You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vetur ignores null and undefined type checking in VSCode with strict null checking enabled in tsconfig (tried with both strict: true and strictNullChecks: true).
Reproduced with minimal .vue file:
<script lang="ts">
function test(): string {
return;
}
const x: string = null;
const y = test();
</script>
The above code should report errors for return intest() function and assignment of null to x, but it doesn't.
Same code in .ts file in the same directory reports errors correctly.
Transpiling the code (rollup + typescript plugin + vue plugin) fails due to errors as expected.
The text was updated successfully, but these errors were encountered:
Not sure if that was the case in OP's case, but in my case the problem is caused by having multiple tsconfig.json files in the project. The vetur seems to prefer the tsconfig.json located in the root of the project over the tsconfig.json located in a particular directory where the component resides.
So we have such tsconfig.json file in the project root:
{ "compilerOptions": { "strict": false } }
And such tsconfig.json file in the /src/strictly-typed/:
{ "compilerOptions": { "strict": true } }
Normal /src/strictly-typed/Something.ts files favour the nearest /src/strictly-typed/tsconfig.json file and have the strict typing, but the code in <script lang="ts"> of /src/strictly-typed/Something.vue files seems to pick up the root one sadly.
If I remove the root tsconfig.json, the strict typing gets picked up from the /src/strictly-typed/tsconfig.json ok and I do get my null checks.
Info
Problem
Vetur ignores null and undefined type checking in VSCode with strict null checking enabled in tsconfig (tried with both
strict: true
andstrictNullChecks: true
).Reproduced with minimal .vue file:
The above code should report errors for return in
test()
function and assignment of null to x, but it doesn't.Same code in .ts file in the same directory reports errors correctly.
Transpiling the code (rollup + typescript plugin + vue plugin) fails due to errors as expected.
The text was updated successfully, but these errors were encountered: