Closed
Description
Expected behavior
No error.
Actual behavior
The type 'Float32ArrayConstructor' is undefined.
The type 'Uint32ArrayConstructor' is undefined.
ESLint Config
{
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["jsdoc"],
"rules": {
"jsdoc/no-undefined-types": "error"
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
}
}
const ELEMENT_ARRAY_BUFFER = 0x8893;
const ARRAY_BUFFER = 0x8892;
/**
* Returns a typed array constructor based on the given buffer type
* @param {number} type Buffer type, either ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER.
* @return {Float32ArrayConstructor|Uint32ArrayConstructor} The typed array class to use for this buffer.
*/
export function getArrayClassForType(type) {
switch (type) {
case ARRAY_BUFFER:
return Float32Array;
case ELEMENT_ARRAY_BUFFER:
return Uint32Array;
default:
return Float32Array;
}
}
Environment
- Node version: v17.5.0
- ESLint version v8.0.0
eslint-plugin-jsdoc
version: 39.3.2
Details
When using "mode": "typescript"
it looks like TypeScript's built-in interface types are not recognized as defined types (e.g. the es2017 typed array types).
Let me know if you'd accept a pull request to add more extra/known types to the list used by the rule.
Activity
brettz9 commentedon May 24, 2022
Sure. For a PR, I think it'd be ideal to be systematic in covering currently supported items as a whole rather than piecemeal, though adding comments as to the source file of additions.
brettz9 commentedon Oct 23, 2022
Since this rule is meant to warn about types that are not available, I think we'd really need a way (for TS users) to check the
tsconfig.json
file so as to know if es5 globals, etc. should be loaded.AustinGil commentedon Dec 8, 2022
Looking for existing issues and I think this is the place, but is this why JSDoc comment complains that things like 'Record', 'Pick', 'T', 'NodeListOf', or 'SubmitEvent' are not defined?
brettz9 commentedon Dec 8, 2022
Yes.
jsdoc/no-undefined-types
reports the typeIterableIterator
is undefined #1066jaydenseric commentedon May 12, 2023
As discussed here, the config
plugin:jsdoc/recommended-typescript-error
should disable thejsdoc/no-undefined-types
rule because TypeScript itself is responsible for reporting errors about invalid JSDoc types.When in TypeScript mode, the rule
jsdoc/no-undefined-types
doesn't just have false errors about global types; if you do{@link foo}
within a class constructor parameter JSDoc description, wherefoo
references a property/method of the same class, TypeScript is smart enough to know what is linked, but the rulejsdoc/no-undefined-types
reports an error unless you change it to{@link ClassName.foo}
.tschaub commentedon May 12, 2023
@jaydenseric - That sounds reasonable to me.
We no longer use the
jsdoc/no-undefined-types
rule due to this issue. To be honest, I'm uncertain if any problems (undetected undefined things) are sneaking through, or if this is the right solution.18 remaining items