typescript 4.3.1-rc → 4.3.2

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.
@@ -290,7 +290,7 @@ var ts;
290
290
  // The following is baselined as a literal template type without intervention
291
291
  /** The version of the TypeScript compiler release */
292
292
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
293
- ts.version = "4.3.1-rc";
293
+ ts.version = "4.3.2";
294
294
  /* @internal */
295
295
  var Comparison;
296
296
  (function (Comparison) {
@@ -7883,7 +7883,7 @@ var ts;
7883
7883
  Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
7884
7884
  _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
7885
7885
  A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
7886
- The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."),
7886
+ The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."),
7887
7887
  Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
7888
7888
  Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
7889
7889
  An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
@@ -30224,23 +30224,20 @@ var ts;
30224
30224
  return inContext(32768 /* AwaitContext */);
30225
30225
  }
30226
30226
  function parseErrorAtCurrentToken(message, arg0) {
30227
- return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
30227
+ parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
30228
30228
  }
30229
30229
  function parseErrorAtPosition(start, length, message, arg0) {
30230
30230
  // Don't report another error if it would just be at the same position as the last error.
30231
30231
  var lastError = ts.lastOrUndefined(parseDiagnostics);
30232
- var result;
30233
30232
  if (!lastError || start !== lastError.start) {
30234
- result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
30235
- parseDiagnostics.push(result);
30233
+ parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
30236
30234
  }
30237
30235
  // Mark that we've encountered an error. We'll set an appropriate bit on the next
30238
30236
  // node we finish so that it can't be reused incrementally.
30239
30237
  parseErrorBeforeNextFinishedNode = true;
30240
- return result;
30241
30238
  }
30242
30239
  function parseErrorAt(start, end, message, arg0) {
30243
- return parseErrorAtPosition(start, end - start, message, arg0);
30240
+ parseErrorAtPosition(start, end - start, message, arg0);
30244
30241
  }
30245
30242
  function parseErrorAtRange(range, message, arg0) {
30246
30243
  parseErrorAt(range.pos, range.end, message, arg0);
@@ -30397,16 +30394,6 @@ var ts;
30397
30394
  parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
30398
30395
  return false;
30399
30396
  }
30400
- function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) {
30401
- if (token() === closeKind) {
30402
- nextToken();
30403
- return;
30404
- }
30405
- var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
30406
- if (lastError) {
30407
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind)));
30408
- }
30409
- }
30410
30397
  function parseOptional(t) {
30411
30398
  if (token() === t) {
30412
30399
  nextToken();
@@ -33774,11 +33761,10 @@ var ts;
33774
33761
  }
33775
33762
  function parseArrayLiteralExpression() {
33776
33763
  var pos = getNodePos();
33777
- var openBracketPosition = scanner.getTokenPos();
33778
33764
  parseExpected(22 /* OpenBracketToken */);
33779
33765
  var multiLine = scanner.hasPrecedingLineBreak();
33780
33766
  var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
33781
- parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition);
33767
+ parseExpected(23 /* CloseBracketToken */);
33782
33768
  return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
33783
33769
  }
33784
33770
  function parseObjectLiteralElement() {
@@ -33838,7 +33824,12 @@ var ts;
33838
33824
  parseExpected(18 /* OpenBraceToken */);
33839
33825
  var multiLine = scanner.hasPrecedingLineBreak();
33840
33826
  var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
33841
- parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition);
33827
+ if (!parseExpected(19 /* CloseBraceToken */)) {
33828
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
33829
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33830
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33831
+ }
33832
+ }
33842
33833
  return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
33843
33834
  }
33844
33835
  function parseFunctionExpression() {
@@ -33912,7 +33903,12 @@ var ts;
33912
33903
  if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
33913
33904
  var multiLine = scanner.hasPrecedingLineBreak();
33914
33905
  var statements = parseList(1 /* BlockStatements */, parseStatement);
33915
- parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition);
33906
+ if (!parseExpected(19 /* CloseBraceToken */)) {
33907
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
33908
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33909
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33910
+ }
33911
+ }
33916
33912
  var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
33917
33913
  if (token() === 62 /* EqualsToken */) {
33918
33914
  parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
@@ -33957,10 +33953,9 @@ var ts;
33957
33953
  var pos = getNodePos();
33958
33954
  var hasJSDoc = hasPrecedingJSDocComment();
33959
33955
  parseExpected(98 /* IfKeyword */);
33960
- var openParenPosition = scanner.getTokenPos();
33961
33956
  parseExpected(20 /* OpenParenToken */);
33962
33957
  var expression = allowInAnd(parseExpression);
33963
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33958
+ parseExpected(21 /* CloseParenToken */);
33964
33959
  var thenStatement = parseStatement();
33965
33960
  var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined;
33966
33961
  return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
@@ -33971,10 +33966,9 @@ var ts;
33971
33966
  parseExpected(89 /* DoKeyword */);
33972
33967
  var statement = parseStatement();
33973
33968
  parseExpected(114 /* WhileKeyword */);
33974
- var openParenPosition = scanner.getTokenPos();
33975
33969
  parseExpected(20 /* OpenParenToken */);
33976
33970
  var expression = allowInAnd(parseExpression);
33977
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33971
+ parseExpected(21 /* CloseParenToken */);
33978
33972
  // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
33979
33973
  // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
33980
33974
  // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
@@ -33986,10 +33980,9 @@ var ts;
33986
33980
  var pos = getNodePos();
33987
33981
  var hasJSDoc = hasPrecedingJSDocComment();
33988
33982
  parseExpected(114 /* WhileKeyword */);
33989
- var openParenPosition = scanner.getTokenPos();
33990
33983
  parseExpected(20 /* OpenParenToken */);
33991
33984
  var expression = allowInAnd(parseExpression);
33992
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33985
+ parseExpected(21 /* CloseParenToken */);
33993
33986
  var statement = parseStatement();
33994
33987
  return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
33995
33988
  }
@@ -34056,10 +34049,9 @@ var ts;
34056
34049
  var pos = getNodePos();
34057
34050
  var hasJSDoc = hasPrecedingJSDocComment();
34058
34051
  parseExpected(115 /* WithKeyword */);
34059
- var openParenPosition = scanner.getTokenPos();
34060
34052
  parseExpected(20 /* OpenParenToken */);
34061
34053
  var expression = allowInAnd(parseExpression);
34062
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
34054
+ parseExpected(21 /* CloseParenToken */);
34063
34055
  var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
34064
34056
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
34065
34057
  }
@@ -36050,7 +36042,8 @@ var ts;
36050
36042
  hasChildren = true;
36051
36043
  if (child.kind === 333 /* JSDocTypeTag */) {
36052
36044
  if (childTypeTag) {
36053
- var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
36045
+ parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
36046
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
36054
36047
  if (lastError) {
36055
36048
  ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
36056
36049
  }
@@ -56211,6 +56204,10 @@ var ts;
56211
56204
  var indexSymbol = symbol && getIndexSymbol(symbol);
56212
56205
  return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56213
56206
  }
56207
+ function getIndexDeclarationOfSymbolTable(symbolTable, kind) {
56208
+ var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable);
56209
+ return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56210
+ }
56214
56211
  function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) {
56215
56212
  var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */;
56216
56213
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
@@ -63419,14 +63416,17 @@ var ts;
63419
63416
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]);
63420
63417
  }
63421
63418
  function getGlobalNonNullableTypeInstantiation(type) {
63419
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
63420
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
63421
+ // that isn't eliminated by a NonNullable<T> instantiation.
63422
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
63422
63423
  if (!deferredGlobalNonNullableTypeAlias) {
63423
63424
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
63424
63425
  }
63425
- // Use NonNullable global type alias if available to improve quick info/declaration emit
63426
- if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
63427
- return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
63428
- }
63429
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior
63426
+ // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
63427
+ return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
63428
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
63429
+ reducedType;
63430
63430
  }
63431
63431
  function getNonNullableType(type) {
63432
63432
  return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
@@ -67014,7 +67014,7 @@ var ts;
67014
67014
  !isGenericIndexType(getTypeOfExpression(parent.argumentExpression));
67015
67015
  }
67016
67016
  function isGenericTypeWithUnionConstraint(type) {
67017
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & 1048576 /* Union */);
67017
+ return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
67018
67018
  }
67019
67019
  function containsGenericType(type) {
67020
67020
  return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType));
@@ -78488,21 +78488,24 @@ var ts;
78488
78488
  checkBlock(node.finallyBlock);
78489
78489
  }
78490
78490
  }
78491
- function checkIndexConstraints(type) {
78492
- var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */);
78493
- var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */);
78491
+ function checkIndexConstraints(type, isStatic) {
78492
+ var _a, _b, _c, _d;
78493
+ var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */);
78494
+ var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */);
78494
78495
  var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
78495
78496
  var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
78496
78497
  if (stringIndexType || numberIndexType) {
78497
78498
  ts.forEach(getPropertiesOfObjectType(type), function (prop) {
78499
+ if (isStatic && prop.flags & 4194304 /* Prototype */)
78500
+ return;
78498
78501
  var propType = getTypeOfSymbol(prop);
78499
78502
  checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */);
78500
78503
  checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */);
78501
78504
  });
78502
78505
  var classDeclaration = type.symbol.valueDeclaration;
78503
78506
  if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) {
78504
- for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
78505
- var member = _a[_i];
78507
+ for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) {
78508
+ var member = _e[_i];
78506
78509
  // Only process instance properties with computed names here.
78507
78510
  // Static properties cannot be in conflict with indexers,
78508
78511
  // and properties with literal names were already checked.
@@ -78832,7 +78835,7 @@ var ts;
78832
78835
  }
78833
78836
  if (produceDiagnostics) {
78834
78837
  checkIndexConstraints(type);
78835
- checkIndexConstraints(staticType);
78838
+ checkIndexConstraints(staticType, /*isStatic*/ true);
78836
78839
  checkTypeForDuplicateIndexSignatures(node);
78837
78840
  checkPropertyInitialization(node);
78838
78841
  }
@@ -88891,10 +88894,11 @@ var ts;
88891
88894
  return ts.visitEachChild(node, visitor, context);
88892
88895
  }
88893
88896
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true);
88897
+ var pendingPrivateStateAssignment;
88894
88898
  if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) {
88895
88899
  var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true);
88896
88900
  getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp);
88897
- getPendingExpressions().push(factory.createAssignment(temp, factory.getInternalName(node)));
88901
+ pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node));
88898
88902
  }
88899
88903
  var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
88900
88904
  var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */);
@@ -88903,6 +88907,9 @@ var ts;
88903
88907
  /*decorators*/ undefined, node.modifiers, node.name,
88904
88908
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
88905
88909
  ];
88910
+ if (pendingPrivateStateAssignment) {
88911
+ getPendingExpressions().unshift(pendingPrivateStateAssignment);
88912
+ }
88906
88913
  // Write any pending expressions from elided or moved computed property names
88907
88914
  if (ts.some(pendingExpressions)) {
88908
88915
  statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
@@ -123737,6 +123744,8 @@ var ts;
123737
123744
  return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions());
123738
123745
  case 3 /* JsDocParameterName */:
123739
123746
  return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag));
123747
+ case 4 /* Keywords */:
123748
+ return specificKeywordCompletionInfo(completionData.keywords);
123740
123749
  default:
123741
123750
  return ts.Debug.assertNever(completionData);
123742
123751
  }
@@ -123745,6 +123754,19 @@ var ts;
123745
123754
  function jsdocCompletionInfo(entries) {
123746
123755
  return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries };
123747
123756
  }
123757
+ function specificKeywordCompletionInfo(keywords) {
123758
+ return {
123759
+ isGlobalCompletion: false,
123760
+ isMemberCompletion: false,
123761
+ isNewIdentifierLocation: false,
123762
+ entries: keywords.map(function (k) { return ({
123763
+ name: ts.tokenToString(k),
123764
+ kind: "keyword" /* keyword */,
123765
+ kindModifiers: "" /* none */,
123766
+ sortText: SortText.GlobalsOrKeywords,
123767
+ }); }),
123768
+ };
123769
+ }
123748
123770
  function getOptionalReplacementSpan(location) {
123749
123771
  // StringLiteralLike locations are handled separately in stringCompletions.ts
123750
123772
  return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
@@ -124169,6 +124191,8 @@ var ts;
124169
124191
  return ts.JsDoc.getJSDocTagCompletionDetails(name);
124170
124192
  case 3 /* JsDocParameterName */:
124171
124193
  return ts.JsDoc.getJSDocParameterNameCompletionDetails(name);
124194
+ case 4 /* Keywords */:
124195
+ return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined;
124172
124196
  default:
124173
124197
  return ts.Debug.assertNever(request);
124174
124198
  }
@@ -124227,6 +124251,7 @@ var ts;
124227
124251
  CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName";
124228
124252
  CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag";
124229
124253
  CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName";
124254
+ CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords";
124230
124255
  })(CompletionDataKind || (CompletionDataKind = {}));
124231
124256
  var CompletionKind;
124232
124257
  (function (CompletionKind) {
@@ -124387,13 +124412,17 @@ var ts;
124387
124412
  var importCompletionNode;
124388
124413
  var location = ts.getTouchingPropertyName(sourceFile, position);
124389
124414
  if (contextToken) {
124415
+ var importCompletionCandidate = getImportCompletionNode(contextToken);
124416
+ if (importCompletionCandidate === 153 /* FromKeyword */) {
124417
+ return { kind: 4 /* Keywords */, keywords: [153 /* FromKeyword */] };
124418
+ }
124390
124419
  // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
124391
124420
  // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
124392
124421
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
124393
124422
  // to opt in with the `includeCompletionsForImportStatements` user preference.
124394
- importCompletionNode = preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText
124395
- ? getImportCompletionNode(contextToken)
124396
- : undefined;
124423
+ if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
124424
+ importCompletionNode = importCompletionCandidate;
124425
+ }
124397
124426
  // Bail out if this is a known invalid completion location
124398
124427
  if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
124399
124428
  log("Returning an empty list because completion was requested in an invalid position.");
@@ -126147,16 +126176,20 @@ var ts;
126147
126176
  }
126148
126177
  function getImportCompletionNode(contextToken) {
126149
126178
  var candidate = getCandidate();
126150
- return candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined;
126179
+ return candidate === 153 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined;
126151
126180
  function getCandidate() {
126152
126181
  var parent = contextToken.parent;
126153
126182
  if (ts.isImportEqualsDeclaration(parent)) {
126154
126183
  return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined;
126155
126184
  }
126156
126185
  if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) {
126157
- return isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name
126158
- ? parent.parent.parent
126159
- : undefined;
126186
+ if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) {
126187
+ // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from`
126188
+ return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 78 /* Identifier */
126189
+ ? 153 /* FromKeyword */
126190
+ : parent.parent.parent;
126191
+ }
126192
+ return undefined;
126160
126193
  }
126161
126194
  if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) {
126162
126195
  // A lone import keyword with nothing following it does not parse as a statement at all
@@ -85,7 +85,7 @@ var ts;
85
85
  // The following is baselined as a literal template type without intervention
86
86
  /** The version of the TypeScript compiler release */
87
87
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
88
- ts.version = "4.3.1-rc";
88
+ ts.version = "4.3.2";
89
89
  /* @internal */
90
90
  var Comparison;
91
91
  (function (Comparison) {
@@ -7678,7 +7678,7 @@ var ts;
7678
7678
  Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
7679
7679
  _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
7680
7680
  A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
7681
- The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."),
7681
+ The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."),
7682
7682
  Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
7683
7683
  Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
7684
7684
  An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
@@ -30019,23 +30019,20 @@ var ts;
30019
30019
  return inContext(32768 /* AwaitContext */);
30020
30020
  }
30021
30021
  function parseErrorAtCurrentToken(message, arg0) {
30022
- return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
30022
+ parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
30023
30023
  }
30024
30024
  function parseErrorAtPosition(start, length, message, arg0) {
30025
30025
  // Don't report another error if it would just be at the same position as the last error.
30026
30026
  var lastError = ts.lastOrUndefined(parseDiagnostics);
30027
- var result;
30028
30027
  if (!lastError || start !== lastError.start) {
30029
- result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
30030
- parseDiagnostics.push(result);
30028
+ parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
30031
30029
  }
30032
30030
  // Mark that we've encountered an error. We'll set an appropriate bit on the next
30033
30031
  // node we finish so that it can't be reused incrementally.
30034
30032
  parseErrorBeforeNextFinishedNode = true;
30035
- return result;
30036
30033
  }
30037
30034
  function parseErrorAt(start, end, message, arg0) {
30038
- return parseErrorAtPosition(start, end - start, message, arg0);
30035
+ parseErrorAtPosition(start, end - start, message, arg0);
30039
30036
  }
30040
30037
  function parseErrorAtRange(range, message, arg0) {
30041
30038
  parseErrorAt(range.pos, range.end, message, arg0);
@@ -30192,16 +30189,6 @@ var ts;
30192
30189
  parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
30193
30190
  return false;
30194
30191
  }
30195
- function parseExpectedMatchingBrackets(openKind, closeKind, openPosition) {
30196
- if (token() === closeKind) {
30197
- nextToken();
30198
- return;
30199
- }
30200
- var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
30201
- if (lastError) {
30202
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind)));
30203
- }
30204
- }
30205
30192
  function parseOptional(t) {
30206
30193
  if (token() === t) {
30207
30194
  nextToken();
@@ -33569,11 +33556,10 @@ var ts;
33569
33556
  }
33570
33557
  function parseArrayLiteralExpression() {
33571
33558
  var pos = getNodePos();
33572
- var openBracketPosition = scanner.getTokenPos();
33573
33559
  parseExpected(22 /* OpenBracketToken */);
33574
33560
  var multiLine = scanner.hasPrecedingLineBreak();
33575
33561
  var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
33576
- parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketPosition);
33562
+ parseExpected(23 /* CloseBracketToken */);
33577
33563
  return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
33578
33564
  }
33579
33565
  function parseObjectLiteralElement() {
@@ -33633,7 +33619,12 @@ var ts;
33633
33619
  parseExpected(18 /* OpenBraceToken */);
33634
33620
  var multiLine = scanner.hasPrecedingLineBreak();
33635
33621
  var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
33636
- parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition);
33622
+ if (!parseExpected(19 /* CloseBraceToken */)) {
33623
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
33624
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33625
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33626
+ }
33627
+ }
33637
33628
  return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
33638
33629
  }
33639
33630
  function parseFunctionExpression() {
@@ -33707,7 +33698,12 @@ var ts;
33707
33698
  if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
33708
33699
  var multiLine = scanner.hasPrecedingLineBreak();
33709
33700
  var statements = parseList(1 /* BlockStatements */, parseStatement);
33710
- parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBracePosition);
33701
+ if (!parseExpected(19 /* CloseBraceToken */)) {
33702
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
33703
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
33704
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
33705
+ }
33706
+ }
33711
33707
  var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
33712
33708
  if (token() === 62 /* EqualsToken */) {
33713
33709
  parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
@@ -33752,10 +33748,9 @@ var ts;
33752
33748
  var pos = getNodePos();
33753
33749
  var hasJSDoc = hasPrecedingJSDocComment();
33754
33750
  parseExpected(98 /* IfKeyword */);
33755
- var openParenPosition = scanner.getTokenPos();
33756
33751
  parseExpected(20 /* OpenParenToken */);
33757
33752
  var expression = allowInAnd(parseExpression);
33758
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33753
+ parseExpected(21 /* CloseParenToken */);
33759
33754
  var thenStatement = parseStatement();
33760
33755
  var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined;
33761
33756
  return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
@@ -33766,10 +33761,9 @@ var ts;
33766
33761
  parseExpected(89 /* DoKeyword */);
33767
33762
  var statement = parseStatement();
33768
33763
  parseExpected(114 /* WhileKeyword */);
33769
- var openParenPosition = scanner.getTokenPos();
33770
33764
  parseExpected(20 /* OpenParenToken */);
33771
33765
  var expression = allowInAnd(parseExpression);
33772
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33766
+ parseExpected(21 /* CloseParenToken */);
33773
33767
  // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
33774
33768
  // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
33775
33769
  // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
@@ -33781,10 +33775,9 @@ var ts;
33781
33775
  var pos = getNodePos();
33782
33776
  var hasJSDoc = hasPrecedingJSDocComment();
33783
33777
  parseExpected(114 /* WhileKeyword */);
33784
- var openParenPosition = scanner.getTokenPos();
33785
33778
  parseExpected(20 /* OpenParenToken */);
33786
33779
  var expression = allowInAnd(parseExpression);
33787
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33780
+ parseExpected(21 /* CloseParenToken */);
33788
33781
  var statement = parseStatement();
33789
33782
  return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
33790
33783
  }
@@ -33851,10 +33844,9 @@ var ts;
33851
33844
  var pos = getNodePos();
33852
33845
  var hasJSDoc = hasPrecedingJSDocComment();
33853
33846
  parseExpected(115 /* WithKeyword */);
33854
- var openParenPosition = scanner.getTokenPos();
33855
33847
  parseExpected(20 /* OpenParenToken */);
33856
33848
  var expression = allowInAnd(parseExpression);
33857
- parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenPosition);
33849
+ parseExpected(21 /* CloseParenToken */);
33858
33850
  var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
33859
33851
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
33860
33852
  }
@@ -35845,7 +35837,8 @@ var ts;
35845
35837
  hasChildren = true;
35846
35838
  if (child.kind === 333 /* JSDocTypeTag */) {
35847
35839
  if (childTypeTag) {
35848
- var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
35840
+ parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
35841
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
35849
35842
  if (lastError) {
35850
35843
  ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
35851
35844
  }
@@ -56006,6 +55999,10 @@ var ts;
56006
55999
  var indexSymbol = symbol && getIndexSymbol(symbol);
56007
56000
  return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56008
56001
  }
56002
+ function getIndexDeclarationOfSymbolTable(symbolTable, kind) {
56003
+ var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable);
56004
+ return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56005
+ }
56009
56006
  function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) {
56010
56007
  var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */;
56011
56008
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
@@ -63214,14 +63211,17 @@ var ts;
63214
63211
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]);
63215
63212
  }
63216
63213
  function getGlobalNonNullableTypeInstantiation(type) {
63214
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
63215
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
63216
+ // that isn't eliminated by a NonNullable<T> instantiation.
63217
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
63217
63218
  if (!deferredGlobalNonNullableTypeAlias) {
63218
63219
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
63219
63220
  }
63220
- // Use NonNullable global type alias if available to improve quick info/declaration emit
63221
- if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
63222
- return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
63223
- }
63224
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior
63221
+ // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
63222
+ return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
63223
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
63224
+ reducedType;
63225
63225
  }
63226
63226
  function getNonNullableType(type) {
63227
63227
  return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
@@ -66809,7 +66809,7 @@ var ts;
66809
66809
  !isGenericIndexType(getTypeOfExpression(parent.argumentExpression));
66810
66810
  }
66811
66811
  function isGenericTypeWithUnionConstraint(type) {
66812
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & 1048576 /* Union */);
66812
+ return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
66813
66813
  }
66814
66814
  function containsGenericType(type) {
66815
66815
  return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType));
@@ -78283,21 +78283,24 @@ var ts;
78283
78283
  checkBlock(node.finallyBlock);
78284
78284
  }
78285
78285
  }
78286
- function checkIndexConstraints(type) {
78287
- var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */);
78288
- var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */);
78286
+ function checkIndexConstraints(type, isStatic) {
78287
+ var _a, _b, _c, _d;
78288
+ var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */);
78289
+ var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */);
78289
78290
  var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
78290
78291
  var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
78291
78292
  if (stringIndexType || numberIndexType) {
78292
78293
  ts.forEach(getPropertiesOfObjectType(type), function (prop) {
78294
+ if (isStatic && prop.flags & 4194304 /* Prototype */)
78295
+ return;
78293
78296
  var propType = getTypeOfSymbol(prop);
78294
78297
  checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */);
78295
78298
  checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */);
78296
78299
  });
78297
78300
  var classDeclaration = type.symbol.valueDeclaration;
78298
78301
  if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) {
78299
- for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
78300
- var member = _a[_i];
78302
+ for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) {
78303
+ var member = _e[_i];
78301
78304
  // Only process instance properties with computed names here.
78302
78305
  // Static properties cannot be in conflict with indexers,
78303
78306
  // and properties with literal names were already checked.
@@ -78627,7 +78630,7 @@ var ts;
78627
78630
  }
78628
78631
  if (produceDiagnostics) {
78629
78632
  checkIndexConstraints(type);
78630
- checkIndexConstraints(staticType);
78633
+ checkIndexConstraints(staticType, /*isStatic*/ true);
78631
78634
  checkTypeForDuplicateIndexSignatures(node);
78632
78635
  checkPropertyInitialization(node);
78633
78636
  }
@@ -88686,10 +88689,11 @@ var ts;
88686
88689
  return ts.visitEachChild(node, visitor, context);
88687
88690
  }
88688
88691
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true);
88692
+ var pendingPrivateStateAssignment;
88689
88693
  if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) {
88690
88694
  var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true);
88691
88695
  getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp);
88692
- getPendingExpressions().push(factory.createAssignment(temp, factory.getInternalName(node)));
88696
+ pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node));
88693
88697
  }
88694
88698
  var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
88695
88699
  var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */);
@@ -88698,6 +88702,9 @@ var ts;
88698
88702
  /*decorators*/ undefined, node.modifiers, node.name,
88699
88703
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
88700
88704
  ];
88705
+ if (pendingPrivateStateAssignment) {
88706
+ getPendingExpressions().unshift(pendingPrivateStateAssignment);
88707
+ }
88701
88708
  // Write any pending expressions from elided or moved computed property names
88702
88709
  if (ts.some(pendingExpressions)) {
88703
88710
  statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.3.1-rc",
5
+ "version": "4.3.2",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [