Skip to content

Commit

Permalink
fix(no-undefined-types): support unknown and const; fixes #846
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Mar 6, 2022
1 parent 2d69c70 commit b5b3e17
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .README/rules/no-undefined-types.md
Expand Up @@ -26,7 +26,7 @@ The following types are always considered defined.
- `null`, `undefined`, `void`, `string`, `boolean`, `object`,
`function`, `symbol`
- `number`, `bigint`, `NaN`, `Infinity`
- `any`, `*`
- `any`, `*`, `never`, `unknown`, `const`
- `this`, `true`, `false`
- `Array`, `Object`, `RegExp`, `Date`, `Function`

Expand Down
15 changes: 6 additions & 9 deletions README.md
Expand Up @@ -9549,7 +9549,7 @@ The following types are always considered defined.
- `null`, `undefined`, `void`, `string`, `boolean`, `object`,
`function`, `symbol`
- `number`, `bigint`, `NaN`, `Infinity`
- `any`, `*`
- `any`, `*`, `never`, `unknown`, `const`
- `this`, `true`, `false`
- `Array`, `Object`, `RegExp`, `Date`, `Function`

Expand Down Expand Up @@ -9897,14 +9897,6 @@ function foo () {

}

/**
*
*
*/
function foo () {

}

/**
* @param {MyType} foo - Bar.
* @param {HisType} bar - Foo.
Expand Down Expand Up @@ -10189,6 +10181,11 @@ export class Foo {
}
}
// Settings: {"jsdoc":{"mode":"typescript"}}

/**
* @type {const}
*/
const a = 'string';
````


Expand Down
2 changes: 1 addition & 1 deletion src/rules/noUndefinedTypes.js
Expand Up @@ -14,7 +14,7 @@ const extraTypes = [
'null', 'undefined', 'void', 'string', 'boolean', 'object',
'function', 'symbol',
'number', 'bigint', 'NaN', 'Infinity',
'any', '*', 'never',
'any', '*', 'never', 'unknown', 'const',
'this', 'true', 'false',
'Array', 'Object', 'RegExp', 'Date', 'Function',
];
Expand Down
19 changes: 8 additions & 11 deletions test/rules/assertions/noUndefinedTypes.js
Expand Up @@ -634,17 +634,6 @@ export default {
}
`,
},
{
code: `
/**
*
*
*/
function foo () {
}
`,
},
{
code: `
/**
Expand Down Expand Up @@ -1215,5 +1204,13 @@ export default {
},
},
},
{
code: `
/**
* @type {const}
*/
const a = 'string';
`,
},
],
};

0 comments on commit b5b3e17

Please sign in to comment.