Resolve types for "* .svelte" files from "* .svelte.d.ts" if they exist
See original GitHub issueIs your feature request related to a problem? Please describe.
I want to publish some svelte modules initially written in typescript and preprocessed into “plain” *.svelte
. Also I want to provide typings for those files. It is convenient to place *.svelte.d.ts
files near original *.svelte
file, but svelte-language-server
ignores these definition files.
Describe the solution you’d like
For plain *.svelte
file, which doesn’t have lang="ts"
, lang-server should use simple typescript node-module resolving rules as first attempt. It means that if *.svelte.d.ts
file exists then it should be used.
Additional context
I made a sample project where we can ensure that two files are checked differently and manually typed *.svelte
file is not properly checked. Just clone https://github.com/trash-and-fire/svelte-typings-demo and npm install && npm run validate
.
Errors should be the same between usages of typed.svelte
and manually-typed.svelte
components.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6 (4 by maintainers)
Top GitHub Comments
Standard TS only looks at the file ending and prioritizes d.ts over .js . I think it’s even technically impossible for TS to load both and then decide which one to use, because the internal program can only contain one definition for one file, not two. This means that it’s not possible for Svelte files to change this behavior by actually looking into the file and determine if it has TS or not. This means we got to decide if we either always prioritize .svelte (current state) or always prioritize .svelte.d.ts . Since this only would really occur in the library case, I’m inclined to always prioritize svelte.d.ts . @jasonlyu123 @tomblachut thoughts?
@firefish5000 FYI, you might be interested in this upcoming change