A
arktype4mo ago
francis

vscode intellisense errors on the same type definition in some files, but not others

e.g. the following type:
const exampleType = type({
email: "string.email",
});
const exampleType = type({
email: "string.email",
});
In some files, this works fine. In others, in the exact same project, this causes the following error:
Type '"string.email"' is not assignable to type '"'string' must reference a module to be accessed using dot syntax "'.
The expected type comes from property 'email' which is declared here on type 'validateObjectLiteral<{ readonly email: "string.email"; }, {}, bindThis<{ readonly email: "string.email"; }>>'
Type '"string.email"' is not assignable to type '"'string' must reference a module to be accessed using dot syntax "'.
The expected type comes from property 'email' which is declared here on type 'validateObjectLiteral<{ readonly email: "string.email"; }, {}, bindThis<{ readonly email: "string.email"; }>>'
Any ideas for what might be going on?
4 Replies
francis
francisOP4mo ago
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:
<const def, r = Type<inferTypeRoot<def, $>, $>>(def: validateTypeRoot<def, $>): r;
<const def, r = Type<inferTypeRoot<def, $>, $>>(def: validateTypeRoot<def, $>): r;
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.
francis
francisOP4mo ago
GitHub
language-tools/packages/svelte2tsx/src/helpers/sveltekit.ts at 0655...
The Svelte Language Server, and official extensions which use it - sveltejs/language-tools
francis
francisOP4mo ago
update, it's not related to the language server, but rather the svelte extension ts plugin.
francis
francisOP4mo ago
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...
Want results from more Discord servers?
Add your server