Skip to content

Commit 8ab9869

Browse files
committedJun 30, 2022
Require Node.js 14
1 parent c6c2ec4 commit 8ab9869

File tree

4 files changed

+29
-34
lines changed

4 files changed

+29
-34
lines changed
 

‎.github/workflows/main.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 18
14+
- 16
1315
- 14
14-
- 12
1516
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-node@v2
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
1819
with:
1920
node-version: ${{ matrix.node-version }}
2021
- run: npm install

‎package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"email": "sam.verschueren@gmail.com",
1010
"url": "https://github.com/SamVerschueren"
1111
},
12-
"main": "dist/index.js",
13-
"typings": "dist/index.d.ts",
14-
"bin": "dist/cli.js",
12+
"exports": "./dist/index.js",
13+
"types": "./dist/index.d.ts",
14+
"bin": "./dist/cli.js",
1515
"engines": {
16-
"node": ">=12"
16+
"node": ">=14.16"
1717
},
1818
"scripts": {
1919
"prepublishOnly": "npm run build",
@@ -39,7 +39,7 @@
3939
"typedefinitions"
4040
],
4141
"dependencies": {
42-
"@tsd/typescript": "~4.7.3",
42+
"@tsd/typescript": "~4.7.4",
4343
"eslint-formatter-pretty": "^4.1.0",
4444
"globby": "^11.0.1",
4545
"meow": "^9.0.0",
@@ -48,7 +48,7 @@
4848
},
4949
"devDependencies": {
5050
"@ava/typescript": "^1.1.1",
51-
"@types/node": "^14.0.0",
51+
"@types/node": "^14.18.21",
5252
"@types/react": "^16.9.2",
5353
"@typescript-eslint/eslint-plugin": "^4.26.0",
5454
"@typescript-eslint/parser": "^4.26.0",
@@ -61,7 +61,7 @@
6161
"execa": "^5.0.0",
6262
"react": "^16.9.0",
6363
"rxjs": "^6.5.3",
64-
"typescript": "^4.3.2"
64+
"typescript": "~4.7.4"
6565
},
6666
"ava": {
6767
"timeout": "2m",

‎readme.md

+16-22
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22

33
> Check TypeScript type definitions
44
5-
65
## Install
76

8-
```
9-
$ npm install tsd
7+
```sh
8+
npm install tsd
109
```
1110

12-
1311
## Overview
1412

1513
This tool lets you write tests for your type definitions (i.e. your `.d.ts` files) by creating files with the `.test-d.ts` extension.
1614

1715
These `.test-d.ts` files will not be executed, and not even compiled in the standard way. Instead, these files will be parsed for special constructs such as `expectError<Foo>(bar)` and then statically analyzed against your type definitions.
1816

19-
2017
## Usage
2118

2219
Let's assume we wrote a `index.d.ts` type definition for our concat module.
@@ -132,8 +129,12 @@ By default, `tsd` applies the following configuration:
132129
{
133130
"strict": true,
134131
"jsx": "react",
135-
"target": "es2017",
136-
"lib": ["es2017"],
132+
"target": "es2020",
133+
"lib": [
134+
"es2020",
135+
"dom",
136+
"dom.iterable"
137+
],
137138
"module": "commonjs",
138139
// The following option is set and is not overridable.
139140
// It is set to `nodenext` if `module` is `nodenext`, `node16` if `module` is `node16` or `node` otherwise.
@@ -154,7 +155,7 @@ These options will be overridden if a `tsconfig.json` file is found in your proj
154155
}
155156
```
156157

157-
*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option.
158+
*Default options will apply if you don't override them explicitly.* You can't override the `moduleResolution` option.
158159

159160
## Assertions
160161

@@ -196,23 +197,20 @@ Print the type of `value` as a warning.
196197

197198
Useful if you don't know the exact type of the expression passed to `printType()` or the type is too complex to write out by hand.
198199

199-
200200
## Programmatic API
201201

202202
You can use the programmatic API to retrieve the diagnostics and do something with them. This can be useful to run the tests with AVA, Jest or any other testing framework.
203203

204204
```ts
205205
import tsd from 'tsd';
206206

207-
(async () => {
208-
const diagnostics = await tsd();
207+
const diagnostics = await tsd();
209208

210-
console.log(diagnostics.length);
211-
//=> 2
212-
})();
209+
console.log(diagnostics.length);
210+
//=> 2
213211
```
214212

215-
### tsd([options])
213+
### tsd(options?)
216214

217215
Retrieve the type definition diagnostics of the project.
218216

@@ -222,25 +220,21 @@ Type: `object`
222220

223221
##### cwd
224222

225-
Type: `string`<br>
223+
Type: `string`\
226224
Default: `process.cwd()`
227225

228226
Current working directory of the project to retrieve the diagnostics for.
229227

230228
##### typingsFile
231229

232-
Type: `string`<br>
230+
Type: `string`\
233231
Default: The `types` property in `package.json`.
234232

235233
Path to the type definition file you want to test. This can be useful when using a test runner to test specific type definitions per test.
236234

237235
##### testFiles
238236

239-
Type: `string[]`<br>
237+
Type: `string[]`\
240238
Default: Finds files with `.test-d.ts` or `.test-d.tsx` extension.
241239

242240
An array of test files with their path. Uses [globby](https://github.com/sindresorhus/globby) under the hood so that you can fine tune test file discovery.
243-
244-
## License
245-
246-
MIT © [Sam Verschueren](https://github.com/SamVerschueren)

‎source/lib/config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default (pkg: PackageJsonWithTsdConfig, cwd: string): Config => {
4040
compilerOptions: {
4141
strict: true,
4242
jsx: JsxEmit.React,
43-
lib: parseRawLibs(['es2017', 'dom', 'dom.iterable'], cwd),
43+
lib: parseRawLibs(['es2020', 'dom', 'dom.iterable'], cwd),
4444
module,
45-
target: ScriptTarget.ES2017,
45+
target: ScriptTarget.ES2020,
4646
esModuleInterop: true,
4747
...combinedCompilerOptions,
4848
moduleResolution: module === ModuleKind.NodeNext ?

0 commit comments

Comments
 (0)
Please sign in to comment.