typescript 4.6.0-dev.20211117 → 4.6.0-dev.20211121

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.20211117";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211121";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -356,26 +356,6 @@ var ts;
356
356
  ts.emptyArray = [];
357
357
  ts.emptyMap = new ts.Map();
358
358
  ts.emptySet = new ts.Set();
359
- function createMap() {
360
- return new ts.Map();
361
- }
362
- ts.createMap = createMap;
363
- /**
364
- * Create a new map from a template object is provided, the map will copy entries from it.
365
- * @deprecated Use `new Map(getEntries(template))` instead.
366
- */
367
- function createMapFromTemplate(template) {
368
- var map = new ts.Map();
369
- // Copies keys/values from template. Note that for..in will not throw if
370
- // template is undefined, and instead will just exit the loop.
371
- for (var key in template) {
372
- if (hasOwnProperty.call(template, key)) {
373
- map.set(key, template[key]);
374
- }
375
- }
376
- return map;
377
- }
378
- ts.createMapFromTemplate = createMapFromTemplate;
379
359
  function length(array) {
380
360
  return array ? array.length : 0;
381
361
  }
@@ -2610,11 +2590,6 @@ var ts;
2610
2590
  return value;
2611
2591
  }
2612
2592
  Debug.checkDefined = checkDefined;
2613
- /**
2614
- * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
2615
- * a value is defined at the statement level.
2616
- */
2617
- Debug.assertDefined = checkDefined;
2618
2593
  function assertEachIsDefined(value, message, stackCrawlMark) {
2619
2594
  for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
2620
2595
  var v = value_1[_i];
@@ -2627,11 +2602,6 @@ var ts;
2627
2602
  return value;
2628
2603
  }
2629
2604
  Debug.checkEachDefined = checkEachDefined;
2630
- /**
2631
- * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
2632
- * the elements of an array are defined at the statement level.
2633
- */
2634
- Debug.assertEachDefined = checkEachDefined;
2635
2605
  function assertNever(member, message, stackCrawlMark) {
2636
2606
  if (message === void 0) { message = "Illegal value:"; }
2637
2607
  var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
@@ -14091,21 +14061,6 @@ var ts;
14091
14061
  return undefined;
14092
14062
  }
14093
14063
  ts.getDeclarationOfKind = getDeclarationOfKind;
14094
- /**
14095
- * Create a new escaped identifier map.
14096
- * @deprecated Use `new Map<__String, T>()` instead.
14097
- */
14098
- function createUnderscoreEscapedMap() {
14099
- return new ts.Map();
14100
- }
14101
- ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
14102
- /**
14103
- * @deprecated Use `!!map?.size` instead
14104
- */
14105
- function hasEntries(map) {
14106
- return !!map && !!map.size;
14107
- }
14108
- ts.hasEntries = hasEntries;
14109
14064
  function createSymbolTable(symbols) {
14110
14065
  var result = new ts.Map();
14111
14066
  if (symbols) {
@@ -26698,7 +26653,7 @@ var ts;
26698
26653
  sourceMapText = mapTextOrStripInternal;
26699
26654
  }
26700
26655
  var node = oldFileOfCurrentEmit ?
26701
- parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
26656
+ parseOldFileOfCurrentEmit(ts.Debug.checkDefined(bundleFileInfo)) :
26702
26657
  parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
26703
26658
  node.fileName = fileName;
26704
26659
  node.sourceMapPath = sourceMapPath;
@@ -26845,13 +26800,13 @@ var ts;
26845
26800
  };
26846
26801
  node.javascriptPath = declarationTextOrJavascriptPath;
26847
26802
  node.javascriptMapPath = javascriptMapPath;
26848
- node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
26803
+ node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
26849
26804
  node.declarationMapPath = declarationMapPath;
26850
26805
  node.buildInfoPath = declarationMapTextOrBuildInfoPath;
26851
26806
  Object.defineProperties(node, {
26852
26807
  javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
26853
26808
  javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
26854
- declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
26809
+ declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
26855
26810
  declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
26856
26811
  buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
26857
26812
  });
@@ -51860,8 +51815,8 @@ var ts;
51860
51815
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
51861
51816
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
51862
51817
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 170 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
51863
- if (signature.thisParameter) {
51864
- var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
51818
+ var thisParameter = tryGetThisParameterDeclaration(signature, context);
51819
+ if (thisParameter) {
51865
51820
  parameters.unshift(thisParameter);
51866
51821
  }
51867
51822
  var returnTypeNode;
@@ -51910,6 +51865,21 @@ var ts;
51910
51865
  }
51911
51866
  return node;
51912
51867
  }
51868
+ function tryGetThisParameterDeclaration(signature, context) {
51869
+ if (signature.thisParameter) {
51870
+ return symbolToParameterDeclaration(signature.thisParameter, context);
51871
+ }
51872
+ if (signature.declaration) {
51873
+ var thisTag = ts.getJSDocThisTag(signature.declaration);
51874
+ if (thisTag && thisTag.typeExpression) {
51875
+ return ts.factory.createParameterDeclaration(
51876
+ /* decorators */ undefined,
51877
+ /* modifiers */ undefined,
51878
+ /* dotDotDotToken */ undefined, "this",
51879
+ /* questionToken */ undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context));
51880
+ }
51881
+ }
51882
+ }
51913
51883
  function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
51914
51884
  var savedContextFlags = context.flags;
51915
51885
  context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
@@ -52351,10 +52321,8 @@ var ts;
52351
52321
  firstChar = symbolName.charCodeAt(0);
52352
52322
  }
52353
52323
  var expression = void 0;
52354
- if (ts.isSingleOrDoubleQuote(firstChar)) {
52355
- expression = ts.factory.createStringLiteral(symbolName
52356
- .substring(1, symbolName.length - 1)
52357
- .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52324
+ if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) {
52325
+ expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52358
52326
  }
52359
52327
  else if (("" + +symbolName) === symbolName) {
52360
52328
  expression = ts.factory.createNumericLiteral(+symbolName);
@@ -94347,7 +94315,7 @@ var ts;
94347
94315
  function visitYieldExpression(node) {
94348
94316
  if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
94349
94317
  if (node.asteriskToken) {
94350
- var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
94318
+ var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression);
94351
94319
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
94352
94320
  /*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(factory.updateYieldExpression(node, node.asteriskToken, ts.setTextRange(emitHelpers().createAsyncDelegatorHelper(ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), expression)), expression)))), node), node);
94353
94321
  }
@@ -95272,11 +95240,11 @@ var ts;
95272
95240
  return existing.name;
95273
95241
  }
95274
95242
  if (!currentFileState.utilizedImplicitRuntimeImports) {
95275
- currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
95243
+ currentFileState.utilizedImplicitRuntimeImports = new ts.Map();
95276
95244
  }
95277
95245
  var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
95278
95246
  if (!specifierSourceImports) {
95279
- specifierSourceImports = ts.createMap();
95247
+ specifierSourceImports = new ts.Map();
95280
95248
  currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
95281
95249
  }
95282
95250
  var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
@@ -113803,6 +113771,24 @@ var ts;
113803
113771
  }
113804
113772
  }
113805
113773
  ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
113774
+ /** @internal */
113775
+ ts.plainJSErrors = new ts.Set([
113776
+ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
113777
+ ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code,
113778
+ ts.Diagnostics.Another_export_default_is_here.code,
113779
+ ts.Diagnostics.The_first_export_default_is_here.code,
113780
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
113781
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
113782
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
113783
+ ts.Diagnostics.constructor_is_a_reserved_word.code,
113784
+ ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
113785
+ ts.Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
113786
+ ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
113787
+ ts.Diagnostics.Invalid_use_of_0_in_strict_mode.code,
113788
+ ts.Diagnostics.A_label_is_not_allowed_here.code,
113789
+ ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
113790
+ ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
113791
+ ]);
113806
113792
  /**
113807
113793
  * Determine if source file needs to be re-created even if its text hasn't changed
113808
113794
  */
@@ -114463,6 +114449,7 @@ var ts;
114463
114449
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
114464
114450
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
114465
114451
  newSourceFile.fileName = oldSourceFile.fileName;
114452
+ newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
114466
114453
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
114467
114454
  if (packageName !== undefined) {
114468
114455
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -114819,14 +114806,23 @@ var ts;
114819
114806
  }
114820
114807
  var typeChecker = getDiagnosticsProducingTypeChecker();
114821
114808
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
114822
- var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
114809
+ var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
114810
+ var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
114811
+ var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
114823
114812
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
114824
- // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
114813
+ // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
114814
+ // - plain JS: .js files with no // ts-check and checkJs: undefined
114815
+ // - check JS: .js files with either // ts-check or checkJs: true
114816
+ // - external: files that are added by plugins
114825
114817
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */
114826
- || sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114818
+ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114827
114819
  var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
114828
- var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114829
- return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114820
+ var checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114821
+ if (isPlainJs) {
114822
+ bindDiagnostics = ts.filter(bindDiagnostics, function (d) { return ts.plainJSErrors.has(d.code); });
114823
+ }
114824
+ // skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
114825
+ return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114830
114826
  });
114831
114827
  }
114832
114828
  function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
@@ -118735,7 +118731,7 @@ var ts;
118735
118731
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118736
118732
  if (resolution.refCount) {
118737
118733
  resolution.refCount++;
118738
- ts.Debug.assertDefined(resolution.files);
118734
+ ts.Debug.assertIsDefined(resolution.files);
118739
118735
  }
118740
118736
  else {
118741
118737
  resolution.refCount = 1;
@@ -118803,7 +118799,7 @@ var ts;
118803
118799
  }
118804
118800
  }
118805
118801
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
118806
- ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
118802
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
118807
118803
  resolution.refCount--;
118808
118804
  if (resolution.refCount) {
118809
118805
  return;
@@ -118895,7 +118891,7 @@ var ts;
118895
118891
  if (resolution.isInvalidated || !canInvalidate(resolution))
118896
118892
  continue;
118897
118893
  resolution.isInvalidated = invalidated = true;
118898
- for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
118894
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
118899
118895
  var containingFilePath = _b[_a];
118900
118896
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
118901
118897
  // When its a file with inferred types resolution, invalidate type reference directive resolution
@@ -136171,14 +136167,17 @@ var ts;
136171
136167
  if (node === sourceFile) {
136172
136168
  return undefined;
136173
136169
  }
136174
- var symbol = typeChecker.getSymbolAtLocation(node);
136170
+ var symbol = getSymbol(node, typeChecker);
136175
136171
  if (!symbol)
136176
136172
  return undefined;
136177
136173
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
136178
136174
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
136179
136175
  var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
136180
136176
  // If a function returns 'void' or some other type with no definition, just return the function definition.
136181
- return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136177
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136178
+ return typeDefinitions.length ? typeDefinitions
136179
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
136180
+ : undefined;
136182
136181
  }
136183
136182
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
136184
136183
  function definitionFromType(type, checker, node) {
@@ -150071,9 +150070,9 @@ var ts;
150071
150070
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150072
150071
  return undefined;
150073
150072
  if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
150074
- var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
150073
+ var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
150075
150074
  var name = fn.name;
150076
- var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
150075
+ var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
150077
150076
  if (ts.isFunctionExpression(fn)) {
150078
150077
  if (name && ts.FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
150079
150078
  // Function expression references itself. To fix we would have to extract it to a const.
@@ -172111,7 +172110,7 @@ var ts;
172111
172110
  Session.prototype.getFullNavigateToItems = function (args) {
172112
172111
  var currentFileOnly = args.currentFileOnly, searchValue = args.searchValue, maxResultCount = args.maxResultCount, projectFileName = args.projectFileName;
172113
172112
  if (currentFileOnly) {
172114
- ts.Debug.assertDefined(args.file);
172113
+ ts.Debug.assertIsDefined(args.file);
172115
172114
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
172116
172115
  return [{ project: project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }];
172117
172116
  }
@@ -897,7 +897,7 @@ declare namespace ts {
897
897
  export interface TypePredicateNode extends TypeNode {
898
898
  readonly kind: SyntaxKind.TypePredicate;
899
899
  readonly parent: SignatureDeclaration | JSDocTypeExpression;
900
- readonly assertsModifier?: AssertsToken;
900
+ readonly assertsModifier?: AssertsKeyword;
901
901
  readonly parameterName: Identifier | ThisTypeNode;
902
902
  readonly type?: TypeNode;
903
903
  }
@@ -968,7 +968,7 @@ declare namespace ts {
968
968
  }
969
969
  export interface MappedTypeNode extends TypeNode, Declaration {
970
970
  readonly kind: SyntaxKind.MappedType;
971
- readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
971
+ readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
972
972
  readonly typeParameter: TypeParameterDeclaration;
973
973
  readonly nameType?: TypeNode;
974
974
  readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@@ -1465,7 +1465,7 @@ declare namespace ts {
1465
1465
  }
1466
1466
  export interface ForOfStatement extends IterationStatement {
1467
1467
  readonly kind: SyntaxKind.ForOfStatement;
1468
- readonly awaitModifier?: AwaitKeywordToken;
1468
+ readonly awaitModifier?: AwaitKeyword;
1469
1469
  readonly initializer: ForInitializer;
1470
1470
  readonly expression: Expression;
1471
1471
  }
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.20211117";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211121";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -356,26 +356,6 @@ var ts;
356
356
  ts.emptyArray = [];
357
357
  ts.emptyMap = new ts.Map();
358
358
  ts.emptySet = new ts.Set();
359
- function createMap() {
360
- return new ts.Map();
361
- }
362
- ts.createMap = createMap;
363
- /**
364
- * Create a new map from a template object is provided, the map will copy entries from it.
365
- * @deprecated Use `new Map(getEntries(template))` instead.
366
- */
367
- function createMapFromTemplate(template) {
368
- var map = new ts.Map();
369
- // Copies keys/values from template. Note that for..in will not throw if
370
- // template is undefined, and instead will just exit the loop.
371
- for (var key in template) {
372
- if (hasOwnProperty.call(template, key)) {
373
- map.set(key, template[key]);
374
- }
375
- }
376
- return map;
377
- }
378
- ts.createMapFromTemplate = createMapFromTemplate;
379
359
  function length(array) {
380
360
  return array ? array.length : 0;
381
361
  }
@@ -2610,11 +2590,6 @@ var ts;
2610
2590
  return value;
2611
2591
  }
2612
2592
  Debug.checkDefined = checkDefined;
2613
- /**
2614
- * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
2615
- * a value is defined at the statement level.
2616
- */
2617
- Debug.assertDefined = checkDefined;
2618
2593
  function assertEachIsDefined(value, message, stackCrawlMark) {
2619
2594
  for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
2620
2595
  var v = value_1[_i];
@@ -2627,11 +2602,6 @@ var ts;
2627
2602
  return value;
2628
2603
  }
2629
2604
  Debug.checkEachDefined = checkEachDefined;
2630
- /**
2631
- * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
2632
- * the elements of an array are defined at the statement level.
2633
- */
2634
- Debug.assertEachDefined = checkEachDefined;
2635
2605
  function assertNever(member, message, stackCrawlMark) {
2636
2606
  if (message === void 0) { message = "Illegal value:"; }
2637
2607
  var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
@@ -14091,21 +14061,6 @@ var ts;
14091
14061
  return undefined;
14092
14062
  }
14093
14063
  ts.getDeclarationOfKind = getDeclarationOfKind;
14094
- /**
14095
- * Create a new escaped identifier map.
14096
- * @deprecated Use `new Map<__String, T>()` instead.
14097
- */
14098
- function createUnderscoreEscapedMap() {
14099
- return new ts.Map();
14100
- }
14101
- ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
14102
- /**
14103
- * @deprecated Use `!!map?.size` instead
14104
- */
14105
- function hasEntries(map) {
14106
- return !!map && !!map.size;
14107
- }
14108
- ts.hasEntries = hasEntries;
14109
14064
  function createSymbolTable(symbols) {
14110
14065
  var result = new ts.Map();
14111
14066
  if (symbols) {
@@ -26698,7 +26653,7 @@ var ts;
26698
26653
  sourceMapText = mapTextOrStripInternal;
26699
26654
  }
26700
26655
  var node = oldFileOfCurrentEmit ?
26701
- parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
26656
+ parseOldFileOfCurrentEmit(ts.Debug.checkDefined(bundleFileInfo)) :
26702
26657
  parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
26703
26658
  node.fileName = fileName;
26704
26659
  node.sourceMapPath = sourceMapPath;
@@ -26845,13 +26800,13 @@ var ts;
26845
26800
  };
26846
26801
  node.javascriptPath = declarationTextOrJavascriptPath;
26847
26802
  node.javascriptMapPath = javascriptMapPath;
26848
- node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
26803
+ node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
26849
26804
  node.declarationMapPath = declarationMapPath;
26850
26805
  node.buildInfoPath = declarationMapTextOrBuildInfoPath;
26851
26806
  Object.defineProperties(node, {
26852
26807
  javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
26853
26808
  javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
26854
- declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
26809
+ declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
26855
26810
  declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
26856
26811
  buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
26857
26812
  });
@@ -51860,8 +51815,8 @@ var ts;
51860
51815
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
51861
51816
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
51862
51817
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 170 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
51863
- if (signature.thisParameter) {
51864
- var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
51818
+ var thisParameter = tryGetThisParameterDeclaration(signature, context);
51819
+ if (thisParameter) {
51865
51820
  parameters.unshift(thisParameter);
51866
51821
  }
51867
51822
  var returnTypeNode;
@@ -51910,6 +51865,21 @@ var ts;
51910
51865
  }
51911
51866
  return node;
51912
51867
  }
51868
+ function tryGetThisParameterDeclaration(signature, context) {
51869
+ if (signature.thisParameter) {
51870
+ return symbolToParameterDeclaration(signature.thisParameter, context);
51871
+ }
51872
+ if (signature.declaration) {
51873
+ var thisTag = ts.getJSDocThisTag(signature.declaration);
51874
+ if (thisTag && thisTag.typeExpression) {
51875
+ return ts.factory.createParameterDeclaration(
51876
+ /* decorators */ undefined,
51877
+ /* modifiers */ undefined,
51878
+ /* dotDotDotToken */ undefined, "this",
51879
+ /* questionToken */ undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context));
51880
+ }
51881
+ }
51882
+ }
51913
51883
  function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
51914
51884
  var savedContextFlags = context.flags;
51915
51885
  context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
@@ -52351,10 +52321,8 @@ var ts;
52351
52321
  firstChar = symbolName.charCodeAt(0);
52352
52322
  }
52353
52323
  var expression = void 0;
52354
- if (ts.isSingleOrDoubleQuote(firstChar)) {
52355
- expression = ts.factory.createStringLiteral(symbolName
52356
- .substring(1, symbolName.length - 1)
52357
- .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52324
+ if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) {
52325
+ expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52358
52326
  }
52359
52327
  else if (("" + +symbolName) === symbolName) {
52360
52328
  expression = ts.factory.createNumericLiteral(+symbolName);
@@ -94347,7 +94315,7 @@ var ts;
94347
94315
  function visitYieldExpression(node) {
94348
94316
  if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
94349
94317
  if (node.asteriskToken) {
94350
- var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
94318
+ var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression);
94351
94319
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
94352
94320
  /*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(factory.updateYieldExpression(node, node.asteriskToken, ts.setTextRange(emitHelpers().createAsyncDelegatorHelper(ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), expression)), expression)))), node), node);
94353
94321
  }
@@ -95272,11 +95240,11 @@ var ts;
95272
95240
  return existing.name;
95273
95241
  }
95274
95242
  if (!currentFileState.utilizedImplicitRuntimeImports) {
95275
- currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
95243
+ currentFileState.utilizedImplicitRuntimeImports = new ts.Map();
95276
95244
  }
95277
95245
  var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
95278
95246
  if (!specifierSourceImports) {
95279
- specifierSourceImports = ts.createMap();
95247
+ specifierSourceImports = new ts.Map();
95280
95248
  currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
95281
95249
  }
95282
95250
  var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
@@ -113803,6 +113771,24 @@ var ts;
113803
113771
  }
113804
113772
  }
113805
113773
  ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
113774
+ /** @internal */
113775
+ ts.plainJSErrors = new ts.Set([
113776
+ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
113777
+ ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code,
113778
+ ts.Diagnostics.Another_export_default_is_here.code,
113779
+ ts.Diagnostics.The_first_export_default_is_here.code,
113780
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
113781
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
113782
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
113783
+ ts.Diagnostics.constructor_is_a_reserved_word.code,
113784
+ ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
113785
+ ts.Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
113786
+ ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
113787
+ ts.Diagnostics.Invalid_use_of_0_in_strict_mode.code,
113788
+ ts.Diagnostics.A_label_is_not_allowed_here.code,
113789
+ ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
113790
+ ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
113791
+ ]);
113806
113792
  /**
113807
113793
  * Determine if source file needs to be re-created even if its text hasn't changed
113808
113794
  */
@@ -114463,6 +114449,7 @@ var ts;
114463
114449
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
114464
114450
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
114465
114451
  newSourceFile.fileName = oldSourceFile.fileName;
114452
+ newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
114466
114453
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
114467
114454
  if (packageName !== undefined) {
114468
114455
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -114819,14 +114806,23 @@ var ts;
114819
114806
  }
114820
114807
  var typeChecker = getDiagnosticsProducingTypeChecker();
114821
114808
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
114822
- var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
114809
+ var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
114810
+ var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
114811
+ var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
114823
114812
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
114824
- // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
114813
+ // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
114814
+ // - plain JS: .js files with no // ts-check and checkJs: undefined
114815
+ // - check JS: .js files with either // ts-check or checkJs: true
114816
+ // - external: files that are added by plugins
114825
114817
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */
114826
- || sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114818
+ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114827
114819
  var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
114828
- var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114829
- return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114820
+ var checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114821
+ if (isPlainJs) {
114822
+ bindDiagnostics = ts.filter(bindDiagnostics, function (d) { return ts.plainJSErrors.has(d.code); });
114823
+ }
114824
+ // skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
114825
+ return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114830
114826
  });
114831
114827
  }
114832
114828
  function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
@@ -118735,7 +118731,7 @@ var ts;
118735
118731
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118736
118732
  if (resolution.refCount) {
118737
118733
  resolution.refCount++;
118738
- ts.Debug.assertDefined(resolution.files);
118734
+ ts.Debug.assertIsDefined(resolution.files);
118739
118735
  }
118740
118736
  else {
118741
118737
  resolution.refCount = 1;
@@ -118803,7 +118799,7 @@ var ts;
118803
118799
  }
118804
118800
  }
118805
118801
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
118806
- ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
118802
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
118807
118803
  resolution.refCount--;
118808
118804
  if (resolution.refCount) {
118809
118805
  return;
@@ -118895,7 +118891,7 @@ var ts;
118895
118891
  if (resolution.isInvalidated || !canInvalidate(resolution))
118896
118892
  continue;
118897
118893
  resolution.isInvalidated = invalidated = true;
118898
- for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
118894
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
118899
118895
  var containingFilePath = _b[_a];
118900
118896
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
118901
118897
  // When its a file with inferred types resolution, invalidate type reference directive resolution
@@ -136171,14 +136167,17 @@ var ts;
136171
136167
  if (node === sourceFile) {
136172
136168
  return undefined;
136173
136169
  }
136174
- var symbol = typeChecker.getSymbolAtLocation(node);
136170
+ var symbol = getSymbol(node, typeChecker);
136175
136171
  if (!symbol)
136176
136172
  return undefined;
136177
136173
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
136178
136174
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
136179
136175
  var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
136180
136176
  // If a function returns 'void' or some other type with no definition, just return the function definition.
136181
- return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136177
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136178
+ return typeDefinitions.length ? typeDefinitions
136179
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
136180
+ : undefined;
136182
136181
  }
136183
136182
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
136184
136183
  function definitionFromType(type, checker, node) {
@@ -150071,9 +150070,9 @@ var ts;
150071
150070
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150072
150071
  return undefined;
150073
150072
  if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
150074
- var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
150073
+ var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
150075
150074
  var name = fn.name;
150076
- var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
150075
+ var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
150077
150076
  if (ts.isFunctionExpression(fn)) {
150078
150077
  if (name && ts.FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
150079
150078
  // Function expression references itself. To fix we would have to extract it to a const.