Skip to content

Commit b5b3e17

Browse files
committed
fix(no-undefined-types): support unknown and const; fixes #846
1 parent 2d69c70 commit b5b3e17

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

.README/rules/no-undefined-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following types are always considered defined.
2626
- `null`, `undefined`, `void`, `string`, `boolean`, `object`,
2727
`function`, `symbol`
2828
- `number`, `bigint`, `NaN`, `Infinity`
29-
- `any`, `*`
29+
- `any`, `*`, `never`, `unknown`, `const`
3030
- `this`, `true`, `false`
3131
- `Array`, `Object`, `RegExp`, `Date`, `Function`
3232

README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -9549,7 +9549,7 @@ The following types are always considered defined.
95499549
- `null`, `undefined`, `void`, `string`, `boolean`, `object`,
95509550
`function`, `symbol`
95519551
- `number`, `bigint`, `NaN`, `Infinity`
9552-
- `any`, `*`
9552+
- `any`, `*`, `never`, `unknown`, `const`
95539553
- `this`, `true`, `false`
95549554
- `Array`, `Object`, `RegExp`, `Date`, `Function`
95559555

@@ -9897,14 +9897,6 @@ function foo () {
98979897

98989898
}
98999899

9900-
/**
9901-
*
9902-
*
9903-
*/
9904-
function foo () {
9905-
9906-
}
9907-
99089900
/**
99099901
* @param {MyType} foo - Bar.
99109902
* @param {HisType} bar - Foo.
@@ -10189,6 +10181,11 @@ export class Foo {
1018910181
}
1019010182
}
1019110183
// Settings: {"jsdoc":{"mode":"typescript"}}
10184+
10185+
/**
10186+
* @type {const}
10187+
*/
10188+
const a = 'string';
1019210189
````
1019310190

1019410191

src/rules/noUndefinedTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const extraTypes = [
1414
'null', 'undefined', 'void', 'string', 'boolean', 'object',
1515
'function', 'symbol',
1616
'number', 'bigint', 'NaN', 'Infinity',
17-
'any', '*', 'never',
17+
'any', '*', 'never', 'unknown', 'const',
1818
'this', 'true', 'false',
1919
'Array', 'Object', 'RegExp', 'Date', 'Function',
2020
];

test/rules/assertions/noUndefinedTypes.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -634,17 +634,6 @@ export default {
634634
}
635635
`,
636636
},
637-
{
638-
code: `
639-
/**
640-
*
641-
*
642-
*/
643-
function foo () {
644-
645-
}
646-
`,
647-
},
648637
{
649638
code: `
650639
/**
@@ -1215,5 +1204,13 @@ export default {
12151204
},
12161205
},
12171206
},
1207+
{
1208+
code: `
1209+
/**
1210+
* @type {const}
1211+
*/
1212+
const a = 'string';
1213+
`,
1214+
},
12181215
],
12191216
};

0 commit comments

Comments
 (0)