typescript 4.6.0-dev.20220107 → 4.6.0-dev.20220108

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.
@@ -19,10 +19,57 @@ and limitations under the License.
19
19
 
20
20
 
21
21
  interface ErrorOptions {
22
- cause?: Error;
22
+ cause?: Error;
23
+ }
24
+
25
+ interface Error {
26
+ cause?: Error;
23
27
  }
24
28
 
25
29
  interface ErrorConstructor {
26
- new(message?: string, options?: ErrorOptions): Error;
27
- (message?: string, options?: ErrorOptions): Error;
30
+ new (message?: string, options?: ErrorOptions): Error;
31
+ (message?: string, options?: ErrorOptions): Error;
32
+ }
33
+
34
+ interface EvalErrorConstructor {
35
+ new (message?: string, options?: ErrorOptions): EvalError;
36
+ (message?: string, options?: ErrorOptions): EvalError;
37
+ }
38
+
39
+ interface RangeErrorConstructor {
40
+ new (message?: string, options?: ErrorOptions): RangeError;
41
+ (message?: string, options?: ErrorOptions): RangeError;
42
+ }
43
+
44
+ interface ReferenceErrorConstructor {
45
+ new (message?: string, options?: ErrorOptions): ReferenceError;
46
+ (message?: string, options?: ErrorOptions): ReferenceError;
47
+ }
48
+
49
+ interface SyntaxErrorConstructor {
50
+ new (message?: string, options?: ErrorOptions): SyntaxError;
51
+ (message?: string, options?: ErrorOptions): SyntaxError;
52
+ }
53
+
54
+ interface TypeErrorConstructor {
55
+ new (message?: string, options?: ErrorOptions): TypeError;
56
+ (message?: string, options?: ErrorOptions): TypeError;
57
+ }
58
+
59
+ interface URIErrorConstructor {
60
+ new (message?: string, options?: ErrorOptions): URIError;
61
+ (message?: string, options?: ErrorOptions): URIError;
62
+ }
63
+
64
+ interface AggregateErrorConstructor {
65
+ new (
66
+ errors: Iterable<any>,
67
+ message?: string,
68
+ options?: ErrorOptions
69
+ ): AggregateError;
70
+ (
71
+ errors: Iterable<any>,
72
+ message?: string,
73
+ options?: ErrorOptions
74
+ ): AggregateError;
28
75
  }
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220107";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220108";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
@@ -11002,7 +11002,8 @@ var ts;
11002
11002
  Float64Array: ["at"],
11003
11003
  BigInt64Array: ["at"],
11004
11004
  BigUint64Array: ["at"],
11005
- ObjectConstructor: ["hasOwn"]
11005
+ ObjectConstructor: ["hasOwn"],
11006
+ Error: ["cause"]
11006
11007
  }
11007
11008
  };
11008
11009
  }
@@ -16525,9 +16526,19 @@ var ts;
16525
16526
  }
16526
16527
  ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
16527
16528
  function escapeSnippetText(text) {
16528
- return text.replace(/\$/gm, "\\$");
16529
+ return text.replace(/\$/gm, function () { return "\\$"; });
16529
16530
  }
16530
16531
  ts.escapeSnippetText = escapeSnippetText;
16532
+ function isNumericLiteralName(name) {
16533
+ return (+name).toString() === name;
16534
+ }
16535
+ ts.isNumericLiteralName = isNumericLiteralName;
16536
+ function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
16537
+ return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
16538
+ !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
16539
+ ts.factory.createStringLiteral(name, !!singleQuote);
16540
+ }
16541
+ ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
16531
16542
  function isThisTypeParameter(type) {
16532
16543
  return !!(type.flags & 262144 && type.isThisType);
16533
16544
  }
@@ -38299,6 +38310,7 @@ var ts;
38299
38310
  var location = ts.getParseTreeNode(locationIn);
38300
38311
  return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
38301
38312
  },
38313
+ getTypeOfSymbol: getTypeOfSymbol,
38302
38314
  getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
38303
38315
  var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
38304
38316
  if (parameter === undefined)
@@ -43096,31 +43108,26 @@ var ts;
43096
43108
  }
43097
43109
  var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
43098
43110
  var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
43099
- return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote);
43111
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
43100
43112
  }
43101
43113
  function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
43102
43114
  var nameType = getSymbolLinks(symbol).nameType;
43103
43115
  if (nameType) {
43104
43116
  if (nameType.flags & 384) {
43105
43117
  var name = "" + nameType.value;
43106
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
43118
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
43107
43119
  return ts.factory.createStringLiteral(name, !!singleQuote);
43108
43120
  }
43109
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
43121
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
43110
43122
  return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
43111
43123
  }
43112
- return createPropertyNameNodeForIdentifierOrLiteral(name);
43124
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
43113
43125
  }
43114
43126
  if (nameType.flags & 8192) {
43115
43127
  return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
43116
43128
  }
43117
43129
  }
43118
43130
  }
43119
- function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
43120
- return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
43121
- !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
43122
- ts.factory.createStringLiteral(name, !!singleQuote);
43123
- }
43124
43131
  function cloneNodeBuilderContext(context) {
43125
43132
  var initial = __assign({}, context);
43126
43133
  if (initial.typeParameterNames) {
@@ -44316,10 +44323,10 @@ var ts;
44316
44323
  if (nameType) {
44317
44324
  if (nameType.flags & 384) {
44318
44325
  var name = "" + nameType.value;
44319
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
44326
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
44320
44327
  return "\"" + ts.escapeString(name, 34) + "\"";
44321
44328
  }
44322
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
44329
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
44323
44330
  return "[" + name + "]";
44324
44331
  }
44325
44332
  return name;
@@ -47817,7 +47824,7 @@ var ts;
47817
47824
  function isApplicableIndexType(source, target) {
47818
47825
  return isTypeAssignableTo(source, target) ||
47819
47826
  target === stringType && isTypeAssignableTo(source, numberType) ||
47820
- target === numberType && !!(source.flags & 128) && isNumericLiteralName(source.value);
47827
+ target === numberType && !!(source.flags & 128) && ts.isNumericLiteralName(source.value);
47821
47828
  }
47822
47829
  function getIndexInfosOfStructuredType(type) {
47823
47830
  if (type.flags & 3670016) {
@@ -50120,7 +50127,7 @@ var ts;
50120
50127
  getFlowTypeOfReference(accessExpression, propType) :
50121
50128
  propType;
50122
50129
  }
50123
- if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
50130
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
50124
50131
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) {
50125
50132
  var indexNode = getIndexNodeForAccessExpression(accessNode);
50126
50133
  if (isTupleType(objectType)) {
@@ -50375,7 +50382,7 @@ var ts;
50375
50382
  return everyType(indexType, function (t) {
50376
50383
  if (t.flags & 384) {
50377
50384
  var propName = getPropertyNameFromType(t);
50378
- if (isNumericLiteralName(propName)) {
50385
+ if (ts.isNumericLiteralName(propName)) {
50379
50386
  var index = +propName;
50380
50387
  return index >= 0 && index < limit;
50381
50388
  }
@@ -53460,7 +53467,7 @@ var ts;
53460
53467
  }
53461
53468
  }
53462
53469
  else {
53463
- var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
53470
+ var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
53464
53471
  if (distributiveConstraint) {
53465
53472
  if (result = isRelatedTo(distributiveConstraint, target, 1, reportErrors)) {
53466
53473
  resetErrorInfo(saveErrorInfo);
@@ -53918,7 +53925,7 @@ var ts;
53918
53925
  for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
53919
53926
  var targetProp = _c[_b];
53920
53927
  var name = targetProp.escapedName;
53921
- if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
53928
+ if (!(targetProp.flags & 4194304) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
53922
53929
  var sourceProp = getPropertyOfType(source, name);
53923
53930
  if (sourceProp && sourceProp !== targetProp) {
53924
53931
  var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
@@ -53987,7 +53994,8 @@ var ts;
53987
53994
  var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
53988
53995
  var sourceObjectFlags = ts.getObjectFlags(source);
53989
53996
  var targetObjectFlags = ts.getObjectFlags(target);
53990
- if (sourceObjectFlags & 64 && targetObjectFlags & 64 && source.symbol === target.symbol) {
53997
+ if (sourceObjectFlags & 64 && targetObjectFlags & 64 && source.symbol === target.symbol ||
53998
+ sourceObjectFlags & 4 && targetObjectFlags & 4 && source.target === target.target) {
53991
53999
  for (var i = 0; i < targetSignatures.length; i++) {
53992
54000
  var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
53993
54001
  if (!related) {
@@ -54868,9 +54876,12 @@ var ts;
54868
54876
  && ((target.flags & (8 | 4 | 16)) !== 0);
54869
54877
  }
54870
54878
  function isObjectTypeWithInferableIndex(type) {
54871
- return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
54872
- !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
54873
- !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 && isObjectTypeWithInferableIndex(type.source));
54879
+ return type.flags & 2097152
54880
+ ? ts.every(type.types, isObjectTypeWithInferableIndex)
54881
+ : !!(type.symbol
54882
+ && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0
54883
+ && !(type.symbol.flags & 32)
54884
+ && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 && isObjectTypeWithInferableIndex(type.source));
54874
54885
  }
54875
54886
  function createSymbolWithType(source, type) {
54876
54887
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
@@ -59137,7 +59148,7 @@ var ts;
59137
59148
  }
59138
59149
  if (isTupleType(t)) {
59139
59150
  var restType = getRestTypeOfTupleType(t);
59140
- if (restType && isNumericLiteralName(name) && +name >= 0) {
59151
+ if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
59141
59152
  return restType;
59142
59153
  }
59143
59154
  }
@@ -59680,10 +59691,10 @@ var ts;
59680
59691
  case 161:
59681
59692
  return isNumericComputedName(name);
59682
59693
  case 79:
59683
- return isNumericLiteralName(name.escapedText);
59694
+ return ts.isNumericLiteralName(name.escapedText);
59684
59695
  case 8:
59685
59696
  case 10:
59686
- return isNumericLiteralName(name.text);
59697
+ return ts.isNumericLiteralName(name.text);
59687
59698
  default:
59688
59699
  return false;
59689
59700
  }
@@ -59691,9 +59702,6 @@ var ts;
59691
59702
  function isNumericComputedName(name) {
59692
59703
  return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
59693
59704
  }
59694
- function isNumericLiteralName(name) {
59695
- return (+name).toString() === name;
59696
- }
59697
59705
  function checkComputedPropertyName(node) {
59698
59706
  var links = getNodeLinks(node.expression);
59699
59707
  if (!links.resolvedType) {
@@ -59722,7 +59730,7 @@ var ts;
59722
59730
  function isSymbolWithNumericName(symbol) {
59723
59731
  var _a;
59724
59732
  var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
59725
- return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
59733
+ return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
59726
59734
  }
59727
59735
  function isSymbolWithSymbolName(symbol) {
59728
59736
  var _a;
@@ -69035,7 +69043,7 @@ var ts;
69035
69043
  }
69036
69044
  else {
69037
69045
  var text = ts.getTextOfPropertyName(member.name);
69038
- if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
69046
+ if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
69039
69047
  error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
69040
69048
  }
69041
69049
  }
@@ -99151,7 +99159,7 @@ var ts;
99151
99159
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
99152
99160
  }
99153
99161
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
99154
- function getErrorSummaryText(errorCount, filesInError, newLine) {
99162
+ function getErrorSummaryText(errorCount, filesInError, newLine, host) {
99155
99163
  if (errorCount === 0)
99156
99164
  return "";
99157
99165
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
@@ -99166,10 +99174,10 @@ var ts;
99166
99174
  distinctFileNamesWithLines.length === 1 ?
99167
99175
  ts.Diagnostics.Found_0_errors_in_1_file :
99168
99176
  ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
99169
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
99177
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
99170
99178
  }
99171
99179
  ts.getErrorSummaryText = getErrorSummaryText;
99172
- function createTabularErrorsDisplay(filesInError) {
99180
+ function createTabularErrorsDisplay(filesInError, host) {
99173
99181
  var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
99174
99182
  if (distinctFiles.length === 0)
99175
99183
  return "";
@@ -99188,7 +99196,8 @@ var ts;
99188
99196
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
99189
99197
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
99190
99198
  : "";
99191
- tabularData += "" + leftPadding + errorCount + " " + file.fileName + ":" + file.line + "\n";
99199
+ var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, false);
99200
+ tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
99192
99201
  });
99193
99202
  return tabularData;
99194
99203
  }
@@ -99570,7 +99579,7 @@ var ts;
99570
99579
  var system = input.system || ts.sys;
99571
99580
  var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
99572
99581
  var builderProgram = ts.createIncrementalProgram(input);
99573
- var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine)); } : undefined);
99582
+ var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine, host)); } : undefined);
99574
99583
  if (input.afterProgramEmitAndDiagnostics)
99575
99584
  input.afterProgramEmitAndDiagnostics(builderProgram);
99576
99585
  return exitStatus;
@@ -102280,7 +102289,7 @@ var ts;
102280
102289
  }
102281
102290
  function createReportErrorSummary(sys, options) {
102282
102291
  return shouldBePretty(sys, options) ?
102283
- function (errorCount, filesInError) { return sys.write(ts.getErrorSummaryText(errorCount, filesInError, sys.newLine)); } :
102292
+ function (errorCount, filesInError) { return sys.write(ts.getErrorSummaryText(errorCount, filesInError, sys.newLine, sys)); } :
102284
102293
  undefined;
102285
102294
  }
102286
102295
  function performCompilation(sys, cb, reportDiagnostic, config) {