Fallback to built-in TypeScript when project lacks typescript dependency#1105
Conversation
When a project has @glint/ember-tsc but not typescript as a direct dependency, the language server would crash on startup because the static `import * as ts from 'typescript'` fails. This adds a fallback chain so Glint can still work using VS Code's built-in TypeScript. Changes: - Language server resolves TypeScript dynamically via createRequire with fallback to GLINT_TYPESCRIPT_PATH env var - ConfigLoader accepts an optional fallback TypeScript instance - findConfig() accepts an optional fallback TypeScript parameter - TSServer plugin passes host ts to findConfig for config loading - VS Code extension sets GLINT_TYPESCRIPT_PATH to VS Code's built-in TypeScript when launching the language server Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This seems relevant, #1102 (comment) -- would this work / clean up anything in this PR? |
Adds support for Eclipse Theia in addition to VS Code, and validates paths with fs.existsSync before setting the env var. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Good call! Updated the extension to use a |
|
|
||
| throw new Error( | ||
| 'TypeScript could not be resolved. Install `typescript` as a dependency, ' + | ||
| 'or ensure the Glint VS Code extension provides a fallback TypeScript path.', |
There was a problem hiding this comment.
"ensure glint VS Code extension provides a fallback TypeScript path"
this is our job, we should not tell the user to do this
Remove reference to internal extension mechanism — users just need to install typescript. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Good question! These two functions aren't duplicated — they serve different roles in different processes:
The flow is: extension finds the path → passes it via env var → language server consumes it as a fallback. |
|
@NullVoxPopuli is this in a reviewable state? your bot didn't check of it's plan so not sure if it considers this finished. |
|
I haven't reviewed it myself yet, but anyone is welcome to attempt to continue to work until i get around to finishing it |
Summary
@glint/ember-tsc(or@glint/template) but nottypescriptas a direct dependency, the language server crashes on startup because the static ESMimport * as ts from 'typescript'failsGLINT_TYPESCRIPT_PATHenv var set by the extensionConfigLoaderandfindConfig()now accept an optional fallback TypeScript instance, so config loading (tsconfig resolution) also works without a project-level TypeScripttstofindConfig(), ensuring proper config loading in that path tooTest plan
pnpm buildsucceedspnpm lintpassespnpm dlx ember-cli@latest new my-app --pnpm@glint/ember-tsctopackage.jsonbut do NOT addtypescripttypescriptinstalled still work as before🤖 Generated with Claude Code