microsoft / TypeScript-Sublime-Plugin

IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
Apache License 2.0
1.72k stars 237 forks source link

Yarn 2 compatibility/incompatibility? #772

Open tmillr opened 3 years ago

tmillr commented 3 years ago

I'm trying to use this plugin with sublime and yarn 2, but ts "cannot find" imported modules (installed with yarn add for example).

Here are my sublime project settings:

{
    "folders": [
        {
            "path": "."
        }
    ],

    "settings": {
        "typescript_tsdk": "${project_path}/.yarn/sdks/typescript/lib",

        "SublimeLinter.linters.eslint.executable": "${project_path}/.yarn/sdks/eslint/bin/eslint.js",
        "SublimeLinter.linters.eslint.selector": "source.ts, source.js - meta.attribute-with-value"
    }
}

I got eslint working perfectly with yarn 2, but not this plugin. This config here doesn't even seem to get picked up by the plugin for some reason? I know I'm probably missing something that needs to be done in order to specify the setting at the project level, but the docs for this plugin do not elaborate on the specifications of configuring via project settings.

When I specify typescript_tsdk in my main sublime settings however, then the setting does seem to get picked up (I know this because checking in the console reveals an error from this plugin). The setting gets picked up but it errors with

Error: Cannot find module '/Applications/Sublime Text.app/Contents/MacOS/${project_path}/.yarn/sdks/typescript/lib/tsserver.js'

for some reason it is appending my configured path to /Applications/Sublime Text.app/Contents/MacOS/???

I tried both using the project_path var, and also just a ./ prefix, and both produce the same error and do the same thing (append the path to /Applications/Sublime Text.app/Contents/MacOS/ on load). I'm deferring to the global config (instead of project settings like I originally intended) in order to try to just get it setup temporarily so I could do some work already, but I can't get that working either. Obviously it would be optimal to have it configured at the project level since not every project will use yarn 2/yarn cache though. Any help would be great! Thank you!

Jengamon commented 3 years ago

LSP-typescript seems to support setting typescript.tsdk by this example config:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "LSP": {
            "LSP-typescript": {
                "settings": {
                    "typescript.tsdk": "${project_dir}/.yarn/sdks/typescript/lib/",
                }
            }
        }
    }
}

I don't know how to get this plugin to stop outputting errors...

Jengamon commented 3 years ago

I spoke too soon. It stopped outputting any errors, which is very very wrong...