typescript 4.8.0-dev.20220726 → 4.8.0-dev.20220729

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,23 +19,112 @@ and limitations under the License.
19
19
 
20
20
 
21
21
  interface ProxyHandler<T extends object> {
22
+ /**
23
+ * A trap method for a function call.
24
+ * @param target The original callable object which is being proxied.
25
+ */
22
26
  apply?(target: T, thisArg: any, argArray: any[]): any;
27
+
28
+ /**
29
+ * A trap for the `new` operator.
30
+ * @param target The original object which is being proxied.
31
+ * @param newTarget The constructor that was originally called.
32
+ */
23
33
  construct?(target: T, argArray: any[], newTarget: Function): object;
24
- defineProperty?(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean;
34
+
35
+ /**
36
+ * A trap for `Object.defineProperty()`.
37
+ * @param target The original object which is being proxied.
38
+ * @returns A `Boolean` indicating whether or not the property has been defined.
39
+ */
40
+ defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
41
+
42
+ /**
43
+ * A trap for the `delete` operator.
44
+ * @param target The original object which is being proxied.
45
+ * @param p The name or `Symbol` of the property to delete.
46
+ * @returns A `Boolean` indicating whether or not the property was deleted.
47
+ */
25
48
  deleteProperty?(target: T, p: string | symbol): boolean;
49
+
50
+ /**
51
+ * A trap for getting a property value.
52
+ * @param target The original object which is being proxied.
53
+ * @param p The name or `Symbol` of the property to get.
54
+ * @param receiver The proxy or an object that inherits from the proxy.
55
+ */
26
56
  get?(target: T, p: string | symbol, receiver: any): any;
57
+
58
+ /**
59
+ * A trap for `Object.getOwnPropertyDescriptor()`.
60
+ * @param target The original object which is being proxied.
61
+ * @param p The name of the property whose description should be retrieved.
62
+ */
27
63
  getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
64
+
65
+ /**
66
+ * A trap for the `[[GetPrototypeOf]]` internal method.
67
+ * @param target The original object which is being proxied.
68
+ */
28
69
  getPrototypeOf?(target: T): object | null;
70
+
71
+ /**
72
+ * A trap for the `in` operator.
73
+ * @param target The original object which is being proxied.
74
+ * @param p The name or `Symbol` of the property to check for existence.
75
+ */
29
76
  has?(target: T, p: string | symbol): boolean;
77
+
78
+ /**
79
+ * A trap for `Object.isExtensible()`.
80
+ * @param target The original object which is being proxied.
81
+ */
30
82
  isExtensible?(target: T): boolean;
83
+
84
+ /**
85
+ * A trap for `Reflect.ownKeys()`.
86
+ * @param target The original object which is being proxied.
87
+ */
31
88
  ownKeys?(target: T): ArrayLike<string | symbol>;
89
+
90
+ /**
91
+ * A trap for `Object.preventExtensions()`.
92
+ * @param target The original object which is being proxied.
93
+ */
32
94
  preventExtensions?(target: T): boolean;
33
- set?(target: T, p: string | symbol, value: any, receiver: any): boolean;
95
+
96
+ /**
97
+ * A trap for setting a property value.
98
+ * @param target The original object which is being proxied.
99
+ * @param p The name or `Symbol` of the property to set.
100
+ * @param receiver The object to which the assignment was originally directed.
101
+ * @returns `A `Boolean` indicating whether or not the property was set.
102
+ */
103
+ set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
104
+
105
+ /**
106
+ * A trap for `Object.setPrototypeOf()`.
107
+ * @param target The original object which is being proxied.
108
+ * @param newPrototype The object's new prototype or `null`.
109
+ */
34
110
  setPrototypeOf?(target: T, v: object | null): boolean;
35
111
  }
36
112
 
37
113
  interface ProxyConstructor {
114
+ /**
115
+ * Creates a revocable Proxy object.
116
+ * @param target A target object to wrap with Proxy.
117
+ * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
118
+ */
38
119
  revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
120
+
121
+ /**
122
+ * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
123
+ * original object, but which may redefine fundamental Object operations like getting, setting, and defining
124
+ * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
125
+ * @param target A target object to wrap with Proxy.
126
+ * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
127
+ */
39
128
  new <T extends object>(target: T, handler: ProxyHandler<T>): T;
40
129
  }
41
130
  declare var Proxy: ProxyConstructor;
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.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220726";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220729";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -1484,6 +1484,10 @@ var ts;
1484
1484
  ts.cast = cast;
1485
1485
  function noop(_) { }
1486
1486
  ts.noop = noop;
1487
+ ts.noopPush = {
1488
+ push: noop,
1489
+ length: 0
1490
+ };
1487
1491
  function returnFalse() {
1488
1492
  return false;
1489
1493
  }
@@ -5731,6 +5735,7 @@ var ts;
5731
5735
  Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
5732
5736
  auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
5733
5737
  An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
5738
+ Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
5734
5739
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
5735
5740
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
5736
5741
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true),
@@ -5944,6 +5949,7 @@ var ts;
5944
5949
  Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
5945
5950
  Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
5946
5951
  Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
5952
+ A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."),
5947
5953
  Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
5948
5954
  All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
5949
5955
  Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
@@ -26880,7 +26886,9 @@ var ts;
26880
26886
  case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26881
26887
  case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26882
26888
  case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26883
- default: return [undefined];
26889
+ case 24: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected);
26890
+ case 25: return ts.Debug.fail("ParsingContext.Count used as a context");
26891
+ default: ts.Debug.assertNever(context);
26884
26892
  }
26885
26893
  }
26886
26894
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
@@ -35243,18 +35251,7 @@ var ts;
35243
35251
  NodeResolutionFeatures.None;
35244
35252
  }
35245
35253
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
35246
- var moduleResolutionState = {
35247
- compilerOptions: options,
35248
- host: host,
35249
- traceEnabled: isTraceEnabled(options, host),
35250
- failedLookupLocations: [],
35251
- affectingLocations: [],
35252
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
35253
- conditions: ts.emptyArray,
35254
- features: NodeResolutionFeatures.None,
35255
- requestContainingDirectory: containingDirectory,
35256
- reportDiagnostic: ts.noop
35257
- };
35254
+ var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
35258
35255
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
35259
35256
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
35260
35257
  var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
@@ -36054,18 +36051,9 @@ var ts;
36054
36051
  var entrypoints;
36055
36052
  var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
36056
36053
  var features = getDefaultNodeResolutionFeatures(options);
36057
- var requireState = {
36058
- compilerOptions: options,
36059
- host: host,
36060
- traceEnabled: isTraceEnabled(options, host),
36061
- failedLookupLocations: [],
36062
- affectingLocations: [],
36063
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
36064
- conditions: ["node", "require", "types"],
36065
- features: features,
36066
- requestContainingDirectory: packageJsonInfo.packageDirectory,
36067
- reportDiagnostic: ts.noop
36068
- };
36054
+ var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
36055
+ requireState.conditions = ["node", "require", "types"];
36056
+ requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
36069
36057
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
36070
36058
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
36071
36059
  if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
@@ -36135,19 +36123,22 @@ var ts;
36135
36123
  }
36136
36124
  }
36137
36125
  }
36138
- function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
36139
- var state = {
36126
+ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
36127
+ return {
36140
36128
  host: host,
36141
36129
  compilerOptions: options,
36142
36130
  traceEnabled: isTraceEnabled(options, host),
36143
- failedLookupLocations: [],
36144
- affectingLocations: [],
36131
+ failedLookupLocations: ts.noopPush,
36132
+ affectingLocations: ts.noopPush,
36145
36133
  packageJsonInfoCache: packageJsonInfoCache,
36146
- features: 0,
36147
- conditions: [],
36134
+ features: NodeResolutionFeatures.None,
36135
+ conditions: ts.emptyArray,
36148
36136
  requestContainingDirectory: undefined,
36149
36137
  reportDiagnostic: ts.noop
36150
36138
  };
36139
+ }
36140
+ ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
36141
+ function getPackageScopeForPath(fileName, state) {
36151
36142
  var parts = ts.getPathComponents(fileName);
36152
36143
  parts.pop();
36153
36144
  while (parts.length > 0) {
@@ -36304,7 +36295,7 @@ var ts;
36304
36295
  var _a, _b;
36305
36296
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36306
36297
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
36307
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
36298
+ var scope = getPackageScopeForPath(directoryPath, state);
36308
36299
  if (!scope || !scope.packageJsonContent.exports) {
36309
36300
  return undefined;
36310
36301
  }
@@ -36363,7 +36354,7 @@ var ts;
36363
36354
  }
36364
36355
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36365
36356
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
36366
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
36357
+ var scope = getPackageScopeForPath(directoryPath, state);
36367
36358
  if (!scope) {
36368
36359
  if (state.traceEnabled) {
36369
36360
  trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
@@ -43556,6 +43547,12 @@ var ts;
43556
43547
  return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
43557
43548
  }
43558
43549
  function typeToTypeNodeHelper(type, context) {
43550
+ var savedFlags = context.flags;
43551
+ var typeNode = typeToTypeNodeWorker(type, context);
43552
+ context.flags = savedFlags;
43553
+ return typeNode;
43554
+ }
43555
+ function typeToTypeNodeWorker(type, context) {
43559
43556
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
43560
43557
  cancellationToken.throwIfCancellationRequested();
43561
43558
  }
@@ -49226,7 +49223,7 @@ var ts;
49226
49223
  }
49227
49224
  }
49228
49225
  }
49229
- return getIntersectionType(constraints);
49226
+ return getNormalizedType(getIntersectionType(constraints), false);
49230
49227
  }
49231
49228
  return undefined;
49232
49229
  }
@@ -52079,21 +52076,28 @@ var ts;
52079
52076
  getFlowTypeOfReference(accessExpression, propType) :
52080
52077
  propType;
52081
52078
  }
52082
- if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
52079
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) {
52080
+ var index = +propName;
52083
52081
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) {
52084
52082
  var indexNode = getIndexNodeForAccessExpression(accessNode);
52085
52083
  if (isTupleType(objectType)) {
52084
+ if (index < 0) {
52085
+ error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
52086
+ return undefinedType;
52087
+ }
52086
52088
  error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
52087
52089
  }
52088
52090
  else {
52089
52091
  error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
52090
52092
  }
52091
52093
  }
52092
- errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
52093
- return mapType(objectType, function (t) {
52094
- var restType = getRestTypeOfTupleType(t) || undefinedType;
52095
- return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType;
52096
- });
52094
+ if (index >= 0) {
52095
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
52096
+ return mapType(objectType, function (t) {
52097
+ var restType = getRestTypeOfTupleType(t) || undefinedType;
52098
+ return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType;
52099
+ });
52100
+ }
52097
52101
  }
52098
52102
  }
52099
52103
  if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) {
@@ -60178,7 +60182,9 @@ var ts;
60178
60182
  var narrowedType = mapType(candidate, function (c) {
60179
60183
  var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
60180
60184
  var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
60181
- var directlyRelated = mapType(matching || type, function (t) { return isRelated(t, c) ? t : isRelated(c, t) ? c : neverType; });
60185
+ var directlyRelated = mapType(matching || type, checkDerived ?
60186
+ function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
60187
+ function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
60182
60188
  return directlyRelated.flags & 131072 ?
60183
60189
  mapType(type, function (t) { return maybeTypeOfKind(t, 465829888) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) :
60184
60190
  directlyRelated;
@@ -70963,14 +70969,19 @@ var ts;
70963
70969
  }
70964
70970
  var indexInfos = getApplicableIndexInfos(type, propNameType);
70965
70971
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70966
- var localPropDeclaration = declaration && declaration.kind === 221 ||
70967
- name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
70972
+ var propDeclaration = declaration && declaration.kind === 221 ||
70973
+ name && name.kind === 162 ? declaration : undefined;
70974
+ var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
70968
70975
  var _loop_30 = function (info) {
70969
70976
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
70970
70977
  var errorNode = localPropDeclaration || localIndexDeclaration ||
70971
70978
  (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
70972
70979
  if (errorNode && !isTypeAssignableTo(propType, info.type)) {
70973
- error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
70980
+ var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
70981
+ if (propDeclaration && errorNode !== propDeclaration) {
70982
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
70983
+ }
70984
+ diagnostics.add(diagnostic);
70974
70985
  }
70975
70986
  };
70976
70987
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
@@ -97280,7 +97291,7 @@ var ts;
97280
97291
  return undefined;
97281
97292
  }
97282
97293
  function lookupFromPackageJson() {
97283
- var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
97294
+ var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
97284
97295
  return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97285
97296
  }
97286
97297
  }