@angular/language-service 10.1.4 → 10.2.1

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 v10.1.4
2
+ * @license Angular v10.2.1
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -10780,11 +10780,12 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
10780
10780
  function extractCommentsWithHash(input) {
10781
10781
  return input.match(_commentWithHashRe) || [];
10782
10782
  }
10783
- const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
10784
- const _curlyRe = /([{}])/g;
10785
- const OPEN_CURLY = '{';
10786
- const CLOSE_CURLY = '}';
10787
10783
  const BLOCK_PLACEHOLDER = '%BLOCK%';
10784
+ const QUOTE_PLACEHOLDER = '%QUOTED%';
10785
+ const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
10786
+ const _quotedRe = /%QUOTED%/g;
10787
+ const CONTENT_PAIRS = new Map([['{', '}']]);
10788
+ const QUOTE_PAIRS = new Map([[`"`, `"`], [`'`, `'`]]);
10788
10789
  class CssRule {
10789
10790
  constructor(selector, content) {
10790
10791
  this.selector = selector;
@@ -10792,9 +10793,12 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
10792
10793
  }
10793
10794
  }
10794
10795
  function processRules(input, ruleCallback) {
10795
- const inputWithEscapedBlocks = escapeBlocks(input);
10796
+ const inputWithEscapedQuotes = escapeBlocks(input, QUOTE_PAIRS, QUOTE_PLACEHOLDER);
10797
+ const inputWithEscapedBlocks = escapeBlocks(inputWithEscapedQuotes.escapedString, CONTENT_PAIRS, BLOCK_PLACEHOLDER);
10796
10798
  let nextBlockIndex = 0;
10797
- return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function (...m) {
10799
+ let nextQuoteIndex = 0;
10800
+ return inputWithEscapedBlocks.escapedString
10801
+ .replace(_ruleRe, (...m) => {
10798
10802
  const selector = m[2];
10799
10803
  let content = '';
10800
10804
  let suffix = m[4];
@@ -10806,7 +10810,8 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
10806
10810
  }
10807
10811
  const rule = ruleCallback(new CssRule(selector, content));
10808
10812
  return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
10809
- });
10813
+ })
10814
+ .replace(_quotedRe, () => inputWithEscapedQuotes.blocks[nextQuoteIndex++]);
10810
10815
  }
10811
10816
  class StringWithEscapedBlocks {
10812
10817
  constructor(escapedString, blocks) {
@@ -10814,35 +10819,46 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
10814
10819
  this.blocks = blocks;
10815
10820
  }
10816
10821
  }
10817
- function escapeBlocks(input) {
10818
- const inputParts = input.split(_curlyRe);
10822
+ function escapeBlocks(input, charPairs, placeholder) {
10819
10823
  const resultParts = [];
10820
10824
  const escapedBlocks = [];
10821
- let bracketCount = 0;
10822
- let currentBlockParts = [];
10823
- for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
10824
- const part = inputParts[partIndex];
10825
- if (part == CLOSE_CURLY) {
10826
- bracketCount--;
10827
- }
10828
- if (bracketCount > 0) {
10829
- currentBlockParts.push(part);
10830
- }
10831
- else {
10832
- if (currentBlockParts.length > 0) {
10833
- escapedBlocks.push(currentBlockParts.join(''));
10834
- resultParts.push(BLOCK_PLACEHOLDER);
10835
- currentBlockParts = [];
10836
- }
10837
- resultParts.push(part);
10838
- }
10839
- if (part == OPEN_CURLY) {
10840
- bracketCount++;
10841
- }
10825
+ let openCharCount = 0;
10826
+ let nonBlockStartIndex = 0;
10827
+ let blockStartIndex = -1;
10828
+ let openChar;
10829
+ let closeChar;
10830
+ for (let i = 0; i < input.length; i++) {
10831
+ const char = input[i];
10832
+ if (char === '\\') {
10833
+ i++;
10834
+ }
10835
+ else if (char === closeChar) {
10836
+ openCharCount--;
10837
+ if (openCharCount === 0) {
10838
+ escapedBlocks.push(input.substring(blockStartIndex, i));
10839
+ resultParts.push(placeholder);
10840
+ nonBlockStartIndex = i;
10841
+ blockStartIndex = -1;
10842
+ openChar = closeChar = undefined;
10843
+ }
10844
+ }
10845
+ else if (char === openChar) {
10846
+ openCharCount++;
10847
+ }
10848
+ else if (openCharCount === 0 && charPairs.has(char)) {
10849
+ openChar = char;
10850
+ closeChar = charPairs.get(char);
10851
+ openCharCount = 1;
10852
+ blockStartIndex = i + 1;
10853
+ resultParts.push(input.substring(nonBlockStartIndex, blockStartIndex));
10854
+ }
10855
+ }
10856
+ if (blockStartIndex !== -1) {
10857
+ escapedBlocks.push(input.substring(blockStartIndex));
10858
+ resultParts.push(placeholder);
10842
10859
  }
10843
- if (currentBlockParts.length > 0) {
10844
- escapedBlocks.push(currentBlockParts.join(''));
10845
- resultParts.push(BLOCK_PLACEHOLDER);
10860
+ else {
10861
+ resultParts.push(input.substring(nonBlockStartIndex));
10846
10862
  }
10847
10863
  return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
10848
10864
  }
@@ -13958,43 +13974,77 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
13958
13974
  const span = new ParseSpan(0, input == null ? 0 : input.length);
13959
13975
  return new ASTWithSource(new Interpolation(span, span.toAbsolute(absoluteOffset), split.strings, expressions), input, location, absoluteOffset, this.errors);
13960
13976
  }
13977
+ /**
13978
+ * Splits a string of text into "raw" text segments and expressions present in interpolations in
13979
+ * the string.
13980
+ * Returns `null` if there are no interpolations, otherwise a
13981
+ * `SplitInterpolation` with splits that look like
13982
+ * <raw text> <expression> <raw text> ... <raw text> <expression> <raw text>
13983
+ */
13961
13984
  splitInterpolation(input, location, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
13962
- const regexp = _getInterpolateRegExp(interpolationConfig);
13963
- const parts = input.split(regexp);
13964
- if (parts.length <= 1) {
13965
- return null;
13966
- }
13967
13985
  const strings = [];
13968
13986
  const expressions = [];
13969
13987
  const offsets = [];
13970
13988
  const stringSpans = [];
13971
13989
  const expressionSpans = [];
13972
- let offset = 0;
13973
- for (let i = 0; i < parts.length; i++) {
13974
- const part = parts[i];
13975
- if (i % 2 === 0) {
13976
- // fixed string
13990
+ let i = 0;
13991
+ let atInterpolation = false;
13992
+ let extendLastString = false;
13993
+ let { start: interpStart, end: interpEnd } = interpolationConfig;
13994
+ while (i < input.length) {
13995
+ if (!atInterpolation) {
13996
+ // parse until starting {{
13997
+ const start = i;
13998
+ i = input.indexOf(interpStart, i);
13999
+ if (i === -1) {
14000
+ i = input.length;
14001
+ }
14002
+ const part = input.substring(start, i);
13977
14003
  strings.push(part);
13978
- const start = offset;
13979
- offset += part.length;
13980
- stringSpans.push({ start, end: offset });
13981
- }
13982
- else if (part.trim().length > 0) {
13983
- const start = offset;
13984
- offset += interpolationConfig.start.length;
13985
- expressions.push(part);
13986
- offsets.push(offset);
13987
- offset += part.length + interpolationConfig.end.length;
13988
- expressionSpans.push({ start, end: offset });
14004
+ stringSpans.push({ start, end: i });
14005
+ atInterpolation = true;
13989
14006
  }
13990
14007
  else {
13991
- this._reportError('Blank expressions are not allowed in interpolated strings', input, `at column ${this._findInterpolationErrorColumn(parts, i, interpolationConfig)} in`, location);
13992
- expressions.push('$implicit');
13993
- offsets.push(offset);
13994
- expressionSpans.push({ start: offset, end: offset });
14008
+ // parse from starting {{ to ending }}
14009
+ const fullStart = i;
14010
+ const exprStart = fullStart + interpStart.length;
14011
+ const exprEnd = input.indexOf(interpEnd, exprStart);
14012
+ if (exprEnd === -1) {
14013
+ // Could not find the end of the interpolation; do not parse an expression.
14014
+ // Instead we should extend the content on the last raw string.
14015
+ atInterpolation = false;
14016
+ extendLastString = true;
14017
+ break;
14018
+ }
14019
+ const fullEnd = exprEnd + interpEnd.length;
14020
+ const part = input.substring(exprStart, exprEnd);
14021
+ if (part.trim().length > 0) {
14022
+ expressions.push(part);
14023
+ }
14024
+ else {
14025
+ this._reportError('Blank expressions are not allowed in interpolated strings', input, `at column ${i} in`, location);
14026
+ expressions.push('$implicit');
14027
+ }
14028
+ offsets.push(exprStart);
14029
+ expressionSpans.push({ start: fullStart, end: fullEnd });
14030
+ i = fullEnd;
14031
+ atInterpolation = false;
14032
+ }
14033
+ }
14034
+ if (!atInterpolation) {
14035
+ // If we are now at a text section, add the remaining content as a raw string.
14036
+ if (extendLastString) {
14037
+ strings[strings.length - 1] += input.substring(i);
14038
+ stringSpans[stringSpans.length - 1].end = input.length;
14039
+ }
14040
+ else {
14041
+ strings.push(input.substring(i));
14042
+ stringSpans.push({ start: i, end: input.length });
13995
14043
  }
13996
14044
  }
13997
- return new SplitInterpolation(strings, stringSpans, expressions, expressionSpans, offsets);
14045
+ return expressions.length === 0 ?
14046
+ null :
14047
+ new SplitInterpolation(strings, stringSpans, expressions, expressionSpans, offsets);
13998
14048
  }
13999
14049
  wrapLiteralPrimitive(input, location, absoluteOffset) {
14000
14050
  const span = new ParseSpan(0, input == null ? 0 : input.length);
@@ -14043,6 +14093,19 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14043
14093
  this.simpleExpressionChecker = IvySimpleExpressionChecker; //
14044
14094
  }
14045
14095
  }
14096
+ /** Describes a stateful context an expression parser is in. */
14097
+ var ParseContextFlags;
14098
+ (function (ParseContextFlags) {
14099
+ ParseContextFlags[ParseContextFlags["None"] = 0] = "None";
14100
+ /**
14101
+ * A Writable context is one in which a value may be written to an lvalue.
14102
+ * For example, after we see a property access, we may expect a write to the
14103
+ * property via the "=" operator.
14104
+ * prop
14105
+ * ^ possible "=" after
14106
+ */
14107
+ ParseContextFlags[ParseContextFlags["Writable"] = 1] = "Writable";
14108
+ })(ParseContextFlags || (ParseContextFlags = {}));
14046
14109
  class _ParseAST {
14047
14110
  constructor(input, location, absoluteOffset, tokens, inputLength, parseAction, errors, offset) {
14048
14111
  this.input = input;
@@ -14056,6 +14119,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14056
14119
  this.rparensExpected = 0;
14057
14120
  this.rbracketsExpected = 0;
14058
14121
  this.rbracesExpected = 0;
14122
+ this.context = ParseContextFlags.None;
14059
14123
  // Cache of expression start and input indeces to the absolute source span they map to, used to
14060
14124
  // prevent creating superfluous source spans in `sourceSpan`.
14061
14125
  // A serial of the expression start and input index is used for mapping because both are stateful
@@ -14116,6 +14180,15 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14116
14180
  advance() {
14117
14181
  this.index++;
14118
14182
  }
14183
+ /**
14184
+ * Executes a callback in the provided context.
14185
+ */
14186
+ withContext(context, cb) {
14187
+ this.context |= context;
14188
+ const ret = cb();
14189
+ this.context ^= context;
14190
+ return ret;
14191
+ }
14119
14192
  consumeOptionalCharacter(code) {
14120
14193
  if (this.next.isCharacter(code)) {
14121
14194
  this.advance();
@@ -14131,6 +14204,12 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14131
14204
  peekKeywordAs() {
14132
14205
  return this.next.isKeywordAs();
14133
14206
  }
14207
+ /**
14208
+ * Consumes an expected character, otherwise emits an error about the missing expected character
14209
+ * and skips over the token stream until reaching a recoverable point.
14210
+ *
14211
+ * See `this.error` and `this.skip` for more details.
14212
+ */
14134
14213
  expectCharacter(code) {
14135
14214
  if (this.consumeOptionalCharacter(code))
14136
14215
  return;
@@ -14150,10 +14229,13 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14150
14229
  return;
14151
14230
  this.error(`Missing expected operator ${operator}`);
14152
14231
  }
14232
+ prettyPrintToken(tok) {
14233
+ return tok === EOF ? 'end of input' : `token ${tok}`;
14234
+ }
14153
14235
  expectIdentifierOrKeyword() {
14154
14236
  const n = this.next;
14155
14237
  if (!n.isIdentifier() && !n.isKeyword()) {
14156
- this.error(`Unexpected token ${n}, expected identifier or keyword`);
14238
+ this.error(`Unexpected ${this.prettyPrintToken(n)}, expected identifier or keyword`);
14157
14239
  return '';
14158
14240
  }
14159
14241
  this.advance();
@@ -14162,7 +14244,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14162
14244
  expectIdentifierOrKeywordOrString() {
14163
14245
  const n = this.next;
14164
14246
  if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
14165
- this.error(`Unexpected token ${n}, expected identifier, keyword, or string`);
14247
+ this.error(`Unexpected ${this.prettyPrintToken(n)}, expected identifier, keyword, or string`);
14166
14248
  return '';
14167
14249
  }
14168
14250
  this.advance();
@@ -14366,17 +14448,23 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14366
14448
  result = this.parseAccessMemberOrMethodCall(result, true);
14367
14449
  }
14368
14450
  else if (this.consumeOptionalCharacter($LBRACKET)) {
14369
- this.rbracketsExpected++;
14370
- const key = this.parsePipe();
14371
- this.rbracketsExpected--;
14372
- this.expectCharacter($RBRACKET);
14373
- if (this.consumeOptionalOperator('=')) {
14374
- const value = this.parseConditional();
14375
- result = new KeyedWrite(this.span(resultStart), this.sourceSpan(resultStart), result, key, value);
14376
- }
14377
- else {
14378
- result = new KeyedRead(this.span(resultStart), this.sourceSpan(resultStart), result, key);
14379
- }
14451
+ this.withContext(ParseContextFlags.Writable, () => {
14452
+ this.rbracketsExpected++;
14453
+ const key = this.parsePipe();
14454
+ if (key instanceof EmptyExpr) {
14455
+ this.error(`Key access cannot be empty`);
14456
+ }
14457
+ this.rbracketsExpected--;
14458
+ this.expectCharacter($RBRACKET);
14459
+ if (this.consumeOptionalOperator('=')) {
14460
+ const value = this.parseConditional();
14461
+ result = new KeyedWrite(this.span(resultStart), this.sourceSpan(resultStart), result, key, value);
14462
+ }
14463
+ else {
14464
+ result =
14465
+ new KeyedRead(this.span(resultStart), this.sourceSpan(resultStart), result, key);
14466
+ }
14467
+ });
14380
14468
  }
14381
14469
  else if (this.consumeOptionalCharacter($LPAREN)) {
14382
14470
  this.rparensExpected++;
@@ -14715,6 +14803,10 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14715
14803
  consumeStatementTerminator() {
14716
14804
  this.consumeOptionalCharacter($SEMICOLON) || this.consumeOptionalCharacter($COMMA);
14717
14805
  }
14806
+ /**
14807
+ * Records an error and skips over the token stream until reaching a recoverable point. See
14808
+ * `this.skip` for more details on token skipping.
14809
+ */
14718
14810
  error(message, index = null) {
14719
14811
  this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));
14720
14812
  this.skip();
@@ -14725,24 +14817,32 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
14725
14817
  return (index < this.tokens.length) ? `at column ${this.tokens[index].index + 1} in` :
14726
14818
  `at the end of the expression`;
14727
14819
  }
14728
- // Error recovery should skip tokens until it encounters a recovery point. skip() treats
14729
- // the end of input and a ';' as unconditionally a recovery point. It also treats ')',
14730
- // '}' and ']' as conditional recovery points if one of calling productions is expecting
14731
- // one of these symbols. This allows skip() to recover from errors such as '(a.) + 1' allowing
14732
- // more of the AST to be retained (it doesn't skip any tokens as the ')' is retained because
14733
- // of the '(' begins an '(' <expr> ')' production). The recovery points of grouping symbols
14734
- // must be conditional as they must be skipped if none of the calling productions are not
14735
- // expecting the closing token else we will never make progress in the case of an
14736
- // extraneous group closing symbol (such as a stray ')'). This is not the case for ';' because
14737
- // parseChain() is always the root production and it expects a ';'.
14738
- // If a production expects one of these token it increments the corresponding nesting count,
14739
- // and then decrements it just prior to checking if the token is in the input.
14820
+ /**
14821
+ * Error recovery should skip tokens until it encounters a recovery point. skip() treats
14822
+ * the end of input and a ';' as unconditionally a recovery point. It also treats ')',
14823
+ * '}' and ']' as conditional recovery points if one of calling productions is expecting
14824
+ * one of these symbols. This allows skip() to recover from errors such as '(a.) + 1' allowing
14825
+ * more of the AST to be retained (it doesn't skip any tokens as the ')' is retained because
14826
+ * of the '(' begins an '(' <expr> ')' production). The recovery points of grouping symbols
14827
+ * must be conditional as they must be skipped if none of the calling productions are not
14828
+ * expecting the closing token else we will never make progress in the case of an
14829
+ * extraneous group closing symbol (such as a stray ')'). This is not the case for ';' because
14830
+ * parseChain() is always the root production and it expects a ';'.
14831
+ *
14832
+ * Furthermore, the presence of a stateful context can add more recovery points.
14833
+ * - in a `Writable` context, we are able to recover after seeing the `=` operator, which
14834
+ * signals the presence of an independent rvalue expression following the `=` operator.
14835
+ *
14836
+ * If a production expects one of these token it increments the corresponding nesting count,
14837
+ * and then decrements it just prior to checking if the token is in the input.
14838
+ */
14740
14839
  skip() {
14741
14840
  let n = this.next;
14742
14841
  while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) &&
14743
14842
  (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) &&
14744
14843
  (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) &&
14745
- (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) {
14844
+ (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET)) &&
14845
+ (!(this.context & ParseContextFlags.Writable) || !n.isOperator('='))) {
14746
14846
  if (this.next.isError()) {
14747
14847
  this.errors.push(new ParserError(this.next.toString(), this.input, this.locationText(), this.location));
14748
14848
  }
@@ -19066,7 +19166,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
19066
19166
  * Use of this source code is governed by an MIT-style license that can be
19067
19167
  * found in the LICENSE file at https://angular.io/license
19068
19168
  */
19069
- const VERSION$1 = new Version('10.1.4');
19169
+ const VERSION$1 = new Version('10.2.1');
19070
19170
 
19071
19171
  /**
19072
19172
  * @license
@@ -19659,7 +19759,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
19659
19759
  * Use of this source code is governed by an MIT-style license that can be
19660
19760
  * found in the LICENSE file at https://angular.io/license
19661
19761
  */
19662
- const VERSION$2 = new Version('10.1.4');
19762
+ const VERSION$2 = new Version('10.2.1');
19663
19763
 
19664
19764
  /**
19665
19765
  * @license
@@ -20078,12 +20178,20 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
20078
20178
  */
20079
20179
  class LocalIdentifierStrategy {
20080
20180
  emit(ref, context, importFlags) {
20181
+ const refSf = getSourceFile(ref.node);
20081
20182
  // If the emitter has specified ForceNewImport, then LocalIdentifierStrategy should not use a
20082
20183
  // local identifier at all, *except* in the source file where the node is actually declared.
20083
- if (importFlags & ImportFlags.ForceNewImport &&
20084
- getSourceFile(ref.node) !== getSourceFile(context)) {
20184
+ if (importFlags & ImportFlags.ForceNewImport && refSf !== context) {
20085
20185
  return null;
20086
20186
  }
20187
+ // If referenced node is not an actual TS declaration (e.g. `class Foo` or `function foo() {}`,
20188
+ // etc) and it is in the current file then just use it directly.
20189
+ // This is important because the reference could be a property access (e.g. `exports.foo`). In
20190
+ // such a case, the reference's `identities` property would be `[foo]`, which would result in an
20191
+ // invalid emission of a free-standing `foo` identifier, rather than `exports.foo`.
20192
+ if (!isDeclaration(ref.node) && refSf === context) {
20193
+ return new WrappedNodeExpr(ref.node);
20194
+ }
20087
20195
  // A Reference can have multiple identities in different files, so it may already have an
20088
20196
  // Identifier in the requested context file.
20089
20197
  const identifier = ref.getIdentityIn(context);
@@ -20166,11 +20274,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
20166
20274
  }
20167
20275
  const exportMap = new Map();
20168
20276
  exports.forEach((declaration, name) => {
20169
- // It's okay to skip inline declarations, since by definition they're not target-able with a
20170
- // ts.Declaration anyway.
20171
- if (declaration.node !== null) {
20172
- exportMap.set(declaration.node, name);
20173
- }
20277
+ exportMap.set(declaration.node, name);
20174
20278
  });
20175
20279
  return exportMap;
20176
20280
  }
@@ -20842,6 +20946,13 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
20842
20946
  */
20843
20947
  KnownDeclaration[KnownDeclaration["TsHelperSpreadArrays"] = 3] = "TsHelperSpreadArrays";
20844
20948
  })(KnownDeclaration || (KnownDeclaration = {}));
20949
+ /**
20950
+ * Returns true if the `decl` is a `ConcreteDeclaration` (ie. that its `node` property is a
20951
+ * `ts.Declaration`).
20952
+ */
20953
+ function isConcreteDeclaration(decl) {
20954
+ return decl.kind === 0 /* Concrete */;
20955
+ }
20845
20956
 
20846
20957
  /**
20847
20958
  * @license
@@ -21093,7 +21204,10 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
21093
21204
  * found in the LICENSE file at https://angular.io/license
21094
21205
  */
21095
21206
  function isNamedClassDeclaration(node) {
21096
- return ts.isClassDeclaration(node) && (node.name !== undefined);
21207
+ return ts.isClassDeclaration(node) && isIdentifier$1(node.name);
21208
+ }
21209
+ function isIdentifier$1(node) {
21210
+ return node !== undefined && ts.isIdentifier(node);
21097
21211
  }
21098
21212
 
21099
21213
  /**
@@ -21184,13 +21298,13 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
21184
21298
  if (!ts.isSourceFile(node)) {
21185
21299
  throw new Error(`getExportsOfModule() called on non-SourceFile in TS code`);
21186
21300
  }
21187
- const map = new Map();
21188
21301
  // Reflect the module to a Symbol, and use getExportsOfModule() to get a list of exported
21189
21302
  // Symbols.
21190
21303
  const symbol = this.checker.getSymbolAtLocation(node);
21191
21304
  if (symbol === undefined) {
21192
21305
  return null;
21193
21306
  }
21307
+ const map = new Map();
21194
21308
  this.checker.getExportsOfModule(symbol).forEach(exportSymbol => {
21195
21309
  // Map each exported Symbol to a Declaration and add it to the map.
21196
21310
  const decl = this.getDeclarationOfSymbol(exportSymbol, null);
@@ -21369,6 +21483,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
21369
21483
  known: null,
21370
21484
  viaModule,
21371
21485
  identity: null,
21486
+ kind: 0 /* Concrete */,
21372
21487
  };
21373
21488
  }
21374
21489
  else if (symbol.declarations !== undefined && symbol.declarations.length > 0) {
@@ -21377,6 +21492,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
21377
21492
  known: null,
21378
21493
  viaModule,
21379
21494
  identity: null,
21495
+ kind: 0 /* Concrete */,
21380
21496
  };
21381
21497
  }
21382
21498
  else {
@@ -22851,12 +22967,7 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
22851
22967
  return this.getResolvedEnum(decl.node, decl.identity.enumMembers, context);
22852
22968
  }
22853
22969
  const declContext = Object.assign(Object.assign({}, context), joinModuleContext(context, node, decl));
22854
- // The identifier's declaration is either concrete (a ts.Declaration exists for it) or inline
22855
- // (a direct reference to a ts.Expression).
22856
- // TODO(alxhub): remove cast once TS is upgraded in g3.
22857
- const result = decl.node !== null ?
22858
- this.visitDeclaration(decl.node, declContext) :
22859
- this.visitExpression(decl.expression, declContext);
22970
+ const result = this.visitAmbiguousDeclaration(decl, declContext);
22860
22971
  if (result instanceof Reference$1) {
22861
22972
  // Only record identifiers to non-synthetic references. Synthetic references may not have the
22862
22973
  // same value at runtime as they do at compile time, so it's not legal to refer to them by the
@@ -22957,12 +23068,18 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
22957
23068
  }
22958
23069
  const declContext = Object.assign(Object.assign({}, context), joinModuleContext(context, node, decl));
22959
23070
  // Visit both concrete and inline declarations.
22960
- // TODO(alxhub): remove cast once TS is upgraded in g3.
22961
- return decl.node !== null ?
22962
- this.visitDeclaration(decl.node, declContext) :
22963
- this.visitExpression(decl.expression, declContext);
23071
+ return this.visitAmbiguousDeclaration(decl, declContext);
22964
23072
  });
22965
23073
  }
23074
+ visitAmbiguousDeclaration(decl, declContext) {
23075
+ return decl.kind === 1 /* Inline */ && decl.implementation !== undefined &&
23076
+ !isDeclaration(decl.implementation) ?
23077
+ // Inline declarations whose `implementation` is a `ts.Expression` should be visited as
23078
+ // an expression.
23079
+ this.visitExpression(decl.implementation, declContext) :
23080
+ // Otherwise just visit the `node` as a declaration.
23081
+ this.visitDeclaration(decl.node, declContext);
23082
+ }
22966
23083
  accessHelper(node, lhs, rhs, context) {
22967
23084
  const strIndex = `${rhs}`;
22968
23085
  if (lhs instanceof Map) {
@@ -23310,13 +23427,6 @@ define(['exports', 'os', 'typescript', 'fs', 'constants', 'stream', 'util', 'ass
23310
23427
  return null;
23311
23428
  }
23312
23429
  }
23313
- /**
23314
- * Helper type guard to workaround a narrowing limitation in g3, where testing for
23315
- * `decl.node !== null` would not narrow `decl` to be of type `ConcreteDeclaration`.
23316
- */
23317
- function isConcreteDeclaration(decl) {
23318
- return decl.node !== null;
23319
- }
23320
23430
 
23321
23431
  /**
23322
23432
  * @license
@@ -26571,10 +26681,16 @@ Either add the @Injectable() decorator to '${provider.node.name
26571
26681
  }
26572
26682
  reflectObjectLiteral(queryData).forEach((queryExpr, propertyName) => {
26573
26683
  queryExpr = unwrapExpression(queryExpr);
26574
- if (!ts.isNewExpression(queryExpr) || !ts.isIdentifier(queryExpr.expression)) {
26684
+ if (!ts.isNewExpression(queryExpr)) {
26575
26685
  throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, 'Decorator query metadata must be an instance of a query type');
26576
26686
  }
26577
- const type = reflector.getImportOfIdentifier(queryExpr.expression);
26687
+ const queryType = ts.isPropertyAccessExpression(queryExpr.expression) ?
26688
+ queryExpr.expression.name :
26689
+ queryExpr.expression;
26690
+ if (!ts.isIdentifier(queryType)) {
26691
+ throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, 'Decorator query metadata must be an instance of a query type');
26692
+ }
26693
+ const type = reflector.getImportOfIdentifier(queryType);
26578
26694
  if (type === null || (!isCore && type.from !== '@angular/core') ||
26579
26695
  !QUERY_TYPES.has(type.name)) {
26580
26696
  throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, 'Decorator query metadata must be an instance of a query type');
@@ -28100,7 +28216,7 @@ Either add the @Injectable() decorator to '${provider.node.name
28100
28216
  else {
28101
28217
  let typeRef = valueRef;
28102
28218
  let typeNode = this.reflector.getDtsDeclaration(typeRef.node);
28103
- if (typeNode !== null && ts.isClassDeclaration(typeNode)) {
28219
+ if (typeNode !== null && isNamedClassDeclaration(typeNode)) {
28104
28220
  typeRef = new Reference$1(typeNode);
28105
28221
  }
28106
28222
  return toR3Reference(valueRef, typeRef, valueContext, typeContext, this.refEmitter);
@@ -28180,7 +28296,7 @@ Either add the @Injectable() decorator to '${provider.node.name
28180
28296
  }
28181
28297
  return null;
28182
28298
  }
28183
- // Verify that a `ts.Declaration` reference is a `ClassDeclaration` reference.
28299
+ // Verify that a "Declaration" reference is a `ClassDeclaration` reference.
28184
28300
  isClassDeclarationReference(ref) {
28185
28301
  return this.reflector.isClass(ref.node);
28186
28302
  }
@@ -28202,7 +28318,7 @@ Either add the @Injectable() decorator to '${provider.node.name
28202
28318
  // Recurse into nested arrays.
28203
28319
  refList.push(...this.resolveTypeList(expr, entry, className, arrayName));
28204
28320
  }
28205
- else if (isDeclarationReference(entry)) {
28321
+ else if (entry instanceof Reference$1) {
28206
28322
  if (!this.isClassDeclarationReference(entry)) {
28207
28323
  throw createValueHasWrongTypeError(entry.node, entry, `Value at position ${idx} in the NgModule.${arrayName} of ${className} is not a class`);
28208
28324
  }
@@ -28220,11 +28336,6 @@ Either add the @Injectable() decorator to '${provider.node.name
28220
28336
  return !compilation.directives.some(directive => directive.ref.node === node) &&
28221
28337
  !compilation.pipes.some(pipe => pipe.ref.node === node);
28222
28338
  }
28223
- function isDeclarationReference(ref) {
28224
- return ref instanceof Reference$1 &&
28225
- (ts.isClassDeclaration(ref.node) || ts.isFunctionDeclaration(ref.node) ||
28226
- ts.isVariableDeclaration(ref.node));
28227
- }
28228
28339
 
28229
28340
  /**
28230
28341
  * @license
@@ -29567,13 +29678,6 @@ Either add the @Injectable() decorator to '${provider.node.name
29567
29678
  node.modifiers.some(mod => mod.kind === ts.SyntaxKind.StaticKeyword);
29568
29679
  }
29569
29680
 
29570
- /**
29571
- * @license
29572
- * Copyright Google LLC All Rights Reserved.
29573
- *
29574
- * Use of this source code is governed by an MIT-style license that can be
29575
- * found in the LICENSE file at https://angular.io/license
29576
- */
29577
29681
  const NOOP_PERF_RECORDER = {
29578
29682
  enabled: false,
29579
29683
  mark: (name, node, category, detail) => { },