Skip to content

Commit

Permalink
Replace dtslint with tsd (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops authored Dec 22, 2023
1 parent e5e5dd2 commit 609386e
Show file tree
Hide file tree
Showing 9 changed files with 2,055 additions and 3,703 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Run tests
run: npm test

dtslint:
name: Validate type definitions
check-types:
name: Check type definitions
runs-on: ubuntu-latest

steps:
Expand All @@ -50,5 +50,5 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Validate type definitions
run: npm run dtslint
- name: Check type definitions
run: npm run check-types
5,532 changes: 1,952 additions & 3,580 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"benchmarks": "node ./benchmarks/run",
"benchmarks-browserify": "./node_modules/.bin/browserify ./benchmarks/runInBrowser.js >./benchmarks/runInBrowser.bundle.js",
"dtslint": "dtslint",
"check-types": "tsd",
"test": "node --test ./tests/*.mjs"
},
"keywords": [
Expand All @@ -35,6 +35,9 @@
"devDependencies": {
"benchmark": "^2.1.4",
"browserify": "^17.0.0",
"dtslint": "^4.0.9"
"tsd": "^0.30.0"
},
"tsd": {
"directory": "./tests"
}
}
27 changes: 27 additions & 0 deletions tests/bind.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {expectError} from 'tsd';
import bind from '../bind';

// bind
bind.default.bind({foo: 'bar'});
const bound = bind.bind({foo: 'bar'});
bind.bind(undefined);
expectError(bind.bind(Symbol()));
bound('foo');
bound(null);
bound(undefined);
bound(true);
bound(false);
bound(42);
bound({ conditional: true });
bound({ conditional: {} });
bound({ conditional: Symbol() });
bound([]);
bound([['bar', null, undefined, true, false, 1234]]);
bound(['bar', null, undefined, true, false, 1234]);
bound('bar', null, undefined, true, false, 1234);
bound('bar', ['abc', { foo: true }]);
bound('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
bound('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
expectError(bound(Symbol()));
expectError(bound([Symbol()]));
expectError(bound([[Symbol()]]));
24 changes: 24 additions & 0 deletions tests/dedupe.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {expectError} from 'tsd';
import dedupe from '../dedupe';

// dedupe
dedupe.default('foo');
dedupe('foo');
dedupe(null);
dedupe(undefined);
dedupe(true);
dedupe(false);
dedupe(42);
dedupe({ conditional: true });
dedupe({ conditional: {} });
dedupe({ conditional: Symbol() });
dedupe([]);
dedupe([['bar', null, undefined, true, false, 1234]]);
dedupe(['bar', null, undefined, true, false, 1234]);
dedupe('bar', null, undefined, true, false, 1234);
dedupe('bar', ['abc', { foo: true }]);
dedupe('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
dedupe('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
expectError(dedupe(Symbol()));
expectError(dedupe([Symbol()]));
expectError(dedupe([[Symbol()]]));
43 changes: 43 additions & 0 deletions tests/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {expectError} from 'tsd';
import classNames from '..';

// default
classNames.default('foo');
classNames('foo');
classNames(null);
classNames(undefined);
classNames(true);
classNames(false);
classNames(42);
classNames({ conditional: true });
classNames({ conditional: {} });
classNames({ conditional: Symbol() });
classNames([]);
classNames([['bar', null, undefined, true, false, 1234]]);
classNames(['bar', null, undefined, true, false, 1234]);
classNames('bar', null, undefined, true, false, 1234);
classNames('bar', ['abc', { foo: true }]);
classNames('bar', ['abc', { foo: true }], { def: false, ijk: 1234 });
classNames('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]);
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);

expectError(classNames(Symbol()));
expectError(classNames([Symbol()]));
expectError(classNames([[Symbol()]]));

// should match tests/index.js
classNames('c', ['a', 'b']);
classNames('', 'b', {}, '');
classNames('a', 0, null, undefined, true, 1, 'b');
classNames('a', [[]]);
classNames('a', []);
classNames('c', ['a', 'b']);
classNames(['a', 'b']);
classNames(['a', 'b'], 'c');
classNames(['a', 'b'], ['c', 'd']);
classNames(['a', 0, null, undefined, false, true, 'b']);
classNames(['a', ['b', 'c']]);
classNames(['a', ['b', ['c', {d: true}]]]);
classNames(['a', {b: true, c: false}]);
classNames({a: true}, 'b', 0);
classNames({}, Infinity, [{}, []]);
100 changes: 0 additions & 100 deletions tests/types.ts

This file was deleted.

14 changes: 0 additions & 14 deletions tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions tslint.json

This file was deleted.

0 comments on commit 609386e

Please sign in to comment.