-
-
Notifications
You must be signed in to change notification settings - Fork 209
Adding JSDoc type support #9
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
Conversation
Cool idea! |
I checked my codebase and doesn't find any issue. But if someone do use typescript and doesn't "correctly" set script Changes of this branch includes:
About reactive statement and prefixed store variable, we could add JSDoc declaration in preprocessing. More work will needed to be done after typescript's work about this is done. For now, I think this branch is ready for review/merge. |
Looks good to me! Reactive statements / $-signs should be handled in a preprocessor later on. We also need to think about passing the whole svelte-file in to get rid of "unused method"-stuff and to be able to provide intellisense inside mustache-parts of the html ( |
@dummdidumm also |
@orta any chance you could get a look at this PR and my other two PRs this week and possibly merge them in if they are ok with you? (sry if I'm rushing you) |
OK, cool, this looks good 👍 |
Is this available now and if so how would I enable JSDoc support in a Svelte file? |
|
@jasonlyu123 thanks for the advice. I cloned it and ran EDIT: Got it working by opening it in its own window instead of as part of a workspace and was then able to run the debug function to launch a new instance of VS Code. However, I'm getting no error highlighting, even though |
@jakobrosenberg I will do the same thing I think |
@jakobrosenberg for now you can only use vscode debug (see README) to try it out or use some hack to replace svelte-language-server bin with the compiled one. |
Since #25 we have nightly deployments if commits happened on master, so theoretically - if the deployment succeeded - you should have this feature in the new svelte beta very soon. |
It failed - but I fixed it d02a85d, and there's a new deploy 99.0.2! |
@orta Why the version is |
@dummdidumm any chance you know how to: A) enable highlighting of type errors in .svelte files (I've enabled Check JS in VSCode and it works in plain .js files) |
@jakobrosenberg I doesn't implement vscode's checkJS option, doesn't know there is an option for this. I'll make a new PR later. For now, you can set checkJS in tsconfig.json or jsconfig.json, also you could use |
it'll never follow semver, because the version is totally automatic - so just maxed it out to make that obvious |
@jakobrosenberg I found that svelte-language-server and the extension doesn't use vscode's typescript setting but has some similar settings under svelte.plugin. So even if I add a new setting to enable global checkJS, it won't be the one you mention. About your second question,
can you get me some example of what you mention? |
{
"name": "@sveltech/routify",
"version": "0.0.0-development",
"description": "Routes for Svelte, automated by your filestructure",
"main": "lib/index.js",
"svelte": "runtime/index.js", The svelte key is what is being resolved within Svelte apps, but code completion doesn't work, since VSCode uses the main key.
|
@jakobrosenberg I know what you means know! Thanks for point that out, this is not implemented yet. I'll open a new issue for this, Thanks! |
@jakobrosenberg typescript 3.7 added this useful feature, I stumble upon this a few days ago. It can emit declarations for js written with jsdoc type. You can use tsc with --declaration, --allowJs and --emitDeclarationOnly flags to build declaration |
@jasonlyu123 thank you that was very helpful. After declaring types and replacing the imports from |
I don't know how to configure it to make ts always read those global type definitions. The only solution I come up with is to move it to .ts file and import it. @orta Do know another solution? |
Check "include" in your tsconfig? |
Thanks so much guys. I had completely overlooked the facts that tsconfig handles more than just compilation. I had it it configured to just emit declarations from .js files. |
Propose to add JSDoc type support to language-server
Monitor script type attribute and notify typescript script kind changesAlready doneChecking forHandle by ts language service// @ts-check
getSemanticDiagnostics
for jsruntime/ambient.d.ts
require Update service.ts to fix the errors with imports #8 to work
-- Shared With TS
see discussion in Overview of approaches on a language server #11
More info will be added later