typescript 4.7.0-dev.20220402 → 4.7.0-dev.20220405

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220402";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220405";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -16991,7 +16991,11 @@ var ts;
16991
16991
  ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
16992
16992
  function getHostSignatureFromJSDoc(node) {
16993
16993
  var host = getEffectiveJSDocHost(node);
16994
- return host && ts.isFunctionLike(host) ? host : undefined;
16994
+ if (host) {
16995
+ return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
16996
+ ts.isFunctionLike(host) ? host : undefined;
16997
+ }
16998
+ return undefined;
16995
16999
  }
16996
17000
  ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
16997
17001
  function getEffectiveJSDocHost(node) {
@@ -32757,7 +32761,6 @@ var ts;
32757
32761
  default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
32758
32762
  }
32759
32763
  }
32760
- // Parses a comma-delimited list of elements
32761
32764
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
32762
32765
  var saveParsingContext = parsingContext;
32763
32766
  parsingContext |= 1 << kind;
@@ -32767,7 +32770,11 @@ var ts;
32767
32770
  while (true) {
32768
32771
  if (isListElement(kind, /*inErrorRecovery*/ false)) {
32769
32772
  var startPos = scanner.getStartPos();
32770
- list.push(parseListElement(kind, parseElement));
32773
+ var result = parseListElement(kind, parseElement);
32774
+ if (!result) {
32775
+ return undefined;
32776
+ }
32777
+ list.push(result);
32771
32778
  commaStart = scanner.getTokenPos();
32772
32779
  if (parseOptional(27 /* CommaToken */)) {
32773
32780
  // No need to check for a zero length node since we know we parsed a comma
@@ -33172,13 +33179,20 @@ var ts;
33172
33179
  }
33173
33180
  return name;
33174
33181
  }
33175
- function parseParameterInOuterAwaitContext() {
33176
- return parseParameterWorker(/*inOuterAwaitContext*/ true);
33182
+ function isParameterNameStart() {
33183
+ // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
33184
+ // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
33185
+ // complaining about the use of the keywords.
33186
+ return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */;
33177
33187
  }
33178
- function parseParameter() {
33179
- return parseParameterWorker(/*inOuterAwaitContext*/ false);
33188
+ function parseParameter(inOuterAwaitContext) {
33189
+ return parseParameterWorker(inOuterAwaitContext);
33180
33190
  }
33181
- function parseParameterWorker(inOuterAwaitContext) {
33191
+ function parseParameterForSpeculation(inOuterAwaitContext) {
33192
+ return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
33193
+ }
33194
+ function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
33195
+ if (allowAmbiguity === void 0) { allowAmbiguity = true; }
33182
33196
  var pos = getNodePos();
33183
33197
  var hasJSDoc = hasPrecedingJSDocComment();
33184
33198
  // FormalParameter [Yield,Await]:
@@ -33199,7 +33213,11 @@ var ts;
33199
33213
  var savedTopLevel = topLevel;
33200
33214
  topLevel = false;
33201
33215
  var modifiers = parseModifiers();
33202
- var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33216
+ var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
33217
+ if (!allowAmbiguity && !isParameterNameStart()) {
33218
+ return undefined;
33219
+ }
33220
+ var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33203
33221
  topLevel = savedTopLevel;
33204
33222
  return node;
33205
33223
  }
@@ -33224,7 +33242,7 @@ var ts;
33224
33242
  }
33225
33243
  return false;
33226
33244
  }
33227
- function parseParametersWorker(flags) {
33245
+ function parseParametersWorker(flags, allowAmbiguity) {
33228
33246
  // FormalParameters [Yield,Await]: (modified)
33229
33247
  // [empty]
33230
33248
  // FormalParameterList[?Yield,Await]
@@ -33244,7 +33262,7 @@ var ts;
33244
33262
  setAwaitContext(!!(flags & 2 /* Await */));
33245
33263
  var parameters = flags & 32 /* JSDoc */ ?
33246
33264
  parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
33247
- parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
33265
+ parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
33248
33266
  setYieldContext(savedYieldContext);
33249
33267
  setAwaitContext(savedAwaitContext);
33250
33268
  return parameters;
@@ -33266,7 +33284,7 @@ var ts;
33266
33284
  if (!parseExpected(20 /* OpenParenToken */)) {
33267
33285
  return createMissingList();
33268
33286
  }
33269
- var parameters = parseParametersWorker(flags);
33287
+ var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
33270
33288
  parseExpected(21 /* CloseParenToken */);
33271
33289
  return parameters;
33272
33290
  }
@@ -33348,7 +33366,7 @@ var ts;
33348
33366
  return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
33349
33367
  }
33350
33368
  function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
33351
- var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33369
+ var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33352
33370
  var type = parseTypeAnnotation();
33353
33371
  parseTypeMemberSemicolon();
33354
33372
  var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
@@ -34398,7 +34416,16 @@ var ts;
34398
34416
  parameters = createMissingList();
34399
34417
  }
34400
34418
  else {
34401
- parameters = parseParametersWorker(isAsync);
34419
+ if (!allowAmbiguity) {
34420
+ var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
34421
+ if (!maybeParameters) {
34422
+ return undefined;
34423
+ }
34424
+ parameters = maybeParameters;
34425
+ }
34426
+ else {
34427
+ parameters = parseParametersWorker(isAsync, allowAmbiguity);
34428
+ }
34402
34429
  if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
34403
34430
  return undefined;
34404
34431
  }
@@ -61958,7 +61985,11 @@ var ts;
61958
61985
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61959
61986
  }
61960
61987
  function isSingletonTupleType(node) {
61961
- return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]);
61988
+ return ts.isTupleTypeNode(node) &&
61989
+ ts.length(node.elements) === 1 &&
61990
+ !ts.isOptionalTypeNode(node.elements[0]) &&
61991
+ !ts.isRestTypeNode(node.elements[0]) &&
61992
+ !(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
61962
61993
  }
61963
61994
  /**
61964
61995
  * We syntactually check for common nondistributive conditional shapes and unwrap them into
@@ -66478,6 +66509,9 @@ var ts;
66478
66509
  function createMarkerType(symbol, source, target) {
66479
66510
  var mapper = makeUnaryTypeMapper(source, target);
66480
66511
  var type = getDeclaredTypeOfSymbol(symbol);
66512
+ if (isErrorType(type)) {
66513
+ return type;
66514
+ }
66481
66515
  var result = symbol.flags & 524288 /* TypeAlias */ ?
66482
66516
  getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) :
66483
66517
  createTypeReference(type, instantiateTypes(type.typeParameters, mapper));
@@ -117873,21 +117907,6 @@ var ts;
117873
117907
  return resolvedRef;
117874
117908
  }
117875
117909
  function verifyCompilerOptions() {
117876
- var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
117877
- if (!isNightly) {
117878
- if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
117879
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
117880
- }
117881
- else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
117882
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
117883
- }
117884
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
117885
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
117886
- }
117887
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
117888
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
117889
- }
117890
- }
117891
117910
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
117892
117911
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
117893
117912
  }
@@ -142895,10 +142914,13 @@ var ts;
142895
142914
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
142896
142915
  // for optional function condition.
142897
142916
  var nonNullableContextualType = contextualType.getNonNullableType();
142898
- var signatures = nonNullableContextualType.getCallSignatures();
142899
- if (signatures.length !== 1)
142917
+ var symbol = nonNullableContextualType.symbol;
142918
+ if (symbol === undefined)
142919
+ return undefined;
142920
+ var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures());
142921
+ if (signature === undefined)
142900
142922
  return undefined;
142901
- var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
142923
+ var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
142902
142924
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
142903
142925
  }
142904
142926
  function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
@@ -147068,9 +147090,9 @@ var ts;
147068
147090
  // for block indentation, we should look for a line which contains something that's not
147069
147091
  // whitespace.
147070
147092
  var currentToken = ts.getTokenAtPosition(sourceFile, position);
147071
- // for object literal, we want to the indentation work like block
147072
- // if { starts in any position (can be in the middle of line)
147073
- // the following indentation should treat { as starting of that line (including leading whitespace)
147093
+ // For object literals, we want indentation to work just like with blocks.
147094
+ // If the `{` starts in any position (even in the middle of a line), then
147095
+ // the following indentation should treat `{` as the start of that line (including leading whitespace).
147074
147096
  // ```
147075
147097
  // const a: { x: undefined, y: undefined } = {} // leading 4 whitespaces and { starts in the middle of line
147076
147098
  // ->
@@ -147088,7 +147110,8 @@ var ts;
147088
147110
  // y: undefined,
147089
147111
  // }
147090
147112
  // ```
147091
- if (options.indentStyle === ts.IndentStyle.Block || currentToken.kind === 18 /* OpenBraceToken */) {
147113
+ var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */;
147114
+ if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
147092
147115
  return getBlockIndent(sourceFile, position, options);
147093
147116
  }
147094
147117
  if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) {
@@ -147101,7 +147124,9 @@ var ts;
147101
147124
  var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
147102
147125
  // use list position if the preceding token is before any list items
147103
147126
  if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
147104
- return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize; // TODO: GH#18217
147127
+ var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
147128
+ var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
147129
+ return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
147105
147130
  }
147106
147131
  return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
147107
147132
  }
@@ -153667,7 +153692,7 @@ var ts;
153667
153692
  var param = signature.parameters[argIndex].valueDeclaration;
153668
153693
  if (!(param && ts.isParameter(param) && ts.isIdentifier(param.name)))
153669
153694
  return undefined;
153670
- var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
153695
+ var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
153671
153696
  if (!ts.length(properties))
153672
153697
  return undefined;
153673
153698
  return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
@@ -156675,7 +156700,11 @@ var ts;
156675
156700
  var program = context.program;
156676
156701
  var checker = program.getTypeChecker();
156677
156702
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
156678
- var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0);
156703
+ var flags = 1 /* NoTruncation */
156704
+ | 1073741824 /* NoUndefinedOptionalParameterType */
156705
+ | 256 /* SuppressAnyReturnType */
156706
+ | 524288 /* AllowEmptyTuple */
156707
+ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
156679
156708
  var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
156680
156709
  if (!signatureDeclaration) {
156681
156710
  return undefined;
@@ -159409,7 +159438,8 @@ var ts;
159409
159438
  return undefined;
159410
159439
  }
159411
159440
  function isScope(node) {
159412
- return ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
159441
+ return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
159442
+ ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
159413
159443
  }
159414
159444
  /**
159415
159445
  * Computes possible places we could extract the function into. For example,
@@ -1983,7 +1983,7 @@ declare namespace ts {
1983
1983
  Label = 12,
1984
1984
  Condition = 96
1985
1985
  }
1986
- export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
1986
+ export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
1987
1987
  export interface FlowNodeBase {
1988
1988
  flags: FlowFlags;
1989
1989
  id?: number;
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220402";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220405";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -16991,7 +16991,11 @@ var ts;
16991
16991
  ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
16992
16992
  function getHostSignatureFromJSDoc(node) {
16993
16993
  var host = getEffectiveJSDocHost(node);
16994
- return host && ts.isFunctionLike(host) ? host : undefined;
16994
+ if (host) {
16995
+ return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
16996
+ ts.isFunctionLike(host) ? host : undefined;
16997
+ }
16998
+ return undefined;
16995
16999
  }
16996
17000
  ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
16997
17001
  function getEffectiveJSDocHost(node) {
@@ -32757,7 +32761,6 @@ var ts;
32757
32761
  default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
32758
32762
  }
32759
32763
  }
32760
- // Parses a comma-delimited list of elements
32761
32764
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
32762
32765
  var saveParsingContext = parsingContext;
32763
32766
  parsingContext |= 1 << kind;
@@ -32767,7 +32770,11 @@ var ts;
32767
32770
  while (true) {
32768
32771
  if (isListElement(kind, /*inErrorRecovery*/ false)) {
32769
32772
  var startPos = scanner.getStartPos();
32770
- list.push(parseListElement(kind, parseElement));
32773
+ var result = parseListElement(kind, parseElement);
32774
+ if (!result) {
32775
+ return undefined;
32776
+ }
32777
+ list.push(result);
32771
32778
  commaStart = scanner.getTokenPos();
32772
32779
  if (parseOptional(27 /* CommaToken */)) {
32773
32780
  // No need to check for a zero length node since we know we parsed a comma
@@ -33172,13 +33179,20 @@ var ts;
33172
33179
  }
33173
33180
  return name;
33174
33181
  }
33175
- function parseParameterInOuterAwaitContext() {
33176
- return parseParameterWorker(/*inOuterAwaitContext*/ true);
33182
+ function isParameterNameStart() {
33183
+ // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
33184
+ // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
33185
+ // complaining about the use of the keywords.
33186
+ return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */;
33177
33187
  }
33178
- function parseParameter() {
33179
- return parseParameterWorker(/*inOuterAwaitContext*/ false);
33188
+ function parseParameter(inOuterAwaitContext) {
33189
+ return parseParameterWorker(inOuterAwaitContext);
33180
33190
  }
33181
- function parseParameterWorker(inOuterAwaitContext) {
33191
+ function parseParameterForSpeculation(inOuterAwaitContext) {
33192
+ return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
33193
+ }
33194
+ function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
33195
+ if (allowAmbiguity === void 0) { allowAmbiguity = true; }
33182
33196
  var pos = getNodePos();
33183
33197
  var hasJSDoc = hasPrecedingJSDocComment();
33184
33198
  // FormalParameter [Yield,Await]:
@@ -33199,7 +33213,11 @@ var ts;
33199
33213
  var savedTopLevel = topLevel;
33200
33214
  topLevel = false;
33201
33215
  var modifiers = parseModifiers();
33202
- var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33216
+ var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
33217
+ if (!allowAmbiguity && !isParameterNameStart()) {
33218
+ return undefined;
33219
+ }
33220
+ var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33203
33221
  topLevel = savedTopLevel;
33204
33222
  return node;
33205
33223
  }
@@ -33224,7 +33242,7 @@ var ts;
33224
33242
  }
33225
33243
  return false;
33226
33244
  }
33227
- function parseParametersWorker(flags) {
33245
+ function parseParametersWorker(flags, allowAmbiguity) {
33228
33246
  // FormalParameters [Yield,Await]: (modified)
33229
33247
  // [empty]
33230
33248
  // FormalParameterList[?Yield,Await]
@@ -33244,7 +33262,7 @@ var ts;
33244
33262
  setAwaitContext(!!(flags & 2 /* Await */));
33245
33263
  var parameters = flags & 32 /* JSDoc */ ?
33246
33264
  parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
33247
- parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
33265
+ parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
33248
33266
  setYieldContext(savedYieldContext);
33249
33267
  setAwaitContext(savedAwaitContext);
33250
33268
  return parameters;
@@ -33266,7 +33284,7 @@ var ts;
33266
33284
  if (!parseExpected(20 /* OpenParenToken */)) {
33267
33285
  return createMissingList();
33268
33286
  }
33269
- var parameters = parseParametersWorker(flags);
33287
+ var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
33270
33288
  parseExpected(21 /* CloseParenToken */);
33271
33289
  return parameters;
33272
33290
  }
@@ -33348,7 +33366,7 @@ var ts;
33348
33366
  return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
33349
33367
  }
33350
33368
  function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
33351
- var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33369
+ var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33352
33370
  var type = parseTypeAnnotation();
33353
33371
  parseTypeMemberSemicolon();
33354
33372
  var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
@@ -34398,7 +34416,16 @@ var ts;
34398
34416
  parameters = createMissingList();
34399
34417
  }
34400
34418
  else {
34401
- parameters = parseParametersWorker(isAsync);
34419
+ if (!allowAmbiguity) {
34420
+ var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
34421
+ if (!maybeParameters) {
34422
+ return undefined;
34423
+ }
34424
+ parameters = maybeParameters;
34425
+ }
34426
+ else {
34427
+ parameters = parseParametersWorker(isAsync, allowAmbiguity);
34428
+ }
34402
34429
  if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
34403
34430
  return undefined;
34404
34431
  }
@@ -61958,7 +61985,11 @@ var ts;
61958
61985
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61959
61986
  }
61960
61987
  function isSingletonTupleType(node) {
61961
- return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]);
61988
+ return ts.isTupleTypeNode(node) &&
61989
+ ts.length(node.elements) === 1 &&
61990
+ !ts.isOptionalTypeNode(node.elements[0]) &&
61991
+ !ts.isRestTypeNode(node.elements[0]) &&
61992
+ !(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
61962
61993
  }
61963
61994
  /**
61964
61995
  * We syntactually check for common nondistributive conditional shapes and unwrap them into
@@ -66478,6 +66509,9 @@ var ts;
66478
66509
  function createMarkerType(symbol, source, target) {
66479
66510
  var mapper = makeUnaryTypeMapper(source, target);
66480
66511
  var type = getDeclaredTypeOfSymbol(symbol);
66512
+ if (isErrorType(type)) {
66513
+ return type;
66514
+ }
66481
66515
  var result = symbol.flags & 524288 /* TypeAlias */ ?
66482
66516
  getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) :
66483
66517
  createTypeReference(type, instantiateTypes(type.typeParameters, mapper));
@@ -117873,21 +117907,6 @@ var ts;
117873
117907
  return resolvedRef;
117874
117908
  }
117875
117909
  function verifyCompilerOptions() {
117876
- var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
117877
- if (!isNightly) {
117878
- if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
117879
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
117880
- }
117881
- else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
117882
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
117883
- }
117884
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
117885
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
117886
- }
117887
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
117888
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
117889
- }
117890
- }
117891
117910
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
117892
117911
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
117893
117912
  }
@@ -142895,10 +142914,13 @@ var ts;
142895
142914
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
142896
142915
  // for optional function condition.
142897
142916
  var nonNullableContextualType = contextualType.getNonNullableType();
142898
- var signatures = nonNullableContextualType.getCallSignatures();
142899
- if (signatures.length !== 1)
142917
+ var symbol = nonNullableContextualType.symbol;
142918
+ if (symbol === undefined)
142919
+ return undefined;
142920
+ var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures());
142921
+ if (signature === undefined)
142900
142922
  return undefined;
142901
- var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
142923
+ var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
142902
142924
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
142903
142925
  }
142904
142926
  function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
@@ -147068,9 +147090,9 @@ var ts;
147068
147090
  // for block indentation, we should look for a line which contains something that's not
147069
147091
  // whitespace.
147070
147092
  var currentToken = ts.getTokenAtPosition(sourceFile, position);
147071
- // for object literal, we want to the indentation work like block
147072
- // if { starts in any position (can be in the middle of line)
147073
- // the following indentation should treat { as starting of that line (including leading whitespace)
147093
+ // For object literals, we want indentation to work just like with blocks.
147094
+ // If the `{` starts in any position (even in the middle of a line), then
147095
+ // the following indentation should treat `{` as the start of that line (including leading whitespace).
147074
147096
  // ```
147075
147097
  // const a: { x: undefined, y: undefined } = {} // leading 4 whitespaces and { starts in the middle of line
147076
147098
  // ->
@@ -147088,7 +147110,8 @@ var ts;
147088
147110
  // y: undefined,
147089
147111
  // }
147090
147112
  // ```
147091
- if (options.indentStyle === ts.IndentStyle.Block || currentToken.kind === 18 /* OpenBraceToken */) {
147113
+ var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */;
147114
+ if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
147092
147115
  return getBlockIndent(sourceFile, position, options);
147093
147116
  }
147094
147117
  if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) {
@@ -147101,7 +147124,9 @@ var ts;
147101
147124
  var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
147102
147125
  // use list position if the preceding token is before any list items
147103
147126
  if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
147104
- return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize; // TODO: GH#18217
147127
+ var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
147128
+ var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
147129
+ return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
147105
147130
  }
147106
147131
  return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
147107
147132
  }
@@ -153667,7 +153692,7 @@ var ts;
153667
153692
  var param = signature.parameters[argIndex].valueDeclaration;
153668
153693
  if (!(param && ts.isParameter(param) && ts.isIdentifier(param.name)))
153669
153694
  return undefined;
153670
- var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
153695
+ var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
153671
153696
  if (!ts.length(properties))
153672
153697
  return undefined;
153673
153698
  return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
@@ -156675,7 +156700,11 @@ var ts;
156675
156700
  var program = context.program;
156676
156701
  var checker = program.getTypeChecker();
156677
156702
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
156678
- var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0);
156703
+ var flags = 1 /* NoTruncation */
156704
+ | 1073741824 /* NoUndefinedOptionalParameterType */
156705
+ | 256 /* SuppressAnyReturnType */
156706
+ | 524288 /* AllowEmptyTuple */
156707
+ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
156679
156708
  var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
156680
156709
  if (!signatureDeclaration) {
156681
156710
  return undefined;
@@ -159409,7 +159438,8 @@ var ts;
159409
159438
  return undefined;
159410
159439
  }
159411
159440
  function isScope(node) {
159412
- return ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
159441
+ return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
159442
+ ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
159413
159443
  }
159414
159444
  /**
159415
159445
  * Computes possible places we could extract the function into. For example,
@@ -1983,7 +1983,7 @@ declare namespace ts {
1983
1983
  Label = 12,
1984
1984
  Condition = 96
1985
1985
  }
1986
- export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
1986
+ export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
1987
1987
  export interface FlowNodeBase {
1988
1988
  flags: FlowFlags;
1989
1989
  id?: number;