Skip to content

Commit b742190

Browse files
crisbetoatscott
authored andcommitted
fix(server): disable let syntax when not supported
Disables the `@let` syntax for projects that run an Angular version less than 18.1.
1 parent 68f0d60 commit b742190

File tree

8 files changed

+40
-20
lines changed

8 files changed

+40
-20
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU=

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "//:pnpm-lock.yaml").
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=974837034
5-
pnpm-lock.yaml=1771343819
6-
yarn.lock=1590538245
7-
package.json=1973544585
5+
pnpm-lock.yaml=943190807
6+
yarn.lock=-1098466397
7+
package.json=-90176185
88
pnpm-workspace.yaml=1711114604

client/src/client.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,25 @@ export class AngularLanguageClient implements vscode.Disposable {
323323

324324
// Only disable block syntax if we find angular/core and every one we find does not support
325325
// block syntax
326-
if (angularVersions.length > 0 && angularVersions.every(v => v.version.major < 17)) {
327-
args.push('--disableBlockSyntax');
328-
this.outputChannel.appendLine(
329-
`All workspace roots are using versions of Angular that do not support control flow block syntax.` +
330-
` Block syntax parsing in templates will be disabled.`);
326+
if (angularVersions.length > 0) {
327+
const disableBlocks = angularVersions.every(v => v.version.major < 17);
328+
const disableLet = angularVersions.every(v => {
329+
return v.version.major < 18 || v.version.major === 18 && v.version.minor < 1;
330+
});
331+
332+
if (disableBlocks) {
333+
args.push('--disableBlockSyntax');
334+
this.outputChannel.appendLine(
335+
`All workspace roots are using versions of Angular that do not support control flow block syntax.` +
336+
` Block syntax parsing in templates will be disabled.`);
337+
}
338+
339+
if (disableLet) {
340+
args.push('--disableLetSyntax');
341+
this.outputChannel.appendLine(
342+
`All workspace roots are using versions of Angular that do not support @let syntax.` +
343+
` @let syntax parsing in templates will be disabled.`);
344+
}
331345
}
332346

333347
// Pass the earliest Angular version along to the compiler for maximum compatibility.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
"test:legacy-syntaxes": "yarn compile:syntaxes-test && yarn build:syntaxes && jasmine dist/syntaxes/test/driver.js"
239239
},
240240
"dependencies": {
241-
"@angular/language-service": "18.1.0-next.2",
241+
"@angular/language-service": "18.1.0-next.4",
242242
"typescript": "5.4.5",
243243
"vscode-html-languageservice": "^4.2.5",
244244
"vscode-jsonrpc": "6.0.0",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/cmdline_utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface CommandLineOptions {
3838
includeCompletionsWithSnippetText: boolean;
3939
forceStrictTemplates: boolean;
4040
disableBlockSyntax: boolean;
41+
disableLetSyntax: boolean;
4142
angularCoreVersion?: string;
4243
}
4344

@@ -55,6 +56,7 @@ export function parseCommandLine(argv: string[]): CommandLineOptions {
5556
includeCompletionsWithSnippetText: hasArgument(argv, '--includeCompletionsWithSnippetText'),
5657
forceStrictTemplates: hasArgument(argv, '--forceStrictTemplates'),
5758
disableBlockSyntax: hasArgument(argv, '--disableBlockSyntax'),
59+
disableLetSyntax: hasArgument(argv, '--disableLetSyntax'),
5860
angularCoreVersion: findArgument(argv, '--angularCoreVersion'),
5961
};
6062
}

server/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function main() {
4949
includeCompletionsWithSnippetText: options.includeCompletionsWithSnippetText,
5050
forceStrictTemplates: isG3 || options.forceStrictTemplates,
5151
disableBlockSyntax: options.disableBlockSyntax,
52+
disableLetSyntax: options.disableLetSyntax,
5253
angularCoreVersion: options.angularCoreVersion ?? null,
5354
});
5455

server/src/session.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {TextDocument} from 'vscode-languageserver-textdocument';
1414
import * as lsp from 'vscode-languageserver/node';
1515

1616
import {ServerOptions} from '../../common/initialize';
17-
import {OpenOutputChannel, ProjectLanguageService, ProjectLoadingFinish, ProjectLoadingStart, SuggestStrictMode} from '../../common/notifications';
17+
import {ProjectLanguageService, ProjectLoadingFinish, ProjectLoadingStart, SuggestStrictMode} from '../../common/notifications';
1818
import {GetComponentsWithTemplateFile, GetTcbParams, GetTcbRequest, GetTcbResponse, GetTemplateLocationForComponent, GetTemplateLocationForComponentParams, IsInAngularProject, IsInAngularProjectParams} from '../../common/requests';
1919

2020
import {readNgCompletionData, tsCompletionEntryToLspCompletionItem} from './completion';
@@ -34,6 +34,7 @@ export interface SessionOptions {
3434
includeCompletionsWithSnippetText: boolean;
3535
forceStrictTemplates: boolean;
3636
disableBlockSyntax: boolean;
37+
disableLetSyntax: boolean;
3738
angularCoreVersion: string|null;
3839
}
3940

@@ -161,9 +162,11 @@ export class Session {
161162
if (options.disableBlockSyntax) {
162163
pluginConfig.enableBlockSyntax = false;
163164
}
165+
if (options.disableLetSyntax) {
166+
pluginConfig.enableLetSyntax = false;
167+
}
164168
if (options.angularCoreVersion !== null) {
165-
// TODO(crisbeto): temporarily cast to `any` until 17.2 is released.
166-
(pluginConfig as any).angularCoreVersion = options.angularCoreVersion;
169+
pluginConfig.angularCoreVersion = options.angularCoreVersion;
167170
}
168171
projSvc.configurePlugin({
169172
pluginName: options.ngPlugin,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@
158158
uuid "^8.3.2"
159159
yargs "^17.0.0"
160160

161-
"@angular/[email protected].2":
162-
version "18.1.0-next.2"
163-
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-18.1.0-next.2.tgz#f8e31a175ea3df6535f50e1bacf5038e83b5d6d4"
164-
integrity sha512-d1c/rOmbmVxigzuENEdSKjEx+/tqSbuoQJ5iHUmof/rRQGub4fzFI2I3d2sVOJ4eP38/jifVMWGrX0MdrBbJAw==
161+
"@angular/[email protected].4":
162+
version "18.1.0-next.4"
163+
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-18.1.0-next.4.tgz#c220a83d999754a281b1f5c1232cab9d966cbd45"
164+
integrity sha512-1ZBwjnNvZczJ3KkBndLzVIxx1SJ8kSoTlig0E6QlDdExdtduC54ZoSQpugYoPyUUfP6ILxfVyt7Z+Xr9/yHZgQ==
165165

166166
"@assemblyscript/loader@^0.10.1":
167167
version "0.10.1"

0 commit comments

Comments
 (0)