language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

TypeScript Plugin: JSDoc not recognized

Open dummdidumm opened this issue 4 years ago • 3 comments

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.

dummdidumm avatar May 27 '21 12:05 dummdidumm

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.

dummdidumm avatar Aug 24 '21 08:08 dummdidumm

Bumping this as I'm seeing similar behavior in neovim with the built in LSP when trying to document components with JSDoc

stordahl avatar Sep 14 '22 02:09 stordahl

Did you have the typescript-svelte-plugin installed? Otherwise, it's probably not related.

jasonlyu123 avatar Sep 14 '22 03:09 jasonlyu123