support yarn2 with pnpify

This commit is contained in:
Qiming Zhao 2020-04-17 12:19:17 +08:00
parent 2a46480810
commit 52f625c453
2 changed files with 22 additions and 4 deletions

View file

@ -17,6 +17,20 @@ In your vim/neovim, run command:
:CocInstall coc-tsserver
```
For yarn2 user what to use local typescript module:
- Add PnPify to your dependencies:
```
yarn add @yarnpkg/pnpify
```
- Run the following command, which will generate a new directory called .vscode/pnpify
```
yarn pnpify --sdk
```
### intructions for nvm users
Disable [nvm](https://github.com/creationix/nvm) with the following command:

View file

@ -80,6 +80,8 @@ export class TypeScriptVersion {
}
}
const MODULE_FOLDERS = ['node_modules/typescript/lib', '.vscode/pnpify/typescript/lib']
export class TypeScriptVersionProvider {
public constructor(private configuration: TypeScriptServiceConfiguration) { }
@ -106,10 +108,12 @@ export class TypeScriptVersionProvider {
public getLocalVersion(): TypeScriptVersion | undefined {
let folders = workspace.workspaceFolders.map(f => Uri.parse(f.uri).fsPath)
for (let p of folders) {
if (fs.existsSync(path.join(p, 'node_modules/typescript/lib'))) {
let lib = path.join(p, 'node_modules/typescript/lib')
let version = new TypeScriptVersion(lib)
if (version.isValid) return version
for (let folder of MODULE_FOLDERS) {
let libFolder = path.join(p, folder)
if (fs.existsSync(libFolder)) {
let version = new TypeScriptVersion(libFolder)
if (version.isValid) return version
}
}
}
return null