@angular/language-service 12.2.2 → 12.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundles/ivy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.2.2
2
+ * @license Angular v12.2.3
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -19938,7 +19938,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
19938
19938
  * Use of this source code is governed by an MIT-style license that can be
19939
19939
  * found in the LICENSE file at https://angular.io/license
19940
19940
  */
19941
- const VERSION$1 = new Version('12.2.2');
19941
+ const VERSION$1 = new Version('12.2.3');
19942
19942
 
19943
19943
  /**
19944
19944
  * @license
@@ -20577,7 +20577,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20577
20577
  function compileDeclareClassMetadata(metadata) {
20578
20578
  const definitionMap = new DefinitionMap();
20579
20579
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
20580
- definitionMap.set('version', literal('12.2.2'));
20580
+ definitionMap.set('version', literal('12.2.3'));
20581
20581
  definitionMap.set('ngImport', importExpr(Identifiers.core));
20582
20582
  definitionMap.set('type', metadata.type);
20583
20583
  definitionMap.set('decorators', metadata.decorators);
@@ -20617,7 +20617,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20617
20617
  function createDirectiveDefinitionMap(meta) {
20618
20618
  const definitionMap = new DefinitionMap();
20619
20619
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
20620
- definitionMap.set('version', literal('12.2.2'));
20620
+ definitionMap.set('version', literal('12.2.3'));
20621
20621
  // e.g. `type: MyDirective`
20622
20622
  definitionMap.set('type', meta.internalType);
20623
20623
  // e.g. `selector: 'some-dir'`
@@ -20834,7 +20834,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20834
20834
  function compileDeclareFactoryFunction(meta) {
20835
20835
  const definitionMap = new DefinitionMap();
20836
20836
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
20837
- definitionMap.set('version', literal('12.2.2'));
20837
+ definitionMap.set('version', literal('12.2.3'));
20838
20838
  definitionMap.set('ngImport', importExpr(Identifiers.core));
20839
20839
  definitionMap.set('type', meta.internalType);
20840
20840
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -20876,7 +20876,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20876
20876
  function createInjectableDefinitionMap(meta) {
20877
20877
  const definitionMap = new DefinitionMap();
20878
20878
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
20879
- definitionMap.set('version', literal('12.2.2'));
20879
+ definitionMap.set('version', literal('12.2.3'));
20880
20880
  definitionMap.set('ngImport', importExpr(Identifiers.core));
20881
20881
  definitionMap.set('type', meta.internalType);
20882
20882
  // Only generate providedIn property if it has a non-null value
@@ -20955,7 +20955,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20955
20955
  function createInjectorDefinitionMap(meta) {
20956
20956
  const definitionMap = new DefinitionMap();
20957
20957
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
20958
- definitionMap.set('version', literal('12.2.2'));
20958
+ definitionMap.set('version', literal('12.2.3'));
20959
20959
  definitionMap.set('ngImport', importExpr(Identifiers.core));
20960
20960
  definitionMap.set('type', meta.internalType);
20961
20961
  definitionMap.set('providers', meta.providers);
@@ -20992,7 +20992,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20992
20992
  function createNgModuleDefinitionMap(meta) {
20993
20993
  const definitionMap = new DefinitionMap();
20994
20994
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
20995
- definitionMap.set('version', literal('12.2.2'));
20995
+ definitionMap.set('version', literal('12.2.3'));
20996
20996
  definitionMap.set('ngImport', importExpr(Identifiers.core));
20997
20997
  definitionMap.set('type', meta.internalType);
20998
20998
  // We only generate the keys in the metadata if the arrays contain values.
@@ -21050,7 +21050,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21050
21050
  function createPipeDefinitionMap(meta) {
21051
21051
  const definitionMap = new DefinitionMap();
21052
21052
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
21053
- definitionMap.set('version', literal('12.2.2'));
21053
+ definitionMap.set('version', literal('12.2.3'));
21054
21054
  definitionMap.set('ngImport', importExpr(Identifiers.core));
21055
21055
  // e.g. `type: MyPipe`
21056
21056
  definitionMap.set('type', meta.internalType);
@@ -21082,7 +21082,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21082
21082
  * Use of this source code is governed by an MIT-style license that can be
21083
21083
  * found in the LICENSE file at https://angular.io/license
21084
21084
  */
21085
- const VERSION$2 = new Version('12.2.2');
21085
+ const VERSION$2 = new Version('12.2.3');
21086
21086
 
21087
21087
  /**
21088
21088
  * @license
@@ -26546,6 +26546,26 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
26546
26546
  }
26547
26547
  }
26548
26548
  }
26549
+ extendedTemplateCheck(sf, extendedTemplateChecker) {
26550
+ const classes = this.fileToClasses.get(sf);
26551
+ if (classes === undefined) {
26552
+ return [];
26553
+ }
26554
+ const diagnostics = [];
26555
+ for (const clazz of classes) {
26556
+ if (!isNamedClassDeclaration(clazz)) {
26557
+ continue;
26558
+ }
26559
+ const record = this.classes.get(clazz);
26560
+ for (const trait of record.traits) {
26561
+ if (trait.handler.extendedTemplateCheck === undefined) {
26562
+ continue;
26563
+ }
26564
+ diagnostics.push(...trait.handler.extendedTemplateCheck(clazz, extendedTemplateChecker));
26565
+ }
26566
+ }
26567
+ return diagnostics;
26568
+ }
26549
26569
  index(ctx) {
26550
26570
  for (const clazz of this.classes.keys()) {
26551
26571
  const record = this.classes.get(clazz);
@@ -30553,6 +30573,9 @@ Either add the @Injectable() decorator to '${provider.node.name
30553
30573
  const binder = new R3TargetBinder(scope.matcher);
30554
30574
  ctx.addTemplate(new Reference$1(node), binder, meta.template.diagNodes, scope.pipes, scope.schemas, meta.template.sourceMapping, meta.template.file, meta.template.errors);
30555
30575
  }
30576
+ extendedTemplateCheck(component, extendedTemplateChecker) {
30577
+ return extendedTemplateChecker.getDiagnosticsForComponent(component);
30578
+ }
30556
30579
  resolve(node, analysis, symbol) {
30557
30580
  if (this.semanticDepGraphUpdater !== null && analysis.baseClass instanceof Reference$1) {
30558
30581
  symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
@@ -39731,7 +39754,7 @@ Either add the @Injectable() decorator to '${provider.node.name
39731
39754
  const fileRecord = this.state.get(sfPath);
39732
39755
  const templateId = fileRecord.sourceManager.getTemplateId(clazz);
39733
39756
  const mapping = fileRecord.sourceManager.getSourceMapping(templateId);
39734
- return makeTemplateDiagnostic(templateId, mapping, sourceSpan, category, errorCode, message, relatedInformation);
39757
+ return Object.assign(Object.assign({}, makeTemplateDiagnostic(templateId, mapping, sourceSpan, category, ngErrorCode(errorCode), message, relatedInformation)), { __ngCode: errorCode });
39735
39758
  }
39736
39759
  getOrCreateCompletionEngine(component) {
39737
39760
  if (this.completionCache.has(component)) {
@@ -40093,6 +40116,141 @@ Either add the @Injectable() decorator to '${provider.node.name
40093
40116
  }
40094
40117
  }
40095
40118
 
40119
+ /**
40120
+ * @license
40121
+ * Copyright Google LLC All Rights Reserved.
40122
+ *
40123
+ * Use of this source code is governed by an MIT-style license that can be
40124
+ * found in the LICENSE file at https://angular.io/license
40125
+ */
40126
+ class ExtendedTemplateCheckerImpl {
40127
+ constructor(templateTypeChecker, typeChecker, templateChecks) {
40128
+ this.templateTypeChecker = templateTypeChecker;
40129
+ this.typeChecker = typeChecker;
40130
+ this.templateChecks = templateChecks;
40131
+ }
40132
+ getDiagnosticsForComponent(component) {
40133
+ const template = this.templateTypeChecker.getTemplate(component);
40134
+ // Skip checks if component has no template. This can happen if the user writes a
40135
+ // `@Component()` but doesn't add the template, could happen in the language service
40136
+ // when users are in the middle of typing code.
40137
+ if (template === null) {
40138
+ return [];
40139
+ }
40140
+ const diagnostics = [];
40141
+ const ctx = {
40142
+ templateTypeChecker: this.templateTypeChecker,
40143
+ typeChecker: this.typeChecker,
40144
+ component
40145
+ };
40146
+ for (const check of this.templateChecks) {
40147
+ diagnostics.push(...deduplicateDiagnostics(check.run(ctx, template)));
40148
+ }
40149
+ return diagnostics;
40150
+ }
40151
+ }
40152
+ // Filter out duplicated diagnostics, this is possible due to the way the compiler
40153
+ // handles desugaring and produces `AST`s. Ex.
40154
+ //
40155
+ // ```
40156
+ // <div *ngIf="true" (foo)="bar">test</div>
40157
+ // ```
40158
+ //
40159
+ // Would result in the following AST:
40160
+ //
40161
+ // ```
40162
+ // Template {
40163
+ // outputs: [
40164
+ // BoundEvent {
40165
+ // name: 'foo',
40166
+ // /.../
40167
+ // }
40168
+ // ],
40169
+ // children: [
40170
+ // Element {
40171
+ // outputs: [
40172
+ // BoundEvent {
40173
+ // name: 'foo',
40174
+ // /.../
40175
+ // }
40176
+ // ]
40177
+ // }
40178
+ // ],
40179
+ // /.../
40180
+ // }
40181
+ // ```
40182
+ //
40183
+ // In this case a duplicated diagnostic could be generated for the output `foo`.
40184
+ // TODO(danieltrevino): handle duplicated diagnostics when they are being generated
40185
+ // to avoid extra work (could be directly in the visitor).
40186
+ // https://github.com/angular/angular/pull/42984#discussion_r684823926
40187
+ function deduplicateDiagnostics(diagnostics) {
40188
+ const result = [];
40189
+ for (const newDiag of diagnostics) {
40190
+ const isDuplicateDiag = result.some(existingDiag => areDiagnosticsEqual(newDiag, existingDiag));
40191
+ if (!isDuplicateDiag) {
40192
+ result.push(newDiag);
40193
+ }
40194
+ }
40195
+ return result;
40196
+ }
40197
+ function areDiagnosticsEqual(first, second) {
40198
+ var _a, _b;
40199
+ return ((_a = first.file) === null || _a === void 0 ? void 0 : _a.fileName) === ((_b = second.file) === null || _b === void 0 ? void 0 : _b.fileName) && first.start === second.start &&
40200
+ first.length === second.length && first.code === second.code;
40201
+ }
40202
+
40203
+ /**
40204
+ * @license
40205
+ * Copyright Google LLC All Rights Reserved.
40206
+ *
40207
+ * Use of this source code is governed by an MIT-style license that can be
40208
+ * found in the LICENSE file at https://angular.io/license
40209
+ */
40210
+ /**
40211
+ * Ensures the two-way binding syntax is correct.
40212
+ * Parentheses should be inside the brackets "[()]".
40213
+ * Will return diagnostic information when "([])" is found.
40214
+ */
40215
+ class InvalidBananaInBoxCheck {
40216
+ constructor() {
40217
+ this.code = 8101;
40218
+ }
40219
+ run(ctx, template) {
40220
+ const visitor = new BananaVisitor(ctx);
40221
+ return visitor.getDiagnostics(template);
40222
+ }
40223
+ }
40224
+ class BananaVisitor extends RecursiveVisitor {
40225
+ constructor(ctx) {
40226
+ super();
40227
+ this.ctx = ctx;
40228
+ this.diagnostics = [];
40229
+ }
40230
+ /**
40231
+ * Check for outputs with names surrounded in brackets "[]".
40232
+ * The syntax '([foo])="bar"' would be interpreted as an @Output()
40233
+ * with name '[foo]'. Just like '(foo)="bar"' would have the name 'foo'.
40234
+ * Generate diagnostic information for the cases found.
40235
+ */
40236
+ visitBoundEvent(boundEvent) {
40237
+ const name = boundEvent.name;
40238
+ if (name.startsWith('[') && name.endsWith(']')) {
40239
+ const boundSyntax = boundEvent.sourceSpan.toString();
40240
+ const expectedBoundSyntax = boundSyntax.replace(`(${name})`, `[(${name.slice(1, -1)})]`);
40241
+ this.diagnostics.push(this.ctx.templateTypeChecker.makeTemplateDiagnostic(this.ctx.component, boundEvent.sourceSpan, ts$1.DiagnosticCategory.Warning, ErrorCode.INVALID_BANANA_IN_BOX, `In the two-way binding syntax the parentheses should be inside the brackets, ex. '${expectedBoundSyntax}'.
40242
+ Find more at https://angular.io/guide/two-way-binding`));
40243
+ }
40244
+ }
40245
+ getDiagnostics(template) {
40246
+ this.diagnostics = [];
40247
+ for (const node of template) {
40248
+ node.visit(this);
40249
+ }
40250
+ return this.diagnostics;
40251
+ }
40252
+ }
40253
+
40096
40254
  /**
40097
40255
  * @license
40098
40256
  * Copyright Google LLC All Rights Reserved.
@@ -40209,6 +40367,10 @@ Either add the @Injectable() decorator to '${provider.node.name
40209
40367
  * with each fresh compilation.
40210
40368
  */
40211
40369
  this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder);
40370
+ if (this.options._extendedTemplateDiagnostics === true &&
40371
+ this.options.strictTemplates === false) {
40372
+ throw new Error('The \'_extendedTemplateDiagnostics\' option requires \'strictTemplates\' to also be enabled.');
40373
+ }
40212
40374
  this.constructionDiagnostics.push(...this.adapter.constructionDiagnostics);
40213
40375
  const incompatibleTypeCheckOptionsDiagnostic = verifyCompatibleTypeCheckOptions(this.options);
40214
40376
  if (incompatibleTypeCheckOptionsDiagnostic !== null) {
@@ -40318,7 +40480,12 @@ Either add the @Injectable() decorator to '${provider.node.name
40318
40480
  * Get all Angular-related diagnostics for this compilation.
40319
40481
  */
40320
40482
  getDiagnostics() {
40321
- return this.addMessageTextDetails([...this.getNonTemplateDiagnostics(), ...this.getTemplateDiagnostics()]);
40483
+ const diagnostics = [];
40484
+ diagnostics.push(...this.getNonTemplateDiagnostics(), ...this.getTemplateDiagnostics());
40485
+ if (this.options._extendedTemplateDiagnostics) {
40486
+ diagnostics.push(...this.getExtendedTemplateDiagnostics());
40487
+ }
40488
+ return this.addMessageTextDetails(diagnostics);
40322
40489
  }
40323
40490
  /**
40324
40491
  * Get all Angular-related diagnostics for this compilation.
@@ -40326,10 +40493,26 @@ Either add the @Injectable() decorator to '${provider.node.name
40326
40493
  * If a `ts.SourceFile` is passed, only diagnostics related to that file are returned.
40327
40494
  */
40328
40495
  getDiagnosticsForFile(file, optimizeFor) {
40329
- return this.addMessageTextDetails([
40330
- ...this.getNonTemplateDiagnostics().filter(diag => diag.file === file),
40331
- ...this.getTemplateDiagnosticsForFile(file, optimizeFor)
40332
- ]);
40496
+ const diagnostics = [];
40497
+ diagnostics.push(...this.getNonTemplateDiagnostics().filter(diag => diag.file === file), ...this.getTemplateDiagnosticsForFile(file, optimizeFor));
40498
+ if (this.options._extendedTemplateDiagnostics) {
40499
+ diagnostics.push(...this.getExtendedTemplateDiagnostics(file));
40500
+ }
40501
+ return this.addMessageTextDetails(diagnostics);
40502
+ }
40503
+ /**
40504
+ * Get all `ts.Diagnostic`s currently available that pertain to the given component.
40505
+ */
40506
+ getDiagnosticsForComponent(component) {
40507
+ const compilation = this.ensureAnalyzed();
40508
+ const ttc = compilation.templateTypeChecker;
40509
+ const diagnostics = [];
40510
+ diagnostics.push(...ttc.getDiagnosticsForComponent(component));
40511
+ if (this.options._extendedTemplateDiagnostics) {
40512
+ const extendedTemplateChecker = compilation.extendedTemplateChecker;
40513
+ diagnostics.push(...extendedTemplateChecker.getDiagnosticsForComponent(component));
40514
+ }
40515
+ return this.addMessageTextDetails(diagnostics);
40333
40516
  }
40334
40517
  /**
40335
40518
  * Add Angular.io error guide links to diagnostics for this compilation.
@@ -40719,6 +40902,24 @@ Either add the @Injectable() decorator to '${provider.node.name
40719
40902
  }
40720
40903
  return this.nonTemplateDiagnostics;
40721
40904
  }
40905
+ /**
40906
+ * Calls the `extendedTemplateCheck` phase of the trait compiler
40907
+ * @param sf optional parameter to get diagnostics for a certain file
40908
+ * or all files in the program if `sf` is undefined
40909
+ * @returns generated extended template diagnostics
40910
+ */
40911
+ getExtendedTemplateDiagnostics(sf) {
40912
+ const diagnostics = [];
40913
+ const compilation = this.ensureAnalyzed();
40914
+ const extendedTemplateChecker = compilation.extendedTemplateChecker;
40915
+ if (sf !== undefined) {
40916
+ return compilation.traitCompiler.extendedTemplateCheck(sf, extendedTemplateChecker);
40917
+ }
40918
+ for (const sf of this.inputProgram.getSourceFiles()) {
40919
+ diagnostics.push(...compilation.traitCompiler.extendedTemplateCheck(sf, extendedTemplateChecker));
40920
+ }
40921
+ return diagnostics;
40922
+ }
40722
40923
  makeCompilation() {
40723
40924
  const checker = this.inputProgram.getTypeChecker();
40724
40925
  const reflector = new TypeScriptReflectionHost(checker);
@@ -40832,6 +41033,8 @@ Either add the @Injectable() decorator to '${provider.node.name
40832
41033
  this.currentProgram = program;
40833
41034
  });
40834
41035
  const templateTypeChecker = new TemplateTypeCheckerImpl(this.inputProgram, notifyingDriver, traitCompiler, this.getTypeCheckingConfig(), refEmitter, reflector, this.adapter, this.incrementalCompilation, scopeRegistry, typeCheckScopeRegistry, this.delegatingPerfRecorder);
41036
+ const templateChecks = [new InvalidBananaInBoxCheck()];
41037
+ const extendedTemplateChecker = new ExtendedTemplateCheckerImpl(templateTypeChecker, checker, templateChecks);
40835
41038
  return {
40836
41039
  isCore,
40837
41040
  traitCompiler,
@@ -40846,6 +41049,7 @@ Either add the @Injectable() decorator to '${provider.node.name
40846
41049
  refEmitter,
40847
41050
  templateTypeChecker,
40848
41051
  resourceRegistry,
41052
+ extendedTemplateChecker
40849
41053
  };
40850
41054
  }
40851
41055
  }
@@ -44409,7 +44613,6 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
44409
44613
  }
44410
44614
  getSemanticDiagnostics(fileName) {
44411
44615
  return this.withCompilerAndPerfTracing(PerfPhase.LsDiagnostics, (compiler) => {
44412
- const ttc = compiler.getTemplateTypeChecker();
44413
44616
  const diagnostics = [];
44414
44617
  if (isTypeScriptFile(fileName)) {
44415
44618
  const program = compiler.getCurrentProgram();
@@ -44445,7 +44648,7 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
44445
44648
  const components = compiler.getComponentsWithTemplateFile(fileName);
44446
44649
  for (const component of components) {
44447
44650
  if (ts.isClassDeclaration(component)) {
44448
- diagnostics.push(...ttc.getDiagnosticsForComponent(component));
44651
+ diagnostics.push(...compiler.getDiagnosticsForComponent(component));
44449
44652
  }
44450
44653
  }
44451
44654
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.2.2
2
+ * @license Angular v12.2.3
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -21475,7 +21475,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
21475
21475
  * Use of this source code is governed by an MIT-style license that can be
21476
21476
  * found in the LICENSE file at https://angular.io/license
21477
21477
  */
21478
- const VERSION$1 = new Version('12.2.2');
21478
+ const VERSION$1 = new Version('12.2.3');
21479
21479
 
21480
21480
  /**
21481
21481
  * @license
@@ -37554,7 +37554,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
37554
37554
  /**
37555
37555
  * @publicApi
37556
37556
  */
37557
- const VERSION$2 = new Version$1('12.2.2');
37557
+ const VERSION$2 = new Version$1('12.2.3');
37558
37558
 
37559
37559
  /**
37560
37560
  * @license
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/language-service",
3
- "version": "12.2.2",
3
+ "version": "12.2.3",
4
4
  "description": "Angular - language services",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",