typescript 4.7.0-dev.20220418 → 4.7.0-dev.20220421

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.
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.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220418";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220421";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -26733,7 +26733,7 @@ var ts;
26733
26733
  var pos = getNodePos();
26734
26734
  parseExpected(112);
26735
26735
  var entityName = parseEntityName(true, true);
26736
- var typeArguments = tryParseTypeArguments();
26736
+ var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
26737
26737
  return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
26738
26738
  }
26739
26739
  function parseTypeParameter() {
@@ -51418,8 +51418,11 @@ var ts;
51418
51418
  return type[cache] = elementType;
51419
51419
  }
51420
51420
  }
51421
- if (isGenericMappedType(objectType) && !objectType.declaration.nameType) {
51422
- return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
51421
+ if (isGenericMappedType(objectType)) {
51422
+ var nameType = getNameTypeFromMappedType(objectType);
51423
+ if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
51424
+ return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
51425
+ }
51423
51426
  }
51424
51427
  return type[cache] = type;
51425
51428
  }
@@ -61997,7 +62000,9 @@ var ts;
61997
62000
  }
61998
62001
  prop = getPropertyOfType(apparentType, right.escapedText);
61999
62002
  }
62000
- if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
62003
+ if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
62004
+ !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 && node.parent.kind === 299)) ||
62005
+ ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
62001
62006
  markAliasReferenced(parentSymbol, node);
62002
62007
  }
62003
62008
  var propType;
@@ -72127,15 +72132,14 @@ var ts;
72127
72132
  return propertyDeclaration;
72128
72133
  }
72129
72134
  }
72130
- else if (ts.isMetaProperty(parent)) {
72131
- var parentType = getTypeOfNode(parent);
72132
- var propertyDeclaration = getPropertyOfType(parentType, node.escapedText);
72133
- if (propertyDeclaration) {
72134
- return propertyDeclaration;
72135
- }
72136
- if (parent.keywordToken === 103) {
72135
+ else if (ts.isMetaProperty(parent) && parent.name === node) {
72136
+ if (parent.keywordToken === 103 && ts.idText(node) === "target") {
72137
72137
  return checkNewTargetMetaProperty(parent).symbol;
72138
72138
  }
72139
+ if (parent.keywordToken === 100 && ts.idText(node) === "meta") {
72140
+ return getGlobalImportMetaExpressionType().members.get("meta");
72141
+ }
72142
+ return undefined;
72139
72143
  }
72140
72144
  }
72141
72145
  switch (node.kind) {
@@ -79081,7 +79085,7 @@ var ts;
79081
79085
  }
79082
79086
  resumeLexicalEnvironment();
79083
79087
  var needsSyntheticConstructor = !constructor && isDerivedClass;
79084
- var indexOfFirstStatementAfterSuper = 0;
79088
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
79085
79089
  var prologueStatementCount = 0;
79086
79090
  var superStatementIndex = -1;
79087
79091
  var statements = [];
@@ -79089,8 +79093,11 @@ var ts;
79089
79093
  prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, false, visitor);
79090
79094
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
79091
79095
  if (superStatementIndex >= 0) {
79092
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
79093
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
79096
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
79097
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
79098
+ }
79099
+ else if (prologueStatementCount >= 0) {
79100
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
79094
79101
  }
79095
79102
  }
79096
79103
  if (needsSyntheticConstructor) {
@@ -79109,19 +79116,17 @@ var ts;
79109
79116
  }
79110
79117
  }
79111
79118
  if (parameterPropertyDeclarationCount > 0) {
79112
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
79119
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
79113
79120
  if (superStatementIndex >= 0) {
79114
79121
  ts.addRange(statements, parameterProperties);
79115
79122
  }
79116
- else if (needsSyntheticConstructor) {
79117
- statements = __spreadArray(__spreadArray([
79118
- statements[0]
79119
- ], parameterProperties, true), statements.slice(1), true);
79120
- }
79121
79123
  else {
79122
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
79124
+ var superAndPrologueStatementCount = prologueStatementCount;
79125
+ if (needsSyntheticConstructor)
79126
+ superAndPrologueStatementCount++;
79127
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
79123
79128
  }
79124
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
79129
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
79125
79130
  }
79126
79131
  }
79127
79132
  }
@@ -79129,7 +79134,7 @@ var ts;
79129
79134
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
79130
79135
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
79131
79136
  if (constructor) {
79132
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
79137
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
79133
79138
  }
79134
79139
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
79135
79140
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
@@ -82349,7 +82354,7 @@ var ts;
82349
82354
  else {
82350
82355
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
82351
82356
  }
82352
- var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), constructor.body.statements), true);
82357
+ var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), constructor.body.statements), true);
82353
82358
  ts.setTextRange(body, constructor.body);
82354
82359
  return body;
82355
82360
  }
@@ -98961,29 +98966,30 @@ var ts;
98961
98966
  }
98962
98967
  return undefined;
98963
98968
  }
98969
+ function removeDiagnosticsOfLibraryFiles(state) {
98970
+ if (!state.cleanedDiagnosticsOfLibFiles) {
98971
+ state.cleanedDiagnosticsOfLibFiles = true;
98972
+ var program_1 = ts.Debug.checkDefined(state.program);
98973
+ var options_2 = program_1.getCompilerOptions();
98974
+ ts.forEach(program_1.getSourceFiles(), function (f) {
98975
+ return program_1.isSourceFileDefaultLibrary(f) &&
98976
+ !ts.skipTypeChecking(f, options_2, program_1) &&
98977
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
98978
+ });
98979
+ }
98980
+ }
98964
98981
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
98965
98982
  var _a;
98966
98983
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
98967
98984
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
98968
- if (!state.cleanedDiagnosticsOfLibFiles) {
98969
- state.cleanedDiagnosticsOfLibFiles = true;
98970
- var program_1 = ts.Debug.checkDefined(state.program);
98971
- var options_2 = program_1.getCompilerOptions();
98972
- ts.forEach(program_1.getSourceFiles(), function (f) {
98973
- return program_1.isSourceFileDefaultLibrary(f) &&
98974
- !ts.skipTypeChecking(f, options_2, program_1) &&
98975
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
98976
- });
98977
- }
98985
+ removeDiagnosticsOfLibraryFiles(state);
98978
98986
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
98979
98987
  return;
98980
98988
  }
98981
- else {
98982
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
98983
- }
98984
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
98985
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
98986
- }
98989
+ ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
98990
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
98991
+ return;
98992
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
98987
98993
  }
98988
98994
  function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
98989
98995
  removeSemanticDiagnosticsOf(state, path);
@@ -99011,11 +99017,32 @@ var ts;
99011
99017
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
99012
99018
  return newSignature !== oldSignature;
99013
99019
  }
99014
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
99015
- var _a, _b;
99016
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
99020
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
99021
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
99022
+ var result = keys && ts.forEachKey(keys, fn);
99023
+ if (result)
99024
+ return result;
99025
+ keys = state.exportedModulesMap.getKeys(filePath);
99026
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
99027
+ var _a;
99028
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99029
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
99030
+ fn(exportedFromPath) :
99031
+ undefined;
99032
+ });
99033
+ }
99034
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
99035
+ var _a;
99036
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
99037
+ return false;
99038
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
99039
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
99040
+ removeDiagnosticsOfLibraryFiles(state);
99041
+ return true;
99042
+ }
99043
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
99044
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
99017
99045
  return;
99018
- }
99019
99046
  if (!isChangedSignature(state, affectedFile.resolvedPath))
99020
99047
  return;
99021
99048
  if (state.compilerOptions.isolatedModules) {
@@ -99026,7 +99053,9 @@ var ts;
99026
99053
  var currentPath = queue.pop();
99027
99054
  if (!seenFileNamesMap.has(currentPath)) {
99028
99055
  seenFileNamesMap.set(currentPath, true);
99029
- fn(state, currentPath);
99056
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
99057
+ return;
99058
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
99030
99059
  if (isChangedSignature(state, currentPath)) {
99031
99060
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
99032
99061
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -99036,42 +99065,31 @@ var ts;
99036
99065
  }
99037
99066
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99038
99067
  var seenFileAndExportsOfFile = new ts.Set();
99039
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99040
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99041
- });
99042
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99043
- var _a;
99044
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99045
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99046
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99068
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
99069
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
99070
+ return true;
99071
+ var references = state.referencedMap.getKeys(exportedFromPath);
99072
+ return references && ts.forEachKey(references, function (filePath) {
99073
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99074
+ });
99047
99075
  });
99048
99076
  }
99049
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
99077
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
99050
99078
  var _a;
99051
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
99052
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
99053
- });
99054
- }
99055
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
99056
- var _a, _b, _c;
99057
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
99058
- return;
99059
- }
99060
- fn(state, filePath);
99079
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
99080
+ return undefined;
99081
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
99082
+ return true;
99083
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
99061
99084
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99062
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99063
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99085
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
99086
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99064
99087
  });
99065
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99066
- var _a;
99067
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99068
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99069
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99070
- });
99071
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
99088
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
99072
99089
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
99073
- fn(state, referencingFilePath);
99090
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host);
99074
99091
  });
99092
+ return undefined;
99075
99093
  }
99076
99094
  function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
99077
99095
  if (isBuildInfoEmit) {