Skip to content

Commit b7a8f36

Browse files
committed
Replace dtslint with tsd
This seems appropriate. I couldn't quite get dtslint to work without also validating types of dependencies, which is not quite what I want.
1 parent f620e49 commit b7a8f36

File tree

8 files changed

+118
-132
lines changed

8 files changed

+118
-132
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
with:
3232
path: ~/.npm
3333
key: npm@${{ matrix.cypress-version }}
34-
- name: Cache TypeScript installs
35-
uses: actions/cache@v2
36-
with:
37-
path: ~/.dts
38-
key: dts
3934
- name: Cache Cypress binaries
4035
uses: actions/cache@v2
4136
with:

lib/index.test-d.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { expectType } from "tsd";
2+
3+
import messages from "@cucumber/messages";
4+
5+
import "./";
6+
7+
import {
8+
Given,
9+
When,
10+
Then,
11+
Step,
12+
defineParameterType,
13+
Before,
14+
After,
15+
DataTable,
16+
} from "../methods";
17+
18+
Given("foo", function (foo, bar: number, baz: string) {
19+
expectType<Mocha.Context>(this);
20+
expectType<unknown>(foo);
21+
expectType<number>(bar);
22+
expectType<string>(baz);
23+
});
24+
25+
Given(/foo/, function (foo, bar: number, baz: string) {
26+
expectType<Mocha.Context>(this);
27+
expectType<unknown>(foo);
28+
expectType<number>(bar);
29+
expectType<string>(baz);
30+
});
31+
32+
When("foo", function (foo, bar: number, baz: string) {
33+
expectType<Mocha.Context>(this);
34+
expectType<unknown>(foo);
35+
expectType<number>(bar);
36+
expectType<string>(baz);
37+
});
38+
39+
When(/foo/, function (foo, bar: number, baz: string) {
40+
expectType<Mocha.Context>(this);
41+
expectType<unknown>(foo);
42+
expectType<number>(bar);
43+
expectType<string>(baz);
44+
});
45+
46+
Then("foo", function (foo, bar: number, baz: string) {
47+
expectType<Mocha.Context>(this);
48+
expectType<unknown>(foo);
49+
expectType<number>(bar);
50+
expectType<string>(baz);
51+
});
52+
53+
Then(/foo/, function (foo, bar: number, baz: string) {
54+
expectType<Mocha.Context>(this);
55+
expectType<unknown>(foo);
56+
expectType<number>(bar);
57+
expectType<string>(baz);
58+
});
59+
60+
declare const table: DataTable;
61+
62+
Then("foo", function () {
63+
// Step should consume Mocha.Context.
64+
Step(this, "foo");
65+
});
66+
67+
Then("foo", function () {
68+
// Step should consume DataTable's.
69+
Step(this, "foo", table);
70+
});
71+
72+
Then("foo", function () {
73+
// Step should consume doc strings.
74+
Step(this, "foo", "bar");
75+
});
76+
77+
defineParameterType({
78+
name: "foo",
79+
regexp: /foo/,
80+
transformer(foo, bar, baz) {
81+
expectType<Mocha.Context>(this);
82+
expectType<string>(foo);
83+
expectType<string>(bar);
84+
expectType<string>(baz);
85+
},
86+
});
87+
88+
Before(function () {
89+
expectType<Mocha.Context>(this);
90+
});
91+
92+
Before({}, function () {
93+
expectType<Mocha.Context>(this);
94+
});
95+
96+
Before({ tags: "foo" }, function () {
97+
expectType<Mocha.Context>(this);
98+
});
99+
100+
After(function () {
101+
expectType<Mocha.Context>(this);
102+
});
103+
104+
After({}, function () {
105+
expectType<Mocha.Context>(this);
106+
});
107+
108+
After({ tags: "foo" }, function () {
109+
expectType<Mocha.Context>(this);
110+
});
111+
112+
expectType<messages.GherkinDocument>(window.testState.gherkinDocument);
113+
expectType<messages.Pickle[]>(window.testState.pickles);
114+
expectType<messages.Pickle>(window.testState.pickle);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"fmt": "prettier --ignore-path .gitignore --write '**/*.ts'",
3636
"test": "npm run test:fmt && npm run test:types && npm run test:unit && npm run test:integration",
3737
"test:fmt": "prettier --ignore-path .gitignore --check '**/*.ts'",
38-
"test:types": "dtslint --expectOnly types",
38+
"test:types": "tsd",
3939
"test:unit": "mocha lib/**/*.test.ts",
4040
"test:run-all-specs": "mocha --timeout 0 test/run-all-specs.ts",
4141
"test:integration": "cucumber-js",
@@ -73,7 +73,6 @@
7373
"@types/stream-buffers": "^3.0.4",
7474
"ast-types": "^0.15.2",
7575
"cypress": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
76-
"dtslint": "^4.2.1",
7776
"esbuild": "^0.14.23",
7877
"fs-extra": "^10.1.0",
7978
"mocha": "^9.2.1",
@@ -84,6 +83,7 @@
8483
"strip-indent": "^3.0.0",
8584
"ts-loader": "^9.2.6",
8685
"ts-node": "^10.5.0",
86+
"tsd": "^0.22.0",
8787
"typescript": "^4.5.5",
8888
"webpack": "^5.69.1"
8989
},

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
"browserify.ts",
2323
"esbuild.ts",
2424
"webpack.ts"
25-
]
25+
],
26+
"exclude": ["lib/index.test-d.ts"]
2627
}

types/index.d.ts

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

types/methods.ts

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

types/testState.ts

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

types/tsconfig.json

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

0 commit comments

Comments
 (0)