Skip to content

Commit

Permalink
fix: Fix exactOptionalPropertyTypes (#20)
Browse files Browse the repository at this point in the history
This makes this work correctly when exactOptionalPropertyTypes is set to
true.
  • Loading branch information
arv committed Jun 9, 2023
1 parent 25d3d66 commit 46d760a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
23 changes: 10 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"version": "5.1.0",
"repository": "github:rocicorp/logger",
"license": "Apache-2.0",
"engines": {
"node": "^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "mocha --ui=tdd out/*.test.js",
"pretest": "npm run build",
Expand All @@ -27,7 +24,7 @@
"mocha": "^9.2.2",
"prettier": "^2.6.0",
"sinon": "^13.0.1",
"typescript": "^4.6.2"
"typescript": "^5.1.3"
},
"type": "module",
"types": "out/logger.d.ts",
Expand Down
14 changes: 7 additions & 7 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* only [[error]] will be present.
*/
export interface OptionalLogger {
error?(...args: unknown[]): void;
info?(...args: unknown[]): void;
debug?(...args: unknown[]): void;
flush?(): Promise<void>;
error?: ((...args: unknown[]) => void) | undefined;
info?: ((...args: unknown[]) => void) | undefined;
debug?: ((...args: unknown[]) => void) | undefined;
flush?: (() => Promise<void>) | undefined;
}

/**
Expand Down Expand Up @@ -57,9 +57,9 @@ export class TeeLogSink implements LogSink {
}

export class OptionalLoggerImpl implements OptionalLogger {
readonly debug?: (...args: unknown[]) => void = undefined;
readonly info?: (...args: unknown[]) => void = undefined;
readonly error?: (...args: unknown[]) => void = undefined;
readonly debug?: ((...args: unknown[]) => void) | undefined = undefined;
readonly info?: ((...args: unknown[]) => void) | undefined = undefined;
readonly error?: ((...args: unknown[]) => void) | undefined = undefined;
readonly flush: () => Promise<void>;

constructor(logSink: LogSink, level: LogLevel = 'info', context?: Context) {
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,

"importsNotUsedAsValues": "error",

"exactOptionalPropertyTypes": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"outDir": "out",
"allowJs": true,
// esnext for Object.fromEntries
Expand Down

0 comments on commit 46d760a

Please sign in to comment.