Skip to content
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

(feat) TypeScript plugin #978

Merged
merged 10 commits into from
May 4, 2021
Merged

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented May 3, 2021

Initially support

  • rename (doesn't work for prop renames yet, I'm okay with that)
  • diagnostics
  • find references
  • go to definition

This makes all files TSX hardcoded for now, it seems the TS server is okay with importing tsx into js.

To test this, add

        "typescriptServerPlugins": [
            {
                "name": "typescript-svelte-plugin",
                "enableForWorkspaceTypeScriptVersions": true,
                "path": "typescript-plugin"
            }
        ],

to the contributes property in the vscode extension's package.json

In contrast to #842 this does not set "languages": ["svelte"] which means TS will not take over Svelte files. The advantage is that diagnostics, rename etc within Svelte files stays in the control of the language-server, and only inside TS/JS files Svelte support is added. The drawback is that you need to save file changes to disk for Svelte files in order for the TS server to notice it.

Next steps after merge:

  • publish plugin to npm
  • make it opt-in in the VS Code extension
  • check if we can move some common stuff into a shared folder in the monorepo; maybe we need to publish another npm package

#580
#550
#342
#110

@jasonlyu123 would be great if you could take a look 😃

Simon Holthausen added 2 commits May 3, 2021 12:34
Initially support
- rename (doesn't work properly for all kinds of renames yet; need to filter out references inside generated code)
- diagnostics
- find references (need to filter out references inside generated code)

This makes all files TSX hardcoded for now, it seems the TS server is okay with importing tsx into js

sveltejs#580
sveltejs#550
sveltejs#342
sveltejs#110
@dummdidumm dummdidumm mentioned this pull request May 3, 2021
2 tasks
Copy link
Member

@jasonlyu123 jasonlyu123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's indeed a joy to see the svelte files show up in the ts language features. I listed some minor issues. Another feature I think can be decorated is getImplementationAtPosition. It's mostly the same as getDefinition. Should be easy to add.

packages/typescript-plugin/src/utils.ts Outdated Show resolved Hide resolved
packages/typescript-plugin/src/logger.ts Outdated Show resolved Hide resolved
packages/typescript-plugin/package.json Outdated Show resolved Hide resolved
@dummdidumm
Copy link
Member Author

When does getImplementationAtPosition get called? How could I test this?

@jasonlyu123
Copy link
Member

https://code.visualstudio.com/docs/editor/editingevolved#_go-to-implementation
This one. Or maybe we can do it in another PR.

@dummdidumm dummdidumm merged commit 505d7dc into sveltejs:master May 4, 2021
@dummdidumm dummdidumm deleted the ts-plugin-poc branch May 4, 2021 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants