This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bundle JSDoc-built TypeScript declaration file (#34)
* feat: bundle JSDoc-built TypeScript declaration file * refactor: allow undefined keys (but not for keys argument or return value of `unionWith`) * fix: `types` and `files` location * fix: resolve "Cannot find module" error by using `outDir` * refactor: Shorten types with typedefs * refactor: Remove extra `types` * refactor: revert switch to `nodenext` * refactor: Drop use of `KeysLooseReadonly` * refactor: set target to `es6` * chore: move `tsc` to build step * test: tsd tests of declaration file * test: exported type checks * refactor: rename KeysStrict -> VisitorKeysWritable, and KeysStrictReadonly -> VisitorKeys * test: fix reference to declaration file Co-authored-by: Milos Djermanovic <[email protected]> * test: avoid exporting internal `VisitorKeysWritable` type * refactor: Remove need for legacy code tests Co-authored-by: Milos Djermanovic <[email protected]>
- Loading branch information
1 parent
67c0a8b
commit 7f10327
Showing
6 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expectType, expectAssignable, expectError } from 'tsd'; | ||
|
||
import { KEYS, getKeys, unionWith, VisitorKeys } from "../"; | ||
|
||
const assignmentExpression = { | ||
type: "AssignmentExpression", | ||
operator: "=", | ||
left: { | ||
type: "Identifier", | ||
name: "a", | ||
range: [ | ||
0, | ||
1 | ||
] | ||
}, | ||
right: { | ||
type: "Literal", | ||
value: 5, | ||
raw: "5", | ||
range: [ | ||
4, | ||
5 | ||
] | ||
}, | ||
range: [ | ||
0, | ||
5 | ||
] | ||
}; | ||
|
||
expectType<{readonly [type: string]: readonly string[]}>(KEYS); | ||
|
||
expectType<readonly string[]>(getKeys(assignmentExpression)); | ||
|
||
expectType<{readonly [type: string]: readonly string[]}>(unionWith({ | ||
TestInterface1: ["left", "right"], | ||
TestInterface2: ["expression"] | ||
})); | ||
|
||
const readonlyKeys: { | ||
readonly [type: string]: readonly string[] | ||
} = { | ||
TestInterface1: ["left", "right"] | ||
}; | ||
|
||
expectAssignable<VisitorKeys>(readonlyKeys); | ||
|
||
// https://github.com/SamVerschueren/tsd/issues/143 | ||
// expectError(() => { | ||
// const erring: VisitorKeys = { | ||
// TestInterface1: ["left", "right"] | ||
// }; | ||
// erring.TestInterface1 = ["badAttemptOverwrite"]; | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"resolveJsonModule": true, | ||
"allowJs": true, | ||
"checkJs": true, | ||
"noEmit": false, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"strict": true, | ||
"target": "es6", | ||
"outDir": "dist" | ||
}, | ||
"include": ["lib/**/*.js"], | ||
"exclude": ["node_modules"] | ||
} |