typescript 4.9.0-dev.20221006 → 4.9.0-dev.20221011

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.
@@ -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.20221006");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221011");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -59863,7 +59863,20 @@ var ts;
59863
59863
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59864
59864
  }
59865
59865
  function isGenericMappedType(type) {
59866
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59866
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59867
+ var constraint = getConstraintTypeFromMappedType(type);
59868
+ if (isGenericIndexType(constraint)) {
59869
+ return true;
59870
+ }
59871
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59872
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59873
+ // type and check whether the resulting type is generic.
59874
+ var nameType = getNameTypeFromMappedType(type);
59875
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59876
+ return true;
59877
+ }
59878
+ }
59879
+ return false;
59867
59880
  }
59868
59881
  function resolveStructuredTypeMembers(type) {
59869
59882
  if (!type.members) {
@@ -63183,8 +63196,14 @@ var ts;
63183
63196
  return getStringLiteralType(text);
63184
63197
  }
63185
63198
  newTexts.push(text);
63186
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63187
- return stringType;
63199
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63200
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63201
+ return stringType;
63202
+ }
63203
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63204
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63205
+ return newTypes[0];
63206
+ }
63188
63207
  }
63189
63208
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63190
63209
  var type = templateLiteralTypes.get(id);
@@ -63243,12 +63262,14 @@ var ts;
63243
63262
  }
63244
63263
  function getStringMappingType(symbol, type) {
63245
63264
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63246
- // Mapping<Mapping<T>> === Mapping<T>
63247
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63248
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63249
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63250
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63251
- type;
63265
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63266
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63267
+ // Mapping<Mapping<T>> === Mapping<T>
63268
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63269
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ || type.flags & 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63270
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63271
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63272
+ type;
63252
63273
  }
63253
63274
  function applyStringMapping(symbol, str) {
63254
63275
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63527,10 +63548,11 @@ var ts;
63527
63548
  accessNode;
63528
63549
  }
63529
63550
  function isPatternLiteralPlaceholderType(type) {
63530
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63551
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63531
63552
  }
63532
63553
  function isPatternLiteralType(type) {
63533
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63554
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63555
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63534
63556
  }
63535
63557
  function isGenericType(type) {
63536
63558
  return !!getGenericObjectFlags(type);
@@ -69717,7 +69739,7 @@ var ts;
69717
69739
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69718
69740
  }
69719
69741
  function isMemberOfStringMapping(source, target) {
69720
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69742
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69721
69743
  return true;
69722
69744
  }
69723
69745
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
@@ -146623,8 +146645,8 @@ var ts;
146623
146645
  }
146624
146646
  if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
146625
146647
  var stack = [ts.scanner.getToken()];
146626
- var token = ts.scanner.scan();
146627
146648
  loop: while (ts.length(stack)) {
146649
+ var token = ts.scanner.scan();
146628
146650
  switch (token) {
146629
146651
  case 1 /* SyntaxKind.EndOfFileToken */:
146630
146652
  break loop;
@@ -146652,7 +146674,6 @@ var ts;
146652
146674
  }
146653
146675
  break;
146654
146676
  }
146655
- token = ts.scanner.scan();
146656
146677
  }
146657
146678
  nextToken();
146658
146679
  }
@@ -164141,7 +164162,6 @@ var ts;
164141
164162
  var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
164142
164163
  // Do the same for the ending position
164143
164164
  var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
164144
- var declarations = [];
164145
164165
  // We'll modify these flags as we walk the tree to collect data
164146
164166
  // about what things need to be done as part of the extraction.
164147
164167
  var rangeFacts = RangeFacts.None;
@@ -164184,7 +164204,7 @@ var ts;
164184
164204
  // the expression.
164185
164205
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
164186
164206
  }
164187
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
164207
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
164188
164208
  }
164189
164209
  if (ts.isReturnStatement(start) && !start.expression) {
164190
164210
  // Makes no sense to extract an expression-less return statement.
@@ -164196,7 +164216,7 @@ var ts;
164196
164216
  if (errors) {
164197
164217
  return { errors: errors };
164198
164218
  }
164199
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
164219
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
164200
164220
  /**
164201
164221
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
164202
164222
  * @param node The unrefined extraction node.
@@ -164208,10 +164228,10 @@ var ts;
164208
164228
  }
164209
164229
  }
164210
164230
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
164211
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164231
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164212
164232
  var numInitializers = 0;
164213
164233
  var lastInitializer = void 0;
164214
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
164234
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
164215
164235
  var declaration = declarations_5[_i];
164216
164236
  if (declaration.initializer) {
164217
164237
  numInitializers++;
@@ -164311,7 +164331,6 @@ var ts;
164311
164331
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
164312
164332
  return true;
164313
164333
  }
164314
- declarations.push(node.symbol);
164315
164334
  }
164316
164335
  // Some things can't be extracted in certain situations
164317
164336
  switch (node.kind) {
@@ -168357,8 +168376,8 @@ var ts;
168357
168376
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
168358
168377
  }
168359
168378
  };
168360
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168361
- var declaration = declarations_7[_i];
168379
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
168380
+ var declaration = declarations_6[_i];
168362
168381
  _loop_20(declaration);
168363
168382
  }
168364
168383
  }
@@ -168384,8 +168403,8 @@ var ts;
168384
168403
  if (inheritedDocs)
168385
168404
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
168386
168405
  };
168387
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
168388
- var declaration = declarations_8[_i];
168406
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168407
+ var declaration = declarations_7[_i];
168389
168408
  _loop_21(declaration);
168390
168409
  }
168391
168410
  }
@@ -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.20221006");
92
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221011");
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -59853,7 +59853,20 @@ var ts;
59853
59853
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59854
59854
  }
59855
59855
  function isGenericMappedType(type) {
59856
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59856
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59857
+ var constraint = getConstraintTypeFromMappedType(type);
59858
+ if (isGenericIndexType(constraint)) {
59859
+ return true;
59860
+ }
59861
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59862
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59863
+ // type and check whether the resulting type is generic.
59864
+ var nameType = getNameTypeFromMappedType(type);
59865
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59866
+ return true;
59867
+ }
59868
+ }
59869
+ return false;
59857
59870
  }
59858
59871
  function resolveStructuredTypeMembers(type) {
59859
59872
  if (!type.members) {
@@ -63173,8 +63186,14 @@ var ts;
63173
63186
  return getStringLiteralType(text);
63174
63187
  }
63175
63188
  newTexts.push(text);
63176
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63177
- return stringType;
63189
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63190
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63191
+ return stringType;
63192
+ }
63193
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63194
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63195
+ return newTypes[0];
63196
+ }
63178
63197
  }
63179
63198
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63180
63199
  var type = templateLiteralTypes.get(id);
@@ -63233,12 +63252,14 @@ var ts;
63233
63252
  }
63234
63253
  function getStringMappingType(symbol, type) {
63235
63254
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63236
- // Mapping<Mapping<T>> === Mapping<T>
63237
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63238
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63239
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63240
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63241
- type;
63255
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63256
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63257
+ // Mapping<Mapping<T>> === Mapping<T>
63258
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63259
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ || type.flags & 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63260
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63261
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63262
+ type;
63242
63263
  }
63243
63264
  function applyStringMapping(symbol, str) {
63244
63265
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63517,10 +63538,11 @@ var ts;
63517
63538
  accessNode;
63518
63539
  }
63519
63540
  function isPatternLiteralPlaceholderType(type) {
63520
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63541
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63521
63542
  }
63522
63543
  function isPatternLiteralType(type) {
63523
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63544
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63545
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63524
63546
  }
63525
63547
  function isGenericType(type) {
63526
63548
  return !!getGenericObjectFlags(type);
@@ -69707,7 +69729,7 @@ var ts;
69707
69729
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69708
69730
  }
69709
69731
  function isMemberOfStringMapping(source, target) {
69710
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69732
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69711
69733
  return true;
69712
69734
  }
69713
69735
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
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.20221006",
5
+ "version": "4.9.0-dev.20221011",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -41,6 +41,7 @@
41
41
  "devDependencies": {
42
42
  "@octokit/rest": "latest",
43
43
  "@types/chai": "latest",
44
+ "@types/fancy-log": "^2.0.0",
44
45
  "@types/fs-extra": "^9.0.13",
45
46
  "@types/glob": "latest",
46
47
  "@types/gulp": "^4.0.9",
@@ -55,8 +56,8 @@
55
56
  "@types/mocha": "latest",
56
57
  "@types/ms": "latest",
57
58
  "@types/node": "latest",
58
- "@types/node-fetch": "^2.6.2",
59
59
  "@types/source-map-support": "latest",
60
+ "@types/which": "^2.0.1",
60
61
  "@types/xml2js": "^0.4.11",
61
62
  "@typescript-eslint/eslint-plugin": "^5.33.1",
62
63
  "@typescript-eslint/parser": "^5.33.1",
@@ -87,7 +88,7 @@
87
88
  "mocha": "latest",
88
89
  "mocha-fivemat-progress-reporter": "latest",
89
90
  "ms": "^2.1.3",
90
- "node-fetch": "^2.6.7",
91
+ "node-fetch": "^3.2.10",
91
92
  "source-map-support": "latest",
92
93
  "typescript": "^4.8.4",
93
94
  "vinyl": "latest",
@@ -107,7 +108,7 @@
107
108
  "clean": "gulp clean",
108
109
  "gulp": "gulp",
109
110
  "lint": "gulp lint",
110
- "setup-hooks": "node scripts/link-hooks.js"
111
+ "setup-hooks": "node scripts/link-hooks.mjs"
111
112
  },
112
113
  "browser": {
113
114
  "fs": false,