language-tools
language-tools copied to clipboard
TypeScript Plugin: JSDoc not recognized
Describe the bug JSDoc in Svelte JS files are not recognized. This for example leads to wrong typings of properties when using them inside TS files.
To Reproduce Use strict mode
Have a Svelte file with
<script>
/**
* @type {string}
*/
export let required;
</script>
Import that file in a TS file
import Bug from './Bug.svelte';
new Bug({ target: null as any, props: { required: 'a string'} }); // <- wrong error, required is of type undefined
Expected behavior JSDoc in Svelte files with no TS is recognized.
System (please complete the following information):
typescript-svelte-plugin version 0.1.2
Additional context The problem is that the plugin treats all files as TSX. Inside TS(X), JSDoc is ignored.
The default language is deprecated in svelte-preprocess and will be removed in the next major version. When that happens, enhance the plugin logic to read from the script lang tag to know if it should be transformed to jsx or tsx.
Bumping this as I'm seeing similar behavior in neovim with the built in LSP when trying to document components with JSDoc
Did you have the typescript-svelte-plugin installed? Otherwise, it's probably not related.