src/content/docs/linter/rules/no-undeclared-variables.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/correctness/noUndeclaredVariables`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-undef`](https://eslint.org/docs/latest/rules/no-undef){
"linter": {
"rules": {
"correctness": {
"noUndeclaredVariables": "error"
}
}
}
}
Prevents the usage of variables that haven't been declared inside the document.
If you need to allow-list some global bindings, you can use the javascript.globals configuration.
foobar;
// throw diagnostic for JavaScript files
PromiseLike;
type B<T> = PromiseLike<T>
checkTypesWhen set to true, it checks for undeclared types too.
The option defaults to false.
{
"linter": {
"rules": {
"correctness": {
"noUndeclaredVariables": {
"options": {
"checkTypes": true
}
}
}
}
}
}
type A = number extends infer T ? never : T;