-
-
Notifications
You must be signed in to change notification settings - Fork 684
Labels
A-linterArea - LinterArea - Linter
Description
The typescript syntax:
let some_var!: SomeType;
Exists to assert that this variable will be assigned before use.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#definite-assignment-assertions
But the linter incorrectly warns about the assignment with no-unassigned-vars
, claiming it is never assigned. Again, I stress, the whole point of the syntax is to assert to the typescript compiler that it will be assigned in a way that the compiler cannot figure out itself.
This is used in particular with solidjs for refs:
let ref!: HTMLDivElement;
onMount(() => {
// can use ref without errors, since it will be assigned by the time it is used
})
return <div ref={ref}>
...
</div>
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter