typescript 4.9.0-dev.20221018 → 4.9.0-dev.20221019

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.9";
72
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
72
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -60362,7 +60362,7 @@ var ts;
60362
60362
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
60363
60363
  }
60364
60364
  else if (expr.kind === 218 && isMatchingReference(reference, expr.expression)) {
60365
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
60365
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
60366
60366
  }
60367
60367
  else {
60368
60368
  if (strictNullChecks) {
@@ -60595,7 +60595,7 @@ var ts;
60595
60595
  !!(prop.flags & 16777216) || assumeTrue :
60596
60596
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
60597
60597
  }
60598
- function narrowByInKeyword(type, nameType, assumeTrue) {
60598
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
60599
60599
  var name = getPropertyNameFromType(nameType);
60600
60600
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, true); });
60601
60601
  if (isKnownProperty) {
@@ -60672,7 +60672,7 @@ var ts;
60672
60672
  return getTypeWithFacts(type, assumeTrue ? 524288 : 65536);
60673
60673
  }
60674
60674
  if (isMatchingReference(reference, target)) {
60675
- return narrowByInKeyword(type, leftType, assumeTrue);
60675
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
60676
60676
  }
60677
60677
  }
60678
60678
  break;
@@ -60834,7 +60834,7 @@ var ts;
60834
60834
  neverType;
60835
60835
  });
60836
60836
  }
60837
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
60837
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
60838
60838
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
60839
60839
  if (!witnesses) {
60840
60840
  return type;
@@ -69785,7 +69785,7 @@ var ts;
69785
69785
  if (isGenericObjectType(type)) {
69786
69786
  var baseConstraint = getBaseConstraintOfType(type);
69787
69787
  if (baseConstraint ?
69788
- baseConstraint.flags & 3 || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
69788
+ baseConstraint.flags & 3 || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
69789
69789
  maybeTypeOfKind(type, 8650752)) {
69790
69790
  return true;
69791
69791
  }
@@ -88705,18 +88705,18 @@ var ts;
88705
88705
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
88706
88706
  case ts.ModuleKind.CommonJS:
88707
88707
  default:
88708
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
88708
+ return createImportCallExpressionCommonJS(argument);
88709
88709
  }
88710
88710
  }
88711
88711
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
88712
88712
  needUMDDynamicImportHelper = true;
88713
88713
  if (ts.isSimpleCopiableExpression(arg)) {
88714
88714
  var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536);
88715
- return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(arg, containsLexicalThis), undefined, createImportCallExpressionAMD(argClone, containsLexicalThis));
88715
+ return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(arg), undefined, createImportCallExpressionAMD(argClone, containsLexicalThis));
88716
88716
  }
88717
88717
  else {
88718
88718
  var temp = factory.createTempVariable(hoistVariableDeclaration);
88719
- return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(temp, containsLexicalThis), undefined, createImportCallExpressionAMD(temp, containsLexicalThis)));
88719
+ return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(temp, true), undefined, createImportCallExpressionAMD(temp, containsLexicalThis)));
88720
88720
  }
88721
88721
  }
88722
88722
  function createImportCallExpressionAMD(arg, containsLexicalThis) {
@@ -88745,9 +88745,10 @@ var ts;
88745
88745
  }
88746
88746
  return promise;
88747
88747
  }
88748
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
88748
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
88749
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
88749
88750
  var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), undefined, []);
88750
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), undefined, arg ? [arg] : []);
88751
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"), undefined, temp ? [temp] : arg ? [arg] : []);
88751
88752
  if (ts.getESModuleInterop(compilerOptions)) {
88752
88753
  requireCall = emitHelpers().createImportStarHelper(requireCall);
88753
88754
  }
@@ -88757,11 +88758,9 @@ var ts;
88757
88758
  }
88758
88759
  else {
88759
88760
  func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
88760
- if (containsLexicalThis) {
88761
- ts.setEmitFlags(func, 8);
88762
- }
88763
88761
  }
88764
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), undefined, [func]);
88762
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), undefined, [func]);
88763
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
88765
88764
  }
88766
88765
  function getHelperExpressionForExport(node, innerExpr) {
88767
88766
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864) {
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
112
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -21720,13 +21720,11 @@ var ts;
21720
21720
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21721
21721
  */
21722
21722
  function createBaseNodeFactory() {
21723
- // tslint:disable variable-name
21724
21723
  var NodeConstructor;
21725
21724
  var TokenConstructor;
21726
21725
  var IdentifierConstructor;
21727
21726
  var PrivateIdentifierConstructor;
21728
21727
  var SourceFileConstructor;
21729
- // tslint:enable variable-name
21730
21728
  return {
21731
21729
  createBaseSourceFileNode: createBaseSourceFileNode,
21732
21730
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -27658,11 +27656,9 @@ var ts;
27658
27656
  rawTextScanner.setText("`" + rawText + "`");
27659
27657
  break;
27660
27658
  case 15 /* SyntaxKind.TemplateHead */:
27661
- // tslint:disable-next-line no-invalid-template-strings
27662
27659
  rawTextScanner.setText("`" + rawText + "${");
27663
27660
  break;
27664
27661
  case 16 /* SyntaxKind.TemplateMiddle */:
27665
- // tslint:disable-next-line no-invalid-template-strings
27666
27662
  rawTextScanner.setText("}" + rawText + "${");
27667
27663
  break;
27668
27664
  case 17 /* SyntaxKind.TemplateTail */:
@@ -28021,7 +28017,6 @@ var ts;
28021
28017
  return node;
28022
28018
  }
28023
28019
  ts.createInputFiles = createInputFiles;
28024
- // tslint:disable-next-line variable-name
28025
28020
  var SourceMapSource;
28026
28021
  /**
28027
28022
  * Create an external source map source file reference
@@ -32155,13 +32150,11 @@ var ts;
32155
32150
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32156
32151
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32157
32152
  // capture constructors in 'initializeState' to avoid null checks
32158
- // tslint:disable variable-name
32159
32153
  var NodeConstructor;
32160
32154
  var TokenConstructor;
32161
32155
  var IdentifierConstructor;
32162
32156
  var PrivateIdentifierConstructor;
32163
32157
  var SourceFileConstructor;
32164
- // tslint:enable variable-name
32165
32158
  function countNode(node) {
32166
32159
  nodeCount++;
32167
32160
  return node;
@@ -72131,7 +72124,7 @@ var ts;
72131
72124
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72132
72125
  }
72133
72126
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
72134
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72127
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72135
72128
  }
72136
72129
  else {
72137
72130
  if (strictNullChecks) {
@@ -72412,7 +72405,7 @@ var ts;
72412
72405
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72413
72406
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72414
72407
  }
72415
- function narrowByInKeyword(type, nameType, assumeTrue) {
72408
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72416
72409
  var name = getPropertyNameFromType(nameType);
72417
72410
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72418
72411
  if (isKnownProperty) {
@@ -72493,7 +72486,7 @@ var ts;
72493
72486
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72494
72487
  }
72495
72488
  if (isMatchingReference(reference, target)) {
72496
- return narrowByInKeyword(type, leftType, assumeTrue);
72489
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72497
72490
  }
72498
72491
  }
72499
72492
  break;
@@ -72682,7 +72675,7 @@ var ts;
72682
72675
  neverType;
72683
72676
  });
72684
72677
  }
72685
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72678
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72686
72679
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72687
72680
  if (!witnesses) {
72688
72681
  return type;
@@ -83049,7 +83042,7 @@ var ts;
83049
83042
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
83050
83043
  // or is promise-like.
83051
83044
  if (baseConstraint ?
83052
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83045
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
83053
83046
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
83054
83047
  return true;
83055
83048
  }
@@ -107395,7 +107388,7 @@ var ts;
107395
107388
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107396
107389
  case ts.ModuleKind.CommonJS:
107397
107390
  default:
107398
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107391
+ return createImportCallExpressionCommonJS(argument);
107399
107392
  }
107400
107393
  }
107401
107394
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107418,7 +107411,7 @@ var ts;
107418
107411
  return factory.createConditionalExpression(
107419
107412
  /*condition*/ factory.createIdentifier("__syncRequire"),
107420
107413
  /*questionToken*/ undefined,
107421
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107414
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107422
107415
  /*colonToken*/ undefined,
107423
107416
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107424
107417
  }
@@ -107427,7 +107420,7 @@ var ts;
107427
107420
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107428
107421
  /*condition*/ factory.createIdentifier("__syncRequire"),
107429
107422
  /*questionToken*/ undefined,
107430
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107423
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107431
107424
  /*colonToken*/ undefined,
107432
107425
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107433
107426
  }
@@ -107477,14 +107470,20 @@ var ts;
107477
107470
  }
107478
107471
  return promise;
107479
107472
  }
107480
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107481
- // import("./blah")
107473
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107474
+ // import(x)
107482
107475
  // emit as
107483
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107476
+ // var _a;
107477
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107484
107478
  // We have to wrap require in then callback so that require is done in asynchronously
107485
107479
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107486
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107487
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107480
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107481
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107482
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107483
+ /*typeArguments*/ undefined,
107484
+ /*argumentsArray*/ []);
107485
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107486
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107488
107487
  if (ts.getESModuleInterop(compilerOptions)) {
107489
107488
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107490
107489
  }
@@ -107505,14 +107504,9 @@ var ts;
107505
107504
  /*typeParameters*/ undefined,
107506
107505
  /*parameters*/ [],
107507
107506
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107508
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107509
- // that this new function expression indicates it captures 'this' so that the
107510
- // es2015 transformer will properly substitute 'this' with '_this'.
107511
- if (containsLexicalThis) {
107512
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107513
- }
107514
107507
  }
107515
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107508
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107509
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107516
107510
  }
107517
107511
  function getHelperExpressionForExport(node, innerExpr) {
107518
107512
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -21719,13 +21719,11 @@ var ts;
21719
21719
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21720
21720
  */
21721
21721
  function createBaseNodeFactory() {
21722
- // tslint:disable variable-name
21723
21722
  var NodeConstructor;
21724
21723
  var TokenConstructor;
21725
21724
  var IdentifierConstructor;
21726
21725
  var PrivateIdentifierConstructor;
21727
21726
  var SourceFileConstructor;
21728
- // tslint:enable variable-name
21729
21727
  return {
21730
21728
  createBaseSourceFileNode: createBaseSourceFileNode,
21731
21729
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -27657,11 +27655,9 @@ var ts;
27657
27655
  rawTextScanner.setText("`" + rawText + "`");
27658
27656
  break;
27659
27657
  case 15 /* SyntaxKind.TemplateHead */:
27660
- // tslint:disable-next-line no-invalid-template-strings
27661
27658
  rawTextScanner.setText("`" + rawText + "${");
27662
27659
  break;
27663
27660
  case 16 /* SyntaxKind.TemplateMiddle */:
27664
- // tslint:disable-next-line no-invalid-template-strings
27665
27661
  rawTextScanner.setText("}" + rawText + "${");
27666
27662
  break;
27667
27663
  case 17 /* SyntaxKind.TemplateTail */:
@@ -28020,7 +28016,6 @@ var ts;
28020
28016
  return node;
28021
28017
  }
28022
28018
  ts.createInputFiles = createInputFiles;
28023
- // tslint:disable-next-line variable-name
28024
28019
  var SourceMapSource;
28025
28020
  /**
28026
28021
  * Create an external source map source file reference
@@ -32154,13 +32149,11 @@ var ts;
32154
32149
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32155
32150
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32156
32151
  // capture constructors in 'initializeState' to avoid null checks
32157
- // tslint:disable variable-name
32158
32152
  var NodeConstructor;
32159
32153
  var TokenConstructor;
32160
32154
  var IdentifierConstructor;
32161
32155
  var PrivateIdentifierConstructor;
32162
32156
  var SourceFileConstructor;
32163
- // tslint:enable variable-name
32164
32157
  function countNode(node) {
32165
32158
  nodeCount++;
32166
32159
  return node;
@@ -72130,7 +72123,7 @@ var ts;
72130
72123
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72131
72124
  }
72132
72125
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
72133
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72126
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72134
72127
  }
72135
72128
  else {
72136
72129
  if (strictNullChecks) {
@@ -72411,7 +72404,7 @@ var ts;
72411
72404
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72412
72405
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72413
72406
  }
72414
- function narrowByInKeyword(type, nameType, assumeTrue) {
72407
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72415
72408
  var name = getPropertyNameFromType(nameType);
72416
72409
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72417
72410
  if (isKnownProperty) {
@@ -72492,7 +72485,7 @@ var ts;
72492
72485
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72493
72486
  }
72494
72487
  if (isMatchingReference(reference, target)) {
72495
- return narrowByInKeyword(type, leftType, assumeTrue);
72488
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72496
72489
  }
72497
72490
  }
72498
72491
  break;
@@ -72681,7 +72674,7 @@ var ts;
72681
72674
  neverType;
72682
72675
  });
72683
72676
  }
72684
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72677
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72685
72678
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72686
72679
  if (!witnesses) {
72687
72680
  return type;
@@ -83048,7 +83041,7 @@ var ts;
83048
83041
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
83049
83042
  // or is promise-like.
83050
83043
  if (baseConstraint ?
83051
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83044
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
83052
83045
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
83053
83046
  return true;
83054
83047
  }
@@ -107394,7 +107387,7 @@ var ts;
107394
107387
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107395
107388
  case ts.ModuleKind.CommonJS:
107396
107389
  default:
107397
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107390
+ return createImportCallExpressionCommonJS(argument);
107398
107391
  }
107399
107392
  }
107400
107393
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107417,7 +107410,7 @@ var ts;
107417
107410
  return factory.createConditionalExpression(
107418
107411
  /*condition*/ factory.createIdentifier("__syncRequire"),
107419
107412
  /*questionToken*/ undefined,
107420
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107413
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107421
107414
  /*colonToken*/ undefined,
107422
107415
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107423
107416
  }
@@ -107426,7 +107419,7 @@ var ts;
107426
107419
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107427
107420
  /*condition*/ factory.createIdentifier("__syncRequire"),
107428
107421
  /*questionToken*/ undefined,
107429
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107422
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107430
107423
  /*colonToken*/ undefined,
107431
107424
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107432
107425
  }
@@ -107476,14 +107469,20 @@ var ts;
107476
107469
  }
107477
107470
  return promise;
107478
107471
  }
107479
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107480
- // import("./blah")
107472
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107473
+ // import(x)
107481
107474
  // emit as
107482
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107475
+ // var _a;
107476
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107483
107477
  // We have to wrap require in then callback so that require is done in asynchronously
107484
107478
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107485
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107486
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107479
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107480
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107481
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107482
+ /*typeArguments*/ undefined,
107483
+ /*argumentsArray*/ []);
107484
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107485
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107487
107486
  if (ts.getESModuleInterop(compilerOptions)) {
107488
107487
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107489
107488
  }
@@ -107504,14 +107503,9 @@ var ts;
107504
107503
  /*typeParameters*/ undefined,
107505
107504
  /*parameters*/ [],
107506
107505
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107507
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107508
- // that this new function expression indicates it captures 'this' so that the
107509
- // es2015 transformer will properly substitute 'this' with '_this'.
107510
- if (containsLexicalThis) {
107511
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107512
- }
107513
107506
  }
107514
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107507
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107508
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107515
107509
  }
107516
107510
  function getHelperExpressionForExport(node, innerExpr) {
107517
107511
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
package/lib/typescript.js CHANGED
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -21710,13 +21710,11 @@ var ts;
21710
21710
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21711
21711
  */
21712
21712
  function createBaseNodeFactory() {
21713
- // tslint:disable variable-name
21714
21713
  var NodeConstructor;
21715
21714
  var TokenConstructor;
21716
21715
  var IdentifierConstructor;
21717
21716
  var PrivateIdentifierConstructor;
21718
21717
  var SourceFileConstructor;
21719
- // tslint:enable variable-name
21720
21718
  return {
21721
21719
  createBaseSourceFileNode: createBaseSourceFileNode,
21722
21720
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -27648,11 +27646,9 @@ var ts;
27648
27646
  rawTextScanner.setText("`" + rawText + "`");
27649
27647
  break;
27650
27648
  case 15 /* SyntaxKind.TemplateHead */:
27651
- // tslint:disable-next-line no-invalid-template-strings
27652
27649
  rawTextScanner.setText("`" + rawText + "${");
27653
27650
  break;
27654
27651
  case 16 /* SyntaxKind.TemplateMiddle */:
27655
- // tslint:disable-next-line no-invalid-template-strings
27656
27652
  rawTextScanner.setText("}" + rawText + "${");
27657
27653
  break;
27658
27654
  case 17 /* SyntaxKind.TemplateTail */:
@@ -28011,7 +28007,6 @@ var ts;
28011
28007
  return node;
28012
28008
  }
28013
28009
  ts.createInputFiles = createInputFiles;
28014
- // tslint:disable-next-line variable-name
28015
28010
  var SourceMapSource;
28016
28011
  /**
28017
28012
  * Create an external source map source file reference
@@ -32145,13 +32140,11 @@ var ts;
32145
32140
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32146
32141
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32147
32142
  // capture constructors in 'initializeState' to avoid null checks
32148
- // tslint:disable variable-name
32149
32143
  var NodeConstructor;
32150
32144
  var TokenConstructor;
32151
32145
  var IdentifierConstructor;
32152
32146
  var PrivateIdentifierConstructor;
32153
32147
  var SourceFileConstructor;
32154
- // tslint:enable variable-name
32155
32148
  function countNode(node) {
32156
32149
  nodeCount++;
32157
32150
  return node;
@@ -72121,7 +72114,7 @@ var ts;
72121
72114
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72122
72115
  }
72123
72116
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
72124
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72117
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72125
72118
  }
72126
72119
  else {
72127
72120
  if (strictNullChecks) {
@@ -72402,7 +72395,7 @@ var ts;
72402
72395
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72403
72396
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72404
72397
  }
72405
- function narrowByInKeyword(type, nameType, assumeTrue) {
72398
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72406
72399
  var name = getPropertyNameFromType(nameType);
72407
72400
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72408
72401
  if (isKnownProperty) {
@@ -72483,7 +72476,7 @@ var ts;
72483
72476
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72484
72477
  }
72485
72478
  if (isMatchingReference(reference, target)) {
72486
- return narrowByInKeyword(type, leftType, assumeTrue);
72479
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72487
72480
  }
72488
72481
  }
72489
72482
  break;
@@ -72672,7 +72665,7 @@ var ts;
72672
72665
  neverType;
72673
72666
  });
72674
72667
  }
72675
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72668
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72676
72669
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72677
72670
  if (!witnesses) {
72678
72671
  return type;
@@ -83039,7 +83032,7 @@ var ts;
83039
83032
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
83040
83033
  // or is promise-like.
83041
83034
  if (baseConstraint ?
83042
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83035
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
83043
83036
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
83044
83037
  return true;
83045
83038
  }
@@ -107385,7 +107378,7 @@ var ts;
107385
107378
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107386
107379
  case ts.ModuleKind.CommonJS:
107387
107380
  default:
107388
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107381
+ return createImportCallExpressionCommonJS(argument);
107389
107382
  }
107390
107383
  }
107391
107384
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107408,7 +107401,7 @@ var ts;
107408
107401
  return factory.createConditionalExpression(
107409
107402
  /*condition*/ factory.createIdentifier("__syncRequire"),
107410
107403
  /*questionToken*/ undefined,
107411
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107404
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107412
107405
  /*colonToken*/ undefined,
107413
107406
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107414
107407
  }
@@ -107417,7 +107410,7 @@ var ts;
107417
107410
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107418
107411
  /*condition*/ factory.createIdentifier("__syncRequire"),
107419
107412
  /*questionToken*/ undefined,
107420
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107413
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107421
107414
  /*colonToken*/ undefined,
107422
107415
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107423
107416
  }
@@ -107467,14 +107460,20 @@ var ts;
107467
107460
  }
107468
107461
  return promise;
107469
107462
  }
107470
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107471
- // import("./blah")
107463
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107464
+ // import(x)
107472
107465
  // emit as
107473
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107466
+ // var _a;
107467
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107474
107468
  // We have to wrap require in then callback so that require is done in asynchronously
107475
107469
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107476
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107477
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107470
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107471
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107472
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107473
+ /*typeArguments*/ undefined,
107474
+ /*argumentsArray*/ []);
107475
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107476
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107478
107477
  if (ts.getESModuleInterop(compilerOptions)) {
107479
107478
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107480
107479
  }
@@ -107495,14 +107494,9 @@ var ts;
107495
107494
  /*typeParameters*/ undefined,
107496
107495
  /*parameters*/ [],
107497
107496
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107498
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107499
- // that this new function expression indicates it captures 'this' so that the
107500
- // es2015 transformer will properly substitute 'this' with '_this'.
107501
- if (containsLexicalThis) {
107502
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107503
- }
107504
107497
  }
107505
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107498
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107499
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107506
107500
  }
107507
107501
  function getHelperExpressionForExport(node, innerExpr) {
107508
107502
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -21710,13 +21710,11 @@ var ts;
21710
21710
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21711
21711
  */
21712
21712
  function createBaseNodeFactory() {
21713
- // tslint:disable variable-name
21714
21713
  var NodeConstructor;
21715
21714
  var TokenConstructor;
21716
21715
  var IdentifierConstructor;
21717
21716
  var PrivateIdentifierConstructor;
21718
21717
  var SourceFileConstructor;
21719
- // tslint:enable variable-name
21720
21718
  return {
21721
21719
  createBaseSourceFileNode: createBaseSourceFileNode,
21722
21720
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -27648,11 +27646,9 @@ var ts;
27648
27646
  rawTextScanner.setText("`" + rawText + "`");
27649
27647
  break;
27650
27648
  case 15 /* SyntaxKind.TemplateHead */:
27651
- // tslint:disable-next-line no-invalid-template-strings
27652
27649
  rawTextScanner.setText("`" + rawText + "${");
27653
27650
  break;
27654
27651
  case 16 /* SyntaxKind.TemplateMiddle */:
27655
- // tslint:disable-next-line no-invalid-template-strings
27656
27652
  rawTextScanner.setText("}" + rawText + "${");
27657
27653
  break;
27658
27654
  case 17 /* SyntaxKind.TemplateTail */:
@@ -28011,7 +28007,6 @@ var ts;
28011
28007
  return node;
28012
28008
  }
28013
28009
  ts.createInputFiles = createInputFiles;
28014
- // tslint:disable-next-line variable-name
28015
28010
  var SourceMapSource;
28016
28011
  /**
28017
28012
  * Create an external source map source file reference
@@ -32145,13 +32140,11 @@ var ts;
32145
32140
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32146
32141
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32147
32142
  // capture constructors in 'initializeState' to avoid null checks
32148
- // tslint:disable variable-name
32149
32143
  var NodeConstructor;
32150
32144
  var TokenConstructor;
32151
32145
  var IdentifierConstructor;
32152
32146
  var PrivateIdentifierConstructor;
32153
32147
  var SourceFileConstructor;
32154
- // tslint:enable variable-name
32155
32148
  function countNode(node) {
32156
32149
  nodeCount++;
32157
32150
  return node;
@@ -72121,7 +72114,7 @@ var ts;
72121
72114
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72122
72115
  }
72123
72116
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
72124
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72117
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72125
72118
  }
72126
72119
  else {
72127
72120
  if (strictNullChecks) {
@@ -72402,7 +72395,7 @@ var ts;
72402
72395
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72403
72396
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72404
72397
  }
72405
- function narrowByInKeyword(type, nameType, assumeTrue) {
72398
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72406
72399
  var name = getPropertyNameFromType(nameType);
72407
72400
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72408
72401
  if (isKnownProperty) {
@@ -72483,7 +72476,7 @@ var ts;
72483
72476
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72484
72477
  }
72485
72478
  if (isMatchingReference(reference, target)) {
72486
- return narrowByInKeyword(type, leftType, assumeTrue);
72479
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72487
72480
  }
72488
72481
  }
72489
72482
  break;
@@ -72672,7 +72665,7 @@ var ts;
72672
72665
  neverType;
72673
72666
  });
72674
72667
  }
72675
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72668
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72676
72669
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72677
72670
  if (!witnesses) {
72678
72671
  return type;
@@ -83039,7 +83032,7 @@ var ts;
83039
83032
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
83040
83033
  // or is promise-like.
83041
83034
  if (baseConstraint ?
83042
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83035
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
83043
83036
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
83044
83037
  return true;
83045
83038
  }
@@ -107385,7 +107378,7 @@ var ts;
107385
107378
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107386
107379
  case ts.ModuleKind.CommonJS:
107387
107380
  default:
107388
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107381
+ return createImportCallExpressionCommonJS(argument);
107389
107382
  }
107390
107383
  }
107391
107384
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107408,7 +107401,7 @@ var ts;
107408
107401
  return factory.createConditionalExpression(
107409
107402
  /*condition*/ factory.createIdentifier("__syncRequire"),
107410
107403
  /*questionToken*/ undefined,
107411
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107404
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107412
107405
  /*colonToken*/ undefined,
107413
107406
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107414
107407
  }
@@ -107417,7 +107410,7 @@ var ts;
107417
107410
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107418
107411
  /*condition*/ factory.createIdentifier("__syncRequire"),
107419
107412
  /*questionToken*/ undefined,
107420
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107413
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107421
107414
  /*colonToken*/ undefined,
107422
107415
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107423
107416
  }
@@ -107467,14 +107460,20 @@ var ts;
107467
107460
  }
107468
107461
  return promise;
107469
107462
  }
107470
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107471
- // import("./blah")
107463
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107464
+ // import(x)
107472
107465
  // emit as
107473
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107466
+ // var _a;
107467
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107474
107468
  // We have to wrap require in then callback so that require is done in asynchronously
107475
107469
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107476
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107477
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107470
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107471
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107472
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107473
+ /*typeArguments*/ undefined,
107474
+ /*argumentsArray*/ []);
107475
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107476
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107478
107477
  if (ts.getESModuleInterop(compilerOptions)) {
107479
107478
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107480
107479
  }
@@ -107495,14 +107494,9 @@ var ts;
107495
107494
  /*typeParameters*/ undefined,
107496
107495
  /*parameters*/ [],
107497
107496
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107498
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107499
- // that this new function expression indicates it captures 'this' so that the
107500
- // es2015 transformer will properly substitute 'this' with '_this'.
107501
- if (containsLexicalThis) {
107502
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107503
- }
107504
107497
  }
107505
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107498
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107499
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107506
107500
  }
107507
107501
  function getHelperExpressionForExport(node, innerExpr) {
107508
107502
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -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 = "".concat(ts.versionMajorMinor, ".0-dev.20221018");
92
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221019");
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -21700,13 +21700,11 @@ var ts;
21700
21700
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21701
21701
  */
21702
21702
  function createBaseNodeFactory() {
21703
- // tslint:disable variable-name
21704
21703
  var NodeConstructor;
21705
21704
  var TokenConstructor;
21706
21705
  var IdentifierConstructor;
21707
21706
  var PrivateIdentifierConstructor;
21708
21707
  var SourceFileConstructor;
21709
- // tslint:enable variable-name
21710
21708
  return {
21711
21709
  createBaseSourceFileNode: createBaseSourceFileNode,
21712
21710
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -27638,11 +27636,9 @@ var ts;
27638
27636
  rawTextScanner.setText("`" + rawText + "`");
27639
27637
  break;
27640
27638
  case 15 /* SyntaxKind.TemplateHead */:
27641
- // tslint:disable-next-line no-invalid-template-strings
27642
27639
  rawTextScanner.setText("`" + rawText + "${");
27643
27640
  break;
27644
27641
  case 16 /* SyntaxKind.TemplateMiddle */:
27645
- // tslint:disable-next-line no-invalid-template-strings
27646
27642
  rawTextScanner.setText("}" + rawText + "${");
27647
27643
  break;
27648
27644
  case 17 /* SyntaxKind.TemplateTail */:
@@ -28001,7 +27997,6 @@ var ts;
28001
27997
  return node;
28002
27998
  }
28003
27999
  ts.createInputFiles = createInputFiles;
28004
- // tslint:disable-next-line variable-name
28005
28000
  var SourceMapSource;
28006
28001
  /**
28007
28002
  * Create an external source map source file reference
@@ -32135,13 +32130,11 @@ var ts;
32135
32130
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32136
32131
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32137
32132
  // capture constructors in 'initializeState' to avoid null checks
32138
- // tslint:disable variable-name
32139
32133
  var NodeConstructor;
32140
32134
  var TokenConstructor;
32141
32135
  var IdentifierConstructor;
32142
32136
  var PrivateIdentifierConstructor;
32143
32137
  var SourceFileConstructor;
32144
- // tslint:enable variable-name
32145
32138
  function countNode(node) {
32146
32139
  nodeCount++;
32147
32140
  return node;
@@ -72111,7 +72104,7 @@ var ts;
72111
72104
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72112
72105
  }
72113
72106
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
72114
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72107
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72115
72108
  }
72116
72109
  else {
72117
72110
  if (strictNullChecks) {
@@ -72392,7 +72385,7 @@ var ts;
72392
72385
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72393
72386
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72394
72387
  }
72395
- function narrowByInKeyword(type, nameType, assumeTrue) {
72388
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72396
72389
  var name = getPropertyNameFromType(nameType);
72397
72390
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72398
72391
  if (isKnownProperty) {
@@ -72473,7 +72466,7 @@ var ts;
72473
72466
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72474
72467
  }
72475
72468
  if (isMatchingReference(reference, target)) {
72476
- return narrowByInKeyword(type, leftType, assumeTrue);
72469
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72477
72470
  }
72478
72471
  }
72479
72472
  break;
@@ -72662,7 +72655,7 @@ var ts;
72662
72655
  neverType;
72663
72656
  });
72664
72657
  }
72665
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72658
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72666
72659
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72667
72660
  if (!witnesses) {
72668
72661
  return type;
@@ -83029,7 +83022,7 @@ var ts;
83029
83022
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
83030
83023
  // or is promise-like.
83031
83024
  if (baseConstraint ?
83032
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83025
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
83033
83026
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
83034
83027
  return true;
83035
83028
  }
@@ -107375,7 +107368,7 @@ var ts;
107375
107368
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107376
107369
  case ts.ModuleKind.CommonJS:
107377
107370
  default:
107378
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107371
+ return createImportCallExpressionCommonJS(argument);
107379
107372
  }
107380
107373
  }
107381
107374
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107398,7 +107391,7 @@ var ts;
107398
107391
  return factory.createConditionalExpression(
107399
107392
  /*condition*/ factory.createIdentifier("__syncRequire"),
107400
107393
  /*questionToken*/ undefined,
107401
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107394
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107402
107395
  /*colonToken*/ undefined,
107403
107396
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107404
107397
  }
@@ -107407,7 +107400,7 @@ var ts;
107407
107400
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107408
107401
  /*condition*/ factory.createIdentifier("__syncRequire"),
107409
107402
  /*questionToken*/ undefined,
107410
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107403
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107411
107404
  /*colonToken*/ undefined,
107412
107405
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107413
107406
  }
@@ -107457,14 +107450,20 @@ var ts;
107457
107450
  }
107458
107451
  return promise;
107459
107452
  }
107460
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107461
- // import("./blah")
107453
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107454
+ // import(x)
107462
107455
  // emit as
107463
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107456
+ // var _a;
107457
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107464
107458
  // We have to wrap require in then callback so that require is done in asynchronously
107465
107459
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107466
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107467
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107460
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107461
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107462
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107463
+ /*typeArguments*/ undefined,
107464
+ /*argumentsArray*/ []);
107465
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107466
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107468
107467
  if (ts.getESModuleInterop(compilerOptions)) {
107469
107468
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107470
107469
  }
@@ -107485,14 +107484,9 @@ var ts;
107485
107484
  /*typeParameters*/ undefined,
107486
107485
  /*parameters*/ [],
107487
107486
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107488
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107489
- // that this new function expression indicates it captures 'this' so that the
107490
- // es2015 transformer will properly substitute 'this' with '_this'.
107491
- if (containsLexicalThis) {
107492
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107493
- }
107494
107487
  }
107495
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107488
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107489
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107496
107490
  }
107497
107491
  function getHelperExpressionForExport(node, innerExpr) {
107498
107492
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
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.9.0-dev.20221018",
5
+ "version": "4.9.0-dev.20221019",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [