TypeStrong / atom-typescript

The only TypeScript package you will ever need
https://atom.io/packages/atom-typescript
MIT License
1.13k stars 205 forks source link

Add configurable tsdk path options #1527

Closed lierdakil closed 4 years ago

lierdakil commented 4 years ago

At the moment, the algorithm is as follows:

  1. From the TypeScript source file in question, traverse the directory tree upwards, looking for .atom-typescript.json or .atom/atom-typescript.json or .vscode/settings.json in each directory (in that order, i.e. if a directory contains .atom-typescript.json, only that one will be used). If a file is found, parse it as a JSON object and

    1. If the JSON object has tsdkPath property, assign it to sdkPath.
    2. Otherwise, if the JSON object has typescript.tsdk property, use the parent directory name of the path specified in the property as sdkPath (i.e. sdkPath = path.dirname(jsonObject['typescript.tsdk']))
    3. Otherwise, go to 2.

    If sdkPath is relative, assume it is relative to the directory being traversed. Check if tsserver/tsc binary exists under ${sdkPath}/lib/${binaryName}.js. If it exists, use it, else go to 2.

  2. Use Atom configuration atom-typescript.tsdkPath as as path to TypeScript SDK installation directory. Check if tsserver/tsc binary exists under ${tsdkPath}/lib/${binaryName}.js. If it exists, use it, else go to 3.
  3. Use the bundled TypeScript SDK.

Notes:

P.S. (1) might seem somewhat extraneous, considering atomic-management exists, however, there are a few caveats with that, and we probably want a solution that isn't dependent on community packages (so that it works unconditionally)