vscode intellisense errors on the same type definition in some files, but not others
e.g. the following type:
In some files, this works fine. In others, in the exact same project, this causes the following error:
Any ideas for what might be going on?
6 Replies
Aha, I think I've figured ti out. This is something to do with sveltekit's implicit typing. In
+server.ts
or +page.ts
modules, it appears that the type
import resolves to:
in arktype/out/type.d.ts
In files not prefixed with a +
, it resolves to namespace type { ...
in arktype/out/keywords/ark.d.ts
.
Any suggestions for how I fix this / force the type
import to be correct?
ah, I think it's an interaction with the svelte language server. Disabling the svelte language extension fixes the problem.I suspect the file mangling done here: https://github.com/sveltejs/language-tools/blob/0655c67d25dfa9412f0aac8a1c48a7b3aaa28454/packages/svelte2tsx/src/helpers/sveltekit.ts#L133 - is causing issues
GitHub
language-tools/packages/svelte2tsx/src/helpers/sveltekit.ts at 0655...
The Svelte Language Server, and official extensions which use it - sveltejs/language-tools
update, it's not related to the language server, but rather the svelte extension ts plugin.
opened language-tools issue: https://github.com/sveltejs/language-tools/issues/2474
GitHub
Svelte extension resolves incorrect import types in kit files when ...
Describe the bug The bug appears to be in the typescript plugin for the language extension. It appears under the following conditions: you are working on a sveltekit project with sveltekit-superfor...
I've run into a similar problem with Svelte for VS Code. Quick fix was to downgrade the extension (svelte.svelte-vscode) to 108.6.1.
tl;dr: If your Svelte project doesn't have a
svelte.config.js
file, add it.
The main problem was that the Svelte VS Code extension was casting inferred ArkType types to unknown in the editor.
My project was using Bun with a custom Svelte plugin to compile to JS - I didn't need a svelte.config.js
file to compile to JS, however, TypeScript was acting weird in Svelte files.
Downgrading the Svelte extension to ^108 got inferred types working, but I noticed that the extension was logging that it couldn't find a svelte.config.js
file, so I added one with svelte-preprocess
.
Everything is working as expected after upgrading the Svelte extension to the latest version.Do these problems apply even to the latest versions of ArkType? Because of similar issues I converted all symbols to string literals which I expected to resolve most stuff like this.