Skip to content

Commit 406dac9

Browse files
authored
fix(server): Fall back to bundled TS version if specified TSDK is too old (#1863)
We attempt to use the version of typescript defined in the extension options. However, this might be too old for the required version in the bundled Angular compiler. If this happens, we now attempt to resolve the version from the bundled one instead (and print a warning to the output). Fixes #1855
1 parent 2e6e8c9 commit 406dac9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/version_provider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,16 @@ export function resolveTsServer(probeLocations: string[]): NodeModule {
5151
if (probeLocations.length > 0) {
5252
// The first probe location is `typescript.tsdk` if it is specified.
5353
const resolvedFromTsdk = resolveTsServerFromTsdk(probeLocations[0], probeLocations.slice(1));
54+
const minVersion = new Version(MIN_TS_VERSION);
5455
if (resolvedFromTsdk !== undefined) {
55-
return resolvedFromTsdk;
56+
if (resolvedFromTsdk.version.greaterThanOrEqual(minVersion)) {
57+
return resolvedFromTsdk;
58+
} else {
59+
console.warn(`Ignoring TSDK version specified in the TypeScript extension options ${
60+
resolvedFromTsdk
61+
.version} because it is lower than the required TS version for the language service (${
62+
MIN_TS_VERSION}).`);
63+
}
5664
}
5765
}
5866
return resolveWithMinVersion(TSSERVERLIB, MIN_TS_VERSION, probeLocations, 'typescript');

0 commit comments

Comments
 (0)