Skip to content

Commit 609386e

Browse files
authored
Replace dtslint with tsd (#330)
1 parent e5e5dd2 commit 609386e

File tree

9 files changed

+2055
-3703
lines changed

9 files changed

+2055
-3703
lines changed

.github/workflows/node.js.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Run tests
3434
run: npm test
3535

36-
dtslint:
37-
name: Validate type definitions
36+
check-types:
37+
name: Check type definitions
3838
runs-on: ubuntu-latest
3939

4040
steps:
@@ -50,5 +50,5 @@ jobs:
5050
- name: Install dependencies
5151
run: npm ci
5252

53-
- name: Validate type definitions
54-
run: npm run dtslint
53+
- name: Check type definitions
54+
run: npm run check-types

package-lock.json

Lines changed: 1952 additions & 3580 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"scripts": {
1414
"benchmarks": "node ./benchmarks/run",
1515
"benchmarks-browserify": "./node_modules/.bin/browserify ./benchmarks/runInBrowser.js >./benchmarks/runInBrowser.bundle.js",
16-
"dtslint": "dtslint",
16+
"check-types": "tsd",
1717
"test": "node --test ./tests/*.mjs"
1818
},
1919
"keywords": [
@@ -35,6 +35,9 @@
3535
"devDependencies": {
3636
"benchmark": "^2.1.4",
3737
"browserify": "^17.0.0",
38-
"dtslint": "^4.0.9"
38+
"tsd": "^0.30.0"
39+
},
40+
"tsd": {
41+
"directory": "./tests"
3942
}
4043
}

tests/bind.test-d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {expectError} from 'tsd';
2+
import bind from '../bind';
3+
4+
// bind
5+
bind.default.bind({foo: 'bar'});
6+
const bound = bind.bind({foo: 'bar'});
7+
bind.bind(undefined);
8+
expectError(bind.bind(Symbol()));
9+
bound('foo');
10+
bound(null);
11+
bound(undefined);
12+
bound(true);
13+
bound(false);
14+
bound(42);
15+
bound({ conditional: true });
16+
bound({ conditional: {} });
17+
bound({ conditional: Symbol() });
18+
bound([]);
19+
bound([['bar', null, undefined, true, false, 1234]]);
20+
bound(['bar', null, undefined, true, false, 1234]);
21+
bound('bar', null, undefined, true, false, 1234);
22+
bound('bar', ['abc', { foo: true }]);
23+
bound('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
24+
bound('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
25+
expectError(bound(Symbol()));
26+
expectError(bound([Symbol()]));
27+
expectError(bound([[Symbol()]]));

tests/dedupe.test-d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {expectError} from 'tsd';
2+
import dedupe from '../dedupe';
3+
4+
// dedupe
5+
dedupe.default('foo');
6+
dedupe('foo');
7+
dedupe(null);
8+
dedupe(undefined);
9+
dedupe(true);
10+
dedupe(false);
11+
dedupe(42);
12+
dedupe({ conditional: true });
13+
dedupe({ conditional: {} });
14+
dedupe({ conditional: Symbol() });
15+
dedupe([]);
16+
dedupe([['bar', null, undefined, true, false, 1234]]);
17+
dedupe(['bar', null, undefined, true, false, 1234]);
18+
dedupe('bar', null, undefined, true, false, 1234);
19+
dedupe('bar', ['abc', { foo: true }]);
20+
dedupe('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
21+
dedupe('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
22+
expectError(dedupe(Symbol()));
23+
expectError(dedupe([Symbol()]));
24+
expectError(dedupe([[Symbol()]]));

tests/index.test-d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {expectError} from 'tsd';
2+
import classNames from '..';
3+
4+
// default
5+
classNames.default('foo');
6+
classNames('foo');
7+
classNames(null);
8+
classNames(undefined);
9+
classNames(true);
10+
classNames(false);
11+
classNames(42);
12+
classNames({ conditional: true });
13+
classNames({ conditional: {} });
14+
classNames({ conditional: Symbol() });
15+
classNames([]);
16+
classNames([['bar', null, undefined, true, false, 1234]]);
17+
classNames(['bar', null, undefined, true, false, 1234]);
18+
classNames('bar', null, undefined, true, false, 1234);
19+
classNames('bar', ['abc', { foo: true }]);
20+
classNames('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
21+
classNames('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
22+
classNames('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }], ['abc', 1234, true, false, undefined, null, { foo: true }] as const);
23+
24+
expectError(classNames(Symbol()));
25+
expectError(classNames([Symbol()]));
26+
expectError(classNames([[Symbol()]]));
27+
28+
// should match tests/index.js
29+
classNames('c', ['a', 'b']);
30+
classNames('', 'b', {}, '');
31+
classNames('a', 0, null, undefined, true, 1, 'b');
32+
classNames('a', [[]]);
33+
classNames('a', []);
34+
classNames('c', ['a', 'b']);
35+
classNames(['a', 'b']);
36+
classNames(['a', 'b'], 'c');
37+
classNames(['a', 'b'], ['c', 'd']);
38+
classNames(['a', 0, null, undefined, false, true, 'b']);
39+
classNames(['a', ['b', 'c']]);
40+
classNames(['a', ['b', ['c', {d: true}]]]);
41+
classNames(['a', {b: true, c: false}]);
42+
classNames({a: true}, 'b', 0);
43+
classNames({}, Infinity, [{}, []]);

tests/types.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

tsconfig.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

tslint.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)