typescript 4.6.0-dev.20211115 → 4.6.0-dev.20211119

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20211115";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20211119";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -151,26 +151,6 @@ var ts;
151
151
  ts.emptyArray = [];
152
152
  ts.emptyMap = new ts.Map();
153
153
  ts.emptySet = new ts.Set();
154
- function createMap() {
155
- return new ts.Map();
156
- }
157
- ts.createMap = createMap;
158
- /**
159
- * Create a new map from a template object is provided, the map will copy entries from it.
160
- * @deprecated Use `new Map(getEntries(template))` instead.
161
- */
162
- function createMapFromTemplate(template) {
163
- var map = new ts.Map();
164
- // Copies keys/values from template. Note that for..in will not throw if
165
- // template is undefined, and instead will just exit the loop.
166
- for (var key in template) {
167
- if (hasOwnProperty.call(template, key)) {
168
- map.set(key, template[key]);
169
- }
170
- }
171
- return map;
172
- }
173
- ts.createMapFromTemplate = createMapFromTemplate;
174
154
  function length(array) {
175
155
  return array ? array.length : 0;
176
156
  }
@@ -2405,11 +2385,6 @@ var ts;
2405
2385
  return value;
2406
2386
  }
2407
2387
  Debug.checkDefined = checkDefined;
2408
- /**
2409
- * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
2410
- * a value is defined at the statement level.
2411
- */
2412
- Debug.assertDefined = checkDefined;
2413
2388
  function assertEachIsDefined(value, message, stackCrawlMark) {
2414
2389
  for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
2415
2390
  var v = value_1[_i];
@@ -2422,11 +2397,6 @@ var ts;
2422
2397
  return value;
2423
2398
  }
2424
2399
  Debug.checkEachDefined = checkEachDefined;
2425
- /**
2426
- * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
2427
- * the elements of an array are defined at the statement level.
2428
- */
2429
- Debug.assertEachDefined = checkEachDefined;
2430
2400
  function assertNever(member, message, stackCrawlMark) {
2431
2401
  if (message === void 0) { message = "Illegal value:"; }
2432
2402
  var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
@@ -13886,21 +13856,6 @@ var ts;
13886
13856
  return undefined;
13887
13857
  }
13888
13858
  ts.getDeclarationOfKind = getDeclarationOfKind;
13889
- /**
13890
- * Create a new escaped identifier map.
13891
- * @deprecated Use `new Map<__String, T>()` instead.
13892
- */
13893
- function createUnderscoreEscapedMap() {
13894
- return new ts.Map();
13895
- }
13896
- ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
13897
- /**
13898
- * @deprecated Use `!!map?.size` instead
13899
- */
13900
- function hasEntries(map) {
13901
- return !!map && !!map.size;
13902
- }
13903
- ts.hasEntries = hasEntries;
13904
13859
  function createSymbolTable(symbols) {
13905
13860
  var result = new ts.Map();
13906
13861
  if (symbols) {
@@ -26493,7 +26448,7 @@ var ts;
26493
26448
  sourceMapText = mapTextOrStripInternal;
26494
26449
  }
26495
26450
  var node = oldFileOfCurrentEmit ?
26496
- parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
26451
+ parseOldFileOfCurrentEmit(ts.Debug.checkDefined(bundleFileInfo)) :
26497
26452
  parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
26498
26453
  node.fileName = fileName;
26499
26454
  node.sourceMapPath = sourceMapPath;
@@ -26640,13 +26595,13 @@ var ts;
26640
26595
  };
26641
26596
  node.javascriptPath = declarationTextOrJavascriptPath;
26642
26597
  node.javascriptMapPath = javascriptMapPath;
26643
- node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
26598
+ node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
26644
26599
  node.declarationMapPath = declarationMapPath;
26645
26600
  node.buildInfoPath = declarationMapTextOrBuildInfoPath;
26646
26601
  Object.defineProperties(node, {
26647
26602
  javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
26648
26603
  javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
26649
- declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
26604
+ declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
26650
26605
  declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
26651
26606
  buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
26652
26607
  });
@@ -51655,8 +51610,8 @@ var ts;
51655
51610
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
51656
51611
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
51657
51612
  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); });
51658
- if (signature.thisParameter) {
51659
- var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
51613
+ var thisParameter = tryGetThisParameterDeclaration(signature, context);
51614
+ if (thisParameter) {
51660
51615
  parameters.unshift(thisParameter);
51661
51616
  }
51662
51617
  var returnTypeNode;
@@ -51705,6 +51660,21 @@ var ts;
51705
51660
  }
51706
51661
  return node;
51707
51662
  }
51663
+ function tryGetThisParameterDeclaration(signature, context) {
51664
+ if (signature.thisParameter) {
51665
+ return symbolToParameterDeclaration(signature.thisParameter, context);
51666
+ }
51667
+ if (signature.declaration) {
51668
+ var thisTag = ts.getJSDocThisTag(signature.declaration);
51669
+ if (thisTag && thisTag.typeExpression) {
51670
+ return ts.factory.createParameterDeclaration(
51671
+ /* decorators */ undefined,
51672
+ /* modifiers */ undefined,
51673
+ /* dotDotDotToken */ undefined, "this",
51674
+ /* questionToken */ undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context));
51675
+ }
51676
+ }
51677
+ }
51708
51678
  function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
51709
51679
  var savedContextFlags = context.flags;
51710
51680
  context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
@@ -52146,10 +52116,8 @@ var ts;
52146
52116
  firstChar = symbolName.charCodeAt(0);
52147
52117
  }
52148
52118
  var expression = void 0;
52149
- if (ts.isSingleOrDoubleQuote(firstChar)) {
52150
- expression = ts.factory.createStringLiteral(symbolName
52151
- .substring(1, symbolName.length - 1)
52152
- .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52119
+ if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) {
52120
+ expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52153
52121
  }
52154
52122
  else if (("" + +symbolName) === symbolName) {
52155
52123
  expression = ts.factory.createNumericLiteral(+symbolName);
@@ -94142,7 +94110,7 @@ var ts;
94142
94110
  function visitYieldExpression(node) {
94143
94111
  if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
94144
94112
  if (node.asteriskToken) {
94145
- var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
94113
+ var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression);
94146
94114
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
94147
94115
  /*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(factory.updateYieldExpression(node, node.asteriskToken, ts.setTextRange(emitHelpers().createAsyncDelegatorHelper(ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), expression)), expression)))), node), node);
94148
94116
  }
@@ -95067,11 +95035,11 @@ var ts;
95067
95035
  return existing.name;
95068
95036
  }
95069
95037
  if (!currentFileState.utilizedImplicitRuntimeImports) {
95070
- currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
95038
+ currentFileState.utilizedImplicitRuntimeImports = new ts.Map();
95071
95039
  }
95072
95040
  var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
95073
95041
  if (!specifierSourceImports) {
95074
- specifierSourceImports = ts.createMap();
95042
+ specifierSourceImports = new ts.Map();
95075
95043
  currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
95076
95044
  }
95077
95045
  var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
@@ -108666,6 +108634,7 @@ var ts;
108666
108634
  return emitJSDocSignature(node);
108667
108635
  case 325 /* JSDocTag */:
108668
108636
  case 330 /* JSDocClassTag */:
108637
+ case 335 /* JSDocOverrideTag */:
108669
108638
  return emitJSDocSimpleTag(node);
108670
108639
  case 326 /* JSDocAugmentsTag */:
108671
108640
  case 327 /* JSDocImplementsTag */:
@@ -108678,7 +108647,6 @@ var ts;
108678
108647
  case 332 /* JSDocPrivateTag */:
108679
108648
  case 333 /* JSDocProtectedTag */:
108680
108649
  case 334 /* JSDocReadonlyTag */:
108681
- case 335 /* JSDocOverrideTag */:
108682
108650
  return;
108683
108651
  case 336 /* JSDocCallbackTag */:
108684
108652
  return emitJSDocCallbackTag(node);
@@ -113598,6 +113566,24 @@ var ts;
113598
113566
  }
113599
113567
  }
113600
113568
  ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
113569
+ /** @internal */
113570
+ ts.plainJSErrors = new ts.Set([
113571
+ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
113572
+ ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code,
113573
+ ts.Diagnostics.Another_export_default_is_here.code,
113574
+ ts.Diagnostics.The_first_export_default_is_here.code,
113575
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
113576
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
113577
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
113578
+ ts.Diagnostics.constructor_is_a_reserved_word.code,
113579
+ ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
113580
+ 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,
113581
+ ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
113582
+ ts.Diagnostics.Invalid_use_of_0_in_strict_mode.code,
113583
+ ts.Diagnostics.A_label_is_not_allowed_here.code,
113584
+ ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
113585
+ ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
113586
+ ]);
113601
113587
  /**
113602
113588
  * Determine if source file needs to be re-created even if its text hasn't changed
113603
113589
  */
@@ -114258,6 +114244,7 @@ var ts;
114258
114244
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
114259
114245
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
114260
114246
  newSourceFile.fileName = oldSourceFile.fileName;
114247
+ newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
114261
114248
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
114262
114249
  if (packageName !== undefined) {
114263
114250
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -114614,14 +114601,23 @@ var ts;
114614
114601
  }
114615
114602
  var typeChecker = getDiagnosticsProducingTypeChecker();
114616
114603
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
114617
- var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
114604
+ var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
114605
+ var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
114606
+ var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
114618
114607
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
114619
- // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
114608
+ // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
114609
+ // - plain JS: .js files with no // ts-check and checkJs: undefined
114610
+ // - check JS: .js files with either // ts-check or checkJs: true
114611
+ // - external: files that are added by plugins
114620
114612
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */
114621
- || sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114613
+ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114622
114614
  var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
114623
- var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114624
- return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114615
+ var checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114616
+ if (isPlainJs) {
114617
+ bindDiagnostics = ts.filter(bindDiagnostics, function (d) { return ts.plainJSErrors.has(d.code); });
114618
+ }
114619
+ // skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
114620
+ return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114625
114621
  });
114626
114622
  }
114627
114623
  function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
@@ -115635,7 +115631,7 @@ var ts;
115635
115631
  return resolvedRef;
115636
115632
  }
115637
115633
  function verifyCompilerOptions() {
115638
- var isNightly = ts.stringContains(ts.version, "-dev");
115634
+ var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
115639
115635
  if (!isNightly) {
115640
115636
  if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
115641
115637
  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");
@@ -118530,7 +118526,7 @@ var ts;
118530
118526
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118531
118527
  if (resolution.refCount) {
118532
118528
  resolution.refCount++;
118533
- ts.Debug.assertDefined(resolution.files);
118529
+ ts.Debug.assertIsDefined(resolution.files);
118534
118530
  }
118535
118531
  else {
118536
118532
  resolution.refCount = 1;
@@ -118598,7 +118594,7 @@ var ts;
118598
118594
  }
118599
118595
  }
118600
118596
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
118601
- ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
118597
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
118602
118598
  resolution.refCount--;
118603
118599
  if (resolution.refCount) {
118604
118600
  return;
@@ -118690,7 +118686,7 @@ var ts;
118690
118686
  if (resolution.isInvalidated || !canInvalidate(resolution))
118691
118687
  continue;
118692
118688
  resolution.isInvalidated = invalidated = true;
118693
- for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
118689
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
118694
118690
  var containingFilePath = _b[_a];
118695
118691
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
118696
118692
  // When its a file with inferred types resolution, invalidate type reference directive resolution
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.6.0-dev.20211115",
5
+ "version": "4.6.0-dev.20211119",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [