Skip to content

Commit c75669b

Browse files
committed
[New] add types
1 parent 39470e7 commit c75669b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1046
-170
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"no-underscore-dangle": "warn",
2424
"object-curly-newline": "off",
2525
"sort-keys": "off",
26+
27+
"no-extra-parens": "off",
2628
},
2729
"ignorePatterns": ["syntax-error.*"],
2830
"overrides": [

.github/workflows/node-aught.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ jobs:
99
range: '< 10'
1010
type: minors
1111
command: npm run tests-only
12+
skip-ls-check: true

bin/import-or-require.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { extname: extnamePath } = require('path');
44
const { pathToFileURL } = require('url');
55
const getPackageType = require('get-package-type');
66

7+
/** @type {(file: string) => undefined | Promise<unknown>} */
78
// eslint-disable-next-line consistent-return
89
module.exports = function importOrRequire(file) {
910
const ext = extnamePath(file);

bin/tape

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ var hasImport = require('has-dynamic-import');
100100

101101
var tape = require('../');
102102

103+
/** @type {(hasSupport: boolean) => Promise<void> | void} */
103104
function importFiles(hasSupport) {
104105
tape.wait();
105106

107+
/** @type {null | undefined | Promise<unknown>} */
106108
var filesPromise;
107109
if (hasSupport) {
108110
var importOrRequire = require('./import-or-require');
@@ -117,10 +119,9 @@ function importFiles(hasSupport) {
117119
}
118120

119121
if (filesPromise) {
120-
filesPromise.then(function () { tape.run(); });
121-
} else {
122-
tape.run();
122+
return filesPromise.then(function () { tape.run(); });
123123
}
124+
return tape.run();
124125
}
125126

126127
hasImport().then(function (hasSupport) {

example/array.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('array', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -26,11 +27,11 @@ test('array', function (t) {
2627
];
2728

2829
Function('fn', 'g', String(output))(
29-
function (xs) {
30+
/** @param {(number | number[])[]} xs */ function (xs) {
3031
t.same(arrays.shift(), xs);
3132
return xs;
3233
},
33-
function (xs) {
34+
/** @param {(number | number[])[]} xs */ function (xs) {
3435
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
3536
}
3637
);

example/fail.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('array', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -26,11 +27,11 @@ test('array', function (t) {
2627
];
2728

2829
Function('fn', 'g', String(output))(
29-
function (xs) {
30+
/** @param {(number | number[])[]} xs */ function (xs) {
3031
t.same(arrays.shift(), xs);
3132
return xs;
3233
},
33-
function (xs) {
34+
/** @param {(number | number[])[]} xs */ function (xs) {
3435
t.same(xs, [[1, 2, [3, 4444]], [5, 6]]);
3536
}
3637
);

example/nested.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('nested array test', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -35,11 +36,11 @@ test('nested array test', function (t) {
3536
];
3637

3738
Function('fn', 'g', String(output))(
38-
function (xs) {
39+
/** @param {(number | number[])[]} xs */ function (xs) {
3940
t.same(arrays.shift(), xs);
4041
return xs;
4142
},
42-
function (xs) {
43+
/** @param {(number | number[])[]} xs */ function (xs) {
4344
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
4445
}
4546
);

example/nested_fail.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('nested array test', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -35,11 +36,11 @@ test('nested array test', function (t) {
3536
];
3637

3738
Function('fn', 'g', String(output))(
38-
function (xs) {
39+
/** @param {(number | number[])[]} xs */ function (xs) {
3940
t.same(arrays.shift(), xs);
4041
return xs;
4142
},
42-
function (xs) {
43+
/** @param {(number | number[])[]} xs */ function (xs) {
4344
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
4445
}
4546
);

example/not_enough_fail.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('array', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -26,11 +27,11 @@ test('array', function (t) {
2627
];
2728

2829
Function('fn', 'g', String(output))(
29-
function (xs) {
30+
/** @param {(number | number[])[]} xs */ function (xs) {
3031
t.same(arrays.shift(), xs);
3132
return xs;
3233
},
33-
function (xs) {
34+
/** @param {(number | number[])[]} xs */ function (xs) {
3435
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
3536
}
3637
);

example/too_many_fail.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('array', function (t) {
99
var src = '(' + function () {
1010
var xs = [1, 2, [3, 4]];
1111
var ys = [5, 6];
12+
// @ts-expect-error
1213
g([xs, ys]);
1314
} + ')()';
1415

@@ -26,11 +27,11 @@ test('array', function (t) {
2627
];
2728

2829
Function('fn', 'g', String(output))(
29-
function (xs) {
30+
/** @param {(number | number[])[]} xs */ function (xs) {
3031
t.same(arrays.shift(), xs);
3132
return xs;
3233
},
33-
function (xs) {
34+
/** @param {(number | number[])[]} xs */ function (xs) {
3435
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
3536
}
3637
);

0 commit comments

Comments
 (0)