-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve types for "* .svelte" files from "* .svelte.d.ts" if they exist #878
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? |
One advantage being there are indeed some cases where it's not easy to type the component in the svelte file. Maybe allowing this would make it easier. |
The disadvantage is that if you rename props inside the |
There should be documented way to automatically generate And that would leave the need to write |
I think it is possible but there may be some flaws. My pseudocode:
I think |
Files ending with .svelte.d.ts are now resolved prior to a same file ending with .svelte . This enables library authors to ship type definitions of Svelte files next to their implementation. sveltejs#878
Files ending with .svelte.d.ts are now resolved prior to a same file ending with .svelte . This enables library authors to ship type definitions of Svelte files next to their implementation. #878
@firefish5000 FYI, you might be interested in this upcoming change |
Is 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, butsvelte-language-server
ignores these definition files.Describe the solution you'd like
For plain
*.svelte
file, which doesn't havelang="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 andnpm install && npm run validate
.Errors should be the same between usages of
typed.svelte
andmanually-typed.svelte
components.The text was updated successfully, but these errors were encountered: