svelte-check shows errors that shouldn't appear as of TypeScript 5.4
DePasqualeOrg opened this issue · 3 comments
Describe the bug
When I run svelte-check, I'm getting errors that don't appear in VS Code, where I'm running the latest TypeScript. These are errors that shouldn't appear as of TypeScript 5.4.
Reproduction
https://github.com/DePasqualeOrg/svelte-check-error-demo
No error on src/routes/+page.server.ts
in VS Code, but error when running npm run check
:
/<redacted>/svelte-check-error-demo/src/routes/+page.server.ts:9:5
Error: Type 'FormDataEntryValue[]' is not assignable to type 'string[]'.
Type 'FormDataEntryValue' is not assignable to type 'string'.
Type 'File' is not assignable to type 'string'.
let someVar: string[] = [];
someVar = idStrings; // No error as of TypeScript 5.4: https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#preserved-narrowing-in-closures-following-last-assignments
return { someVar };
Expected behaviour
No error when running npm run check
System Info
- OS: macOS
- IDE: VS Code
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
No response
As pointed out in the PR, you need to bump the typescript version yourself.
Apologies I thought this issue was opened before the PR, I now see that you're using TS5.4 in the reproduction
On closer examination, it looks like VS Code is actually running TypeScript 5.5, which is in beta. The error should no longer appear as of TypeScript 5.5, so svelte-check is working as intended.
https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#inferred-type-predicates