Compare commits

...

34 commits

Author SHA1 Message Date
TypeScript Bot 90600e1b17 Update package-lock.json 2021-11-24 06:07:09 +00:00
Daniel Rosenwasser a90389a22d
Switch deferredNodes from a Map to a Set. (#46751) 2021-11-23 17:46:33 -08:00
TypeScript Bot 0163a624b7 Update package-lock.json 2021-11-20 06:06:42 +00:00
TypeScript Bot 9766757ee6 Update package-lock.json 2021-11-19 06:06:13 +00:00
Nathan Shively-Sanders 868c275fdf
Plain JS binder errors (#46816)
* Plain JS binder errors

Issue select errors from the binder in JS files that do not have checkJS
explicitly turned on or off. These errors mirror runtime checks done by
Javascript.

* Rest of plain JS binder errors

* address PR comments

* Only issue binder errors in plain JS.

Checker errors require requesting diagnostics, which stll needs to be
peformance tested.

This commit removes one cross-file duplicate declaration error in the tests.

* fix const lint
2021-11-18 17:13:06 -08:00
Oleksandr T 6143237376
fix(46366): handle enum string access as enumMemberName (#46431) 2021-11-18 15:50:32 -08:00
Andrew Casey 1ade73df2b
Stop calling our own @deprecrated APIs (#46831)
* Clean up createMap

* Delete dead createMapFromTemplate

* Clean up assertDefined

* Delete dead assertEachDefined

* Delete dead createUnderscoreEscapedMap

* Delete dead hasEntries

* Delete dead ReadonlyNodeSet, NodeSet, ReadonlyNodeMap, NodeMap

* Use updated SyntaxKind names

* Update API baselines
2021-11-18 10:37:55 -08:00
Zzzen de4ba0f208
enable go-to-type-definition on type nodes (#46714)
* enable go-to-type-definition on type nodes

* only go when symbol has no value meaning

* Update formatting of src/services/goToDefinition.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-11-18 08:55:54 -08:00
Oleksandr T a75f26e68b
fix(42238): emit this parameter in function declaration (#46511) 2021-11-17 15:43:27 -08:00
Andrew Branch f11f14baba
Fix broken module resolution after large/rapid edits in nodenext (#46818)
* Fix broken module resolution after edits in nodenext

* Move field copying to a better place I guess
2021-11-17 13:04:43 -08:00
Andrew Branch 009dd487a6
Update symlink cache from AutoImportProvider resolution even if host project already contains the file via its realpath (#46830) 2021-11-16 16:39:10 -08:00
Wesley Wigham 0bf97296d6
Allow nightly-only flags in -insiders builds (#46829) 2021-11-16 12:53:37 -08:00
Kevin Tan fcdbc932bf
implement code fix for override of js files (#45780)
* feat: code fix for override in js files

Co-Authored-By: Wenlu Wang <kingwenlu@gmail.com>

* fix comments

Co-Authored-By: Wenlu Wang <kingwenlu@gmail.com>

* remove tryMergeJsdocTags

* fix: bring the two methods back as functions

* revert emitter changes

* fix comments

* fix: test failures

Co-authored-by: Wenlu Wang <kingwenlu@gmail.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-11-16 08:01:43 -08:00
TypeScript Bot 7615547d42 Update package-lock.json 2021-11-15 06:06:28 +00:00
Oleksandr T 719ab0b477
fix(43359): emit default exports with named exports that have the same names with types (#44718) 2021-11-12 11:25:52 -08:00
Mohammad Aziz fe3e117cb2
fix(46712): Add "exceptZero" for "signDisplay" option of Intl.NumberFormat() (#46740) 2021-11-12 11:12:21 +00:00
Andrew Branch 1298f498f4
Revert changes to matchFiles/readDirectory made since 4.3 (#46787)
* Revert "Fix RWC missing file detection (#46673)"

This reverts commit 4a065f524c.

* Revert "Pass absolute path to directoryExists (#46086)"

This reverts commit 55b4928e82.

* Revert "Reduce exceptions (#44710)"

This reverts commit c0d5c29080.

* Add back system watcher limit
2021-11-11 15:24:20 -08:00
Armando Aguirre 7b86a65f22
Removed replacement from jsx completions (#46767)
* Removed replacement from jsx completions

* Fixed tests
2021-11-10 18:18:15 -08:00
Oleksandr T b12d5c5dc5
fix(46605): show completions in object literal parameters (#46743) 2021-11-09 14:50:26 -08:00
Daniel Rosenwasser 416571ca90
Remove unnecessary annotations/casts/aliases (#46727)
* Remove unnecessary annotation.

* Remove more unnecessary stuff.

* Remove unnecessary assertion.
2021-11-09 12:17:54 -08:00
Gabriela Araujo Britto e5a6ae397d
Fix extra newline in class member snippet completions (#46737)
* fix extra newline

* fix test
2021-11-09 12:03:07 -08:00
Wesley Wigham 4a065f524c
Fix RWC missing file detection (#46673) 2021-11-09 10:41:18 -08:00
TypeScript Bot e040e8516f Update package-lock.json 2021-11-09 06:06:42 +00:00
Oleksandr T a05d851dc3
fix(45907): don't use static member name to inherit JSDocs from instance members (#46274) 2021-11-08 15:05:08 -08:00
Nathan Shively-Sanders 9713cc1a75
Big[U]Int64Array.at returns bigint, not number (#46733)
bigint is needed to represent all 64-bit ints that these arrays could
contain.
2021-11-08 09:50:02 -08:00
Oleksandr T 3ef3cdddb3
fix(45692): merge non-primitive in spread-union (#45729) 2021-11-05 15:41:06 -07:00
Oleksandr T 0a628ff0c9
fix(44059): omit duplicate types (#45739) 2021-11-05 15:36:08 -07:00
Oleksandr T 2d4b243195
fix(33325): allow extract refactoring on selected statement without trailing semicolon (#45765) 2021-11-05 10:00:31 -07:00
Oleksandr T 4fca1e1fcd
fix(46666): add outlining spans for comments preceding call expressions (#46682) 2021-11-04 12:43:01 -07:00
Kagami Sascha Rosylight ae582a22ee
Add target: "es2022" (#46291)
* Add `target: "es2022"`

* Add Object.hasOwn

* formatToParts is es2018

* ref update

* optional parameter

* Revert "optional parameter"

This reverts commit e67d6e5f60.

* undefined

* error cause

* Lint fix

Co-authored-by: Orta <git@orta.io>
2021-11-04 10:55:11 -07:00
Oleksandr T ff75b8a180
fix(46615): remove useless assertion. change error suggestion for rest params (#46628) 2021-11-03 14:11:39 -07:00
Wesley Wigham d53630fac3
Make specifier generation from export map information conditional on module resolution mode (#46670) 2021-11-03 13:10:44 -07:00
Oleksandr T 7264cf7db5
fix(46589): omit ? in method signature completion for optional methods (#46594) 2021-11-03 12:56:17 -07:00
Andrew Casey e2f47a2db1
Duplicate GDPR fragment from VS Code repo (#46625)
* Duplicate GDPR fragment from VS Code repo

...because the tool doesn't handle cross-repro references.

* Explain functionality in more detail
2021-11-03 10:37:31 -07:00
193 changed files with 3193 additions and 483 deletions

18
package-lock.json generated
View file

@ -676,9 +676,9 @@
"dev": true
},
"@types/node": {
"version": "16.11.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz",
"integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==",
"version": "16.11.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz",
"integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==",
"dev": true
},
"@types/node-fetch": {
@ -6997,9 +6997,9 @@
}
},
"source-map-support": {
"version": "0.5.20",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.20.tgz",
"integrity": "sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==",
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
@ -8423,9 +8423,9 @@
},
"dependencies": {
"camelcase": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz",
"integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==",
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.1.tgz",
"integrity": "sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==",
"dev": true
},
"decamelize": {

View file

@ -5657,8 +5657,8 @@ namespace ts {
const expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
const parameters = (some(expandedParams, p => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & CheckFlags.RestParameter)) ? signature.parameters : expandedParams).map(parameter => symbolToParameterDeclaration(parameter, context, kind === SyntaxKind.Constructor, options?.privateSymbolVisitor, options?.bundledImports));
if (signature.thisParameter) {
const thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
const thisParameter = tryGetThisParameterDeclaration(signature, context);
if (thisParameter) {
parameters.unshift(thisParameter);
}
@ -5713,6 +5713,25 @@ namespace ts {
return node;
}
function tryGetThisParameterDeclaration(signature: Signature, context: NodeBuilderContext) {
if (signature.thisParameter) {
return symbolToParameterDeclaration(signature.thisParameter, context);
}
if (signature.declaration) {
const thisTag = getJSDocThisTag(signature.declaration);
if (thisTag && thisTag.typeExpression) {
return factory.createParameterDeclaration(
/* decorators */ undefined,
/* modifiers */ undefined,
/* dotDotDotToken */ undefined,
"this",
/* questionToken */ undefined,
typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)
);
}
}
}
function typeParameterToDeclarationWithConstraint(type: TypeParameter, context: NodeBuilderContext, constraintNode: TypeNode | undefined): TypeParameterDeclaration {
const savedContextFlags = context.flags;
context.flags &= ~NodeBuilderFlags.WriteTypeParametersInQualifiedName; // Avoids potential infinite loop when building for a claimspace with a generic
@ -6204,12 +6223,8 @@ namespace ts {
firstChar = symbolName.charCodeAt(0);
}
let expression: Expression | undefined;
if (isSingleOrDoubleQuote(firstChar)) {
expression = factory.createStringLiteral(
symbolName
.substring(1, symbolName.length - 1)
.replace(/\\./g, s => s.substring(1)),
firstChar === CharacterCodes.singleQuote);
if (isSingleOrDoubleQuote(firstChar) && !(symbol.flags & SymbolFlags.EnumMember)) {
expression = factory.createStringLiteral(stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)), firstChar === CharacterCodes.singleQuote);
}
else if (("" + +symbolName) === symbolName) {
expression = factory.createNumericLiteral(+symbolName);
@ -16013,7 +16028,7 @@ namespace ts {
const declarations = concatenate(leftProp.declarations, rightProp.declarations);
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
const result = createSymbol(flags, leftProp.escapedName);
result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)]);
result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], UnionReduction.Subtype);
result.leftSpread = leftProp;
result.rightSpread = rightProp;
result.declarations = declarations;
@ -21221,9 +21236,10 @@ namespace ts {
(isCallSignatureDeclaration(param.parent) || isMethodSignature(param.parent) || isFunctionTypeNode(param.parent)) &&
param.parent.parameters.indexOf(param) > -1 &&
(resolveName(param, param.name.escapedText, SymbolFlags.Type, undefined, param.name.escapedText, /*isUse*/ true) ||
param.name.originalKeywordKind && isTypeNodeKind(param.name.originalKeywordKind))) {
param.name.originalKeywordKind && isTypeNodeKind(param.name.originalKeywordKind))) {
const newName = "arg" + param.parent.parameters.indexOf(param);
errorOrSuggestion(noImplicitAny, declaration, Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, declarationNameToString(param.name));
const typeName = declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
errorOrSuggestion(noImplicitAny, declaration, Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
return;
}
diagnostic = (declaration as ParameterDeclaration).dotDotDotToken ?
@ -40406,9 +40422,8 @@ namespace ts {
const enclosingFile = getSourceFileOfNode(node);
const links = getNodeLinks(enclosingFile);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
links.deferredNodes = links.deferredNodes || new Map();
const id = getNodeId(node);
links.deferredNodes.set(id, node);
links.deferredNodes ||= new Set();
links.deferredNodes.add(node);
}
}
@ -41588,7 +41603,7 @@ namespace ts {
if (!symbol) {
return false;
}
const target = resolveAlias(symbol);
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
if (target === unknownSymbol) {
return true;
}
@ -43061,8 +43076,7 @@ namespace ts {
// Modifiers are never allowed on properties except for 'async' on a method declaration
if (prop.modifiers) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
for (const mod of prop.modifiers!) { // TODO: GH#19955
for (const mod of prop.modifiers) {
if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) {
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
}

View file

@ -29,6 +29,7 @@ namespace ts {
["es2019", "lib.es2019.d.ts"],
["es2020", "lib.es2020.d.ts"],
["es2021", "lib.es2021.d.ts"],
["es2022", "lib.es2022.d.ts"],
["esnext", "lib.esnext.d.ts"],
// Host only
["dom", "lib.dom.d.ts"],
@ -72,12 +73,16 @@ namespace ts {
["es2021.string", "lib.es2021.string.d.ts"],
["es2021.weakref", "lib.es2021.weakref.d.ts"],
["es2021.intl", "lib.es2021.intl.d.ts"],
["esnext.array", "lib.es2019.array.d.ts"],
["es2022.array", "lib.es2022.array.d.ts"],
["es2022.error", "lib.es2022.error.d.ts"],
["es2022.object", "lib.es2022.object.d.ts"],
["es2022.string", "lib.es2022.string.d.ts"],
["esnext.array", "lib.es2022.array.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.bigint", "lib.es2020.bigint.d.ts"],
["esnext.string", "lib.es2021.string.d.ts"],
["esnext.string", "lib.es2022.string.d.ts"],
["esnext.promise", "lib.es2021.promise.d.ts"],
["esnext.weakref", "lib.es2021.weakref.d.ts"]
];
@ -314,6 +319,7 @@ namespace ts {
es2019: ScriptTarget.ES2019,
es2020: ScriptTarget.ES2020,
es2021: ScriptTarget.ES2021,
es2022: ScriptTarget.ES2022,
esnext: ScriptTarget.ESNext,
})),
affectsSourceFile: true,

View file

@ -23,34 +23,6 @@ namespace ts {
export const emptyMap: ReadonlyESMap<never, never> = new Map<never, never>();
export const emptySet: ReadonlySet<never> = new Set<never>();
/**
* Create a new map.
* @deprecated Use `new Map()` instead.
*/
export function createMap<K, V>(): ESMap<K, V>;
export function createMap<T>(): ESMap<string, T>;
export function createMap<K, V>(): ESMap<K, V> {
return new Map<K, V>();
}
/**
* Create a new map from a template object is provided, the map will copy entries from it.
* @deprecated Use `new Map(getEntries(template))` instead.
*/
export function createMapFromTemplate<T>(template: MapLike<T>): ESMap<string, T> {
const map: ESMap<string, T> = new Map<string, T>();
// Copies keys/values from template. Note that for..in will not throw if
// template is undefined, and instead will just exit the loop.
for (const key in template) {
if (hasOwnProperty.call(template, key)) {
map.set(key, template[key]);
}
}
return map;
}
export function length(array: readonly any[] | undefined): number {
return array ? array.length : 0;
}

View file

@ -171,12 +171,6 @@ namespace ts {
return value;
}
/**
* @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
* a value is defined at the statement level.
*/
export const assertDefined = checkDefined;
export function assertEachIsDefined<T extends Node>(value: NodeArray<T>, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray<T>;
export function assertEachIsDefined<T>(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable<T>[];
export function assertEachIsDefined<T>(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) {
@ -190,12 +184,6 @@ namespace ts {
return value;
}
/**
* @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
* the elements of an array are defined at the statement level.
*/
export const assertEachDefined = checkEachDefined;
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member);
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);

View file

@ -1604,6 +1604,7 @@ namespace ts {
return emitJSDocSignature(node as JSDocSignature);
case SyntaxKind.JSDocTag:
case SyntaxKind.JSDocClassTag:
case SyntaxKind.JSDocOverrideTag:
return emitJSDocSimpleTag(node as JSDocTag);
case SyntaxKind.JSDocAugmentsTag:
case SyntaxKind.JSDocImplementsTag:
@ -1616,7 +1617,6 @@ namespace ts {
case SyntaxKind.JSDocPrivateTag:
case SyntaxKind.JSDocProtectedTag:
case SyntaxKind.JSDocReadonlyTag:
case SyntaxKind.JSDocOverrideTag:
return;
case SyntaxKind.JSDocCallbackTag:
return emitJSDocCallbackTag(node as JSDocCallbackTag);

View file

@ -6387,7 +6387,7 @@ namespace ts {
sourceMapText = mapTextOrStripInternal as string;
}
const node = oldFileOfCurrentEmit ?
parseOldFileOfCurrentEmit(Debug.assertDefined(bundleFileInfo)) :
parseOldFileOfCurrentEmit(Debug.checkDefined(bundleFileInfo)) :
parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
node.fileName = fileName;
node.sourceMapPath = sourceMapPath;
@ -6587,13 +6587,13 @@ namespace ts {
};
node.javascriptPath = declarationTextOrJavascriptPath;
node.javascriptMapPath = javascriptMapPath;
node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath);
node.declarationPath = Debug.checkDefined(javascriptMapTextOrDeclarationPath);
node.declarationMapPath = declarationMapPath;
node.buildInfoPath = declarationMapTextOrBuildInfoPath;
Object.defineProperties(node, {
javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } },
javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that
declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
declarationText: { get() { return definedTextGetter(Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
declarationMapText: { get() { return textGetter(declarationMapPath); } }, // TODO:: if there is inline sourceMap in dtsFile, use that
buildInfo: { get() { return getAndCacheBuildInfo(() => textGetter(declarationMapTextOrBuildInfoPath)); } }
});

View file

@ -707,13 +707,15 @@ namespace ts.moduleSpecifiers {
if (host.fileExists(packageJsonPath)) {
const packageJsonContent = JSON.parse(host.readFile!(packageJsonPath)!);
// TODO: Inject `require` or `import` condition based on the intended import mode
const fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
if (fromExports) {
const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
return { ...withJsExtension, verbatimFromExports: true };
}
if (packageJsonContent.exports) {
return { moduleFileToTry: path, blockedByExports: true };
if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) {
const fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
if (fromExports) {
const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
return { ...withJsExtension, verbatimFromExports: true };
}
if (packageJsonContent.exports) {
return { moduleFileToTry: path, blockedByExports: true };
}
}
const versionPaths = packageJsonContent.typesVersions
? getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)

View file

@ -818,6 +818,25 @@ namespace ts {
}
}
/** @internal */
export const plainJSErrors: Set<number> = new Set([
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
Diagnostics.A_module_cannot_have_multiple_default_exports.code,
Diagnostics.Another_export_default_is_here.code,
Diagnostics.The_first_export_default_is_here.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
Diagnostics.constructor_is_a_reserved_word.code,
Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
Diagnostics.Invalid_use_of_0_in_strict_mode.code,
Diagnostics.A_label_is_not_allowed_here.code,
Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
]);
/**
* Determine if source file needs to be re-created even if its text hasn't changed
*/
@ -1577,6 +1596,7 @@ namespace ts {
newSourceFile.originalFileName = oldSourceFile.originalFileName;
newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
newSourceFile.fileName = oldSourceFile.fileName;
newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
const packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
if (packageName !== undefined) {
@ -2004,15 +2024,24 @@ namespace ts {
Debug.assert(!!sourceFile.bindDiagnostics);
const isCheckJs = isCheckJsEnabledForFile(sourceFile, options);
const isJs = sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX;
const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
const isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
const isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
// By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|| sourceFile.scriptKind === ScriptKind.External || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
const bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
// - plain JS: .js files with no // ts-check and checkJs: undefined
// - check JS: .js files with either // ts-check or checkJs: true
// - external: files that are added by plugins
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
const checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
if (isPlainJs) {
bindDiagnostics = filter(bindDiagnostics, d => plainJSErrors.has(d.code));
}
// skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
});
}
@ -3160,7 +3189,7 @@ namespace ts {
}
function verifyCompilerOptions() {
const isNightly = stringContains(version, "-dev");
const isNightly = stringContains(version, "-dev") || stringContains(version, "-insiders");
if (!isNightly) {
if (getEmitModuleKind(options) === ModuleKind.Node12) {
createOptionValueDiagnostic("module", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");

View file

@ -619,7 +619,7 @@ namespace ts {
) {
if (resolution.refCount) {
resolution.refCount++;
Debug.assertDefined(resolution.files);
Debug.assertIsDefined(resolution.files);
}
else {
resolution.refCount = 1;
@ -696,7 +696,7 @@ namespace ts {
filePath: Path,
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
) {
unorderedRemoveItem(Debug.assertDefined(resolution.files), filePath);
unorderedRemoveItem(Debug.checkDefined(resolution.files), filePath);
resolution.refCount!--;
if (resolution.refCount) {
return;
@ -798,7 +798,7 @@ namespace ts {
for (const resolution of resolutions) {
if (resolution.isInvalidated || !canInvalidate(resolution)) continue;
resolution.isInvalidated = invalidated = true;
for (const containingFilePath of Debug.assertDefined(resolution.files)) {
for (const containingFilePath of Debug.checkDefined(resolution.files)) {
(filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new Set())).add(containingFilePath);
// When its a file with inferred types resolution, invalidate type reference directive resolution
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);

View file

@ -1625,7 +1625,6 @@ namespace ts {
sysLog(`sysLog:: ${fileOrDirectory}:: Defaulting to fsWatchFile`);
return watchPresentFileSystemEntryWithFsWatchFile();
}
try {
const presentWatcher = _fs.watch(
fileOrDirectory,
@ -1804,7 +1803,7 @@ namespace ts {
}
function readDirectory(path: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] {
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists);
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
}
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {

View file

@ -282,7 +282,7 @@ namespace ts {
function visitYieldExpression(node: YieldExpression) {
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
if (node.asteriskToken) {
const expression = visitNode(Debug.assertDefined(node.expression), visitor, isExpression);
const expression = visitNode(Debug.checkDefined(node.expression), visitor, isExpression);
return setOriginalNode(
setTextRange(

View file

@ -48,11 +48,11 @@ namespace ts {
return existing.name;
}
if (!currentFileState.utilizedImplicitRuntimeImports) {
currentFileState.utilizedImplicitRuntimeImports = createMap();
currentFileState.utilizedImplicitRuntimeImports = new Map();
}
let specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
if (!specifierSourceImports) {
specifierSourceImports = createMap();
specifierSourceImports = new Map();
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
}
const generatedName = factory.createUniqueName(`_${name}`, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.AllowNameSubstitution);

View file

@ -1609,7 +1609,7 @@ namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsToken;
readonly assertsModifier?: AssertsKeyword;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -1702,7 +1702,7 @@ namespace ts {
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -2756,7 +2756,7 @@ namespace ts {
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeywordToken;
readonly awaitModifier?: AwaitKeyword;
readonly initializer: ForInitializer;
readonly expression: Expression;
}
@ -5107,7 +5107,7 @@ namespace ts {
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
deferredNodes?: Set<Node>; // Set of nodes whose checking has been deferred
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
isExhaustive?: boolean; // Is node an exhaustive switch statement
@ -6268,6 +6268,7 @@ namespace ts {
ES2019 = 6,
ES2020 = 7,
ES2021 = 8,
ES2022 = 9,
ESNext = 99,
JSON = 100,
Latest = ESNext,
@ -6725,15 +6726,16 @@ namespace ts {
ContainsTypeScript = 1 << 0,
ContainsJsx = 1 << 1,
ContainsESNext = 1 << 2,
ContainsES2021 = 1 << 3,
ContainsES2020 = 1 << 4,
ContainsES2019 = 1 << 5,
ContainsES2018 = 1 << 6,
ContainsES2017 = 1 << 7,
ContainsES2016 = 1 << 8,
ContainsES2015 = 1 << 9,
ContainsGenerator = 1 << 10,
ContainsDestructuringAssignment = 1 << 11,
ContainsES2022 = 1 << 3,
ContainsES2021 = 1 << 4,
ContainsES2020 = 1 << 5,
ContainsES2019 = 1 << 6,
ContainsES2018 = 1 << 7,
ContainsES2017 = 1 << 8,
ContainsES2016 = 1 << 9,
ContainsES2015 = 1 << 10,
ContainsGenerator = 1 << 11,
ContainsDestructuringAssignment = 1 << 12,
// Markers
// - Flags used to indicate that a subtree contains a specific transformation.
@ -6762,6 +6764,7 @@ namespace ts {
AssertTypeScript = ContainsTypeScript,
AssertJsx = ContainsJsx,
AssertESNext = ContainsESNext,
AssertES2022 = ContainsES2022,
AssertES2021 = ContainsES2021,
AssertES2020 = ContainsES2020,
AssertES2019 = ContainsES2019,

View file

@ -20,21 +20,6 @@ namespace ts {
return undefined;
}
/**
* Create a new escaped identifier map.
* @deprecated Use `new Map<__String, T>()` instead.
*/
export function createUnderscoreEscapedMap<T>(): UnderscoreEscapedMap<T> {
return new Map<__String, T>();
}
/**
* @deprecated Use `!!map?.size` instead
*/
export function hasEntries(map: ReadonlyCollection<any> | undefined): map is ReadonlyCollection<any> {
return !!map && !!map.size;
}
export function createSymbolTable(symbols?: readonly Symbol[]): SymbolTable {
const result = new Map<__String, Symbol>();
if (symbols) {
@ -606,6 +591,7 @@ namespace ts {
AsyncIterableIterator: emptyArray,
AsyncGenerator: emptyArray,
AsyncGeneratorFunction: emptyArray,
NumberFormat: ["formatToParts"]
},
es2019: {
Array: ["flat", "flatMap"],
@ -627,8 +613,21 @@ namespace ts {
PromiseConstructor: ["any"],
String: ["replaceAll"]
},
esnext: {
NumberFormat: ["formatToParts"]
es2022: {
Array: ["at"],
String: ["at"],
Int8Array: ["at"],
Uint8Array: ["at"],
Uint8ClampedArray: ["at"],
Int16Array: ["at"],
Uint16Array: ["at"],
Int32Array: ["at"],
Uint32Array: ["at"],
Float32Array: ["at"],
Float64Array: ["at"],
BigInt64Array: ["at"],
BigUint64Array: ["at"],
ObjectConstructor: ["hasOwn"]
}
};
}
@ -6615,7 +6614,7 @@ namespace ts {
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
};
}
@ -6624,7 +6623,7 @@ namespace ts {
}
/** @param path directory of the tsconfig.json */
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[] {
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
path = normalizePath(path);
currentDirectory = normalizePath(currentDirectory);
@ -6639,22 +6638,20 @@ namespace ts {
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
const visited = new Map<string, true>();
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
for (const absoluteBasePath of patterns.basePaths) {
if (directoryExists(absoluteBasePath)) {
visitDirectory(absoluteBasePath, depth);
}
for (const basePath of patterns.basePaths) {
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
}
return flatten(results);
function visitDirectory(absolutePath: string, depth: number | undefined) {
function visitDirectory(path: string, absolutePath: string, depth: number | undefined) {
const canonicalPath = toCanonical(realpath(absolutePath));
if (visited.has(canonicalPath)) return;
visited.set(canonicalPath, true);
const { files, directories } = getFileSystemEntries(absolutePath);
const { files, directories } = getFileSystemEntries(path);
for (const current of sort<string>(files, compareStringsCaseSensitive)) {
const name = combinePaths(absolutePath, current);
const name = combinePaths(path, current);
const absoluteName = combinePaths(absolutePath, current);
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
@ -6677,10 +6674,11 @@ namespace ts {
}
for (const current of sort<string>(directories, compareStringsCaseSensitive)) {
const name = combinePaths(path, current);
const absoluteName = combinePaths(absolutePath, current);
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
(!excludeRegex || !excludeRegex.test(absoluteName))) {
visitDirectory(absoluteName, depth);
visitDirectory(name, absoluteName, depth);
}
}
}
@ -6688,11 +6686,10 @@ namespace ts {
/**
* Computes the unique non-wildcard base paths amongst the provided include patterns.
* @returns Absolute directory paths
*/
function getBasePaths(absoluteTsconfigPath: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
function getBasePaths(path: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
const basePaths: string[] = [absoluteTsconfigPath];
const basePaths: string[] = [path];
if (includes) {
// Storage for literal base paths amongst the include patterns.
@ -6700,9 +6697,9 @@ namespace ts {
for (const include of includes) {
// We also need to check the relative paths by converting them to absolute and normalizing
// in case they escape the base path (e.g "..\somedirectory")
const absoluteIncludePath: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(absoluteTsconfigPath, include));
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
// Append the literal and canonical candidate base paths.
includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
includeBasePaths.push(getIncludeBasePath(absolute));
}
// Sort the offsets array using either the literal or canonical path representations.
@ -6711,7 +6708,7 @@ namespace ts {
// Iterate over each include base path and include unique base paths that are not a
// subpath of an existing base path
for (const includeBasePath of includeBasePaths) {
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames))) {
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
basePaths.push(includeBasePath);
}
}
@ -6982,18 +6979,6 @@ namespace ts {
return { min, max };
}
/** @deprecated Use `ReadonlySet<TNode>` instead. */
export type ReadonlyNodeSet<TNode extends Node> = ReadonlySet<TNode>;
/** @deprecated Use `Set<TNode>` instead. */
export type NodeSet<TNode extends Node> = Set<TNode>;
/** @deprecated Use `ReadonlyMap<TNode, TValue>` instead. */
export type ReadonlyNodeMap<TNode extends Node, TValue> = ReadonlyESMap<TNode, TValue>;
/** @deprecated Use `Map<TNode, TValue>` instead. */
export type NodeMap<TNode extends Node, TValue> = ESMap<TNode, TValue>;
export function rangeOfNode(node: Node): TextRange {
return { pos: getTokenPosOfNode(node), end: node.end };
}

View file

@ -14,6 +14,8 @@ namespace ts {
switch (getEmitScriptTarget(options)) {
case ScriptTarget.ESNext:
return "lib.esnext.full.d.ts";
case ScriptTarget.ES2022:
return "lib.es2022.full.d.ts";
case ScriptTarget.ES2021:
return "lib.es2021.full.d.ts";
case ScriptTarget.ES2020:

View file

@ -184,7 +184,7 @@ namespace ts {
const rootResult = tryReadDirectory(rootDir, rootDirPath);
let rootSymLinkResult: FileSystemEntries | undefined;
if (rootResult !== undefined) {
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists);
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
}
return host.readDirectory!(rootDir, extensions, excludes, includes, depth);

View file

@ -95,7 +95,7 @@ namespace fakes {
}
public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path), path => this.directoryExists(path));
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path));
}
public getAccessibleFileSystemEntries(path: string): ts.FileSystemEntries {

View file

@ -637,7 +637,8 @@ namespace FourSlash {
ts.forEachKey(this.inputFiles, fileName => {
if (!ts.isAnySupportedFileExtension(fileName)
|| Harness.getConfigNameFromFileName(fileName)
|| !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
// Can't get a Program in Server tests
|| this.testType !== FourSlashTestType.Server && !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|| ts.getBaseFileName(fileName) === "package.json") return;
const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
if (errors.length) {

View file

@ -922,7 +922,7 @@ interface Array<T> { length: number; [n: number]: T; }`
});
}
return { directories, files };
}, path => this.realpath(path), path => this.directoryExists(path));
}, path => this.realpath(path));
}
createHash(s: string): string {

View file

@ -200,7 +200,7 @@ declare namespace Intl {
interface NumberFormatOptions {
compactDisplay?: "short" | "long" | undefined;
notation?: "standard" | "scientific" | "engineering" | "compact" | undefined;
signDisplay?: "auto" | "never" | "always" | undefined;
signDisplay?: "auto" | "never" | "always" | "exceptZero" | undefined;
unit?: string | undefined;
unitDisplay?: "short" | "long" | "narrow" | undefined;
}
@ -208,7 +208,7 @@ declare namespace Intl {
interface ResolvedNumberFormatOptions {
compactDisplay?: "short" | "long";
notation?: "standard" | "scientific" | "engineering" | "compact";
signDisplay?: "auto" | "never" | "always";
signDisplay?: "auto" | "never" | "always" | "exceptZero";
unit?: string;
unitDisplay?: "short" | "long" | "narrow";
}

103
src/lib/es2022.array.d.ts vendored Normal file
View file

@ -0,0 +1,103 @@
interface Array<T> {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): T | undefined;
}
interface ReadonlyArray<T> {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): T | undefined;
}
interface Int8Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Uint8Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Uint8ClampedArray {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Int16Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Uint16Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Int32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Uint32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Float32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface Float64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
interface BigInt64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): bigint | undefined;
}
interface BigUint64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): bigint | undefined;
}

5
src/lib/es2022.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
/// <reference lib="es2021" />
/// <reference lib="es2022.array" />
/// <reference lib="es2022.error" />
/// <reference lib="es2022.object" />
/// <reference lib="es2022.string" />

8
src/lib/es2022.error.d.ts vendored Normal file
View file

@ -0,0 +1,8 @@
interface ErrorOptions {
cause?: Error;
}
interface ErrorConstructor {
new(message?: string, options?: ErrorOptions): Error;
(message?: string, options?: ErrorOptions): Error;
}

5
src/lib/es2022.full.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
/// <reference lib="es2022" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />

8
src/lib/es2022.object.d.ts vendored Normal file
View file

@ -0,0 +1,8 @@
interface Object {
/**
* Determines whether an object has a property with the specified name.
* @param o An object.
* @param v A property name.
*/
hasOwn(o: object, v: PropertyKey): boolean;
}

7
src/lib/es2022.string.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
interface String {
/**
* Returns a new String consisting of the single UTF-16 code unit located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): string | undefined;
}

2
src/lib/esnext.d.ts vendored
View file

@ -1,2 +1,2 @@
/// <reference lib="es2021" />
/// <reference lib="es2022" />
/// <reference lib="esnext.intl" />

View file

@ -9,6 +9,7 @@
"es2019",
"es2020",
"es2021",
"es2022",
"esnext",
// Host only
"dom.generated",
@ -52,6 +53,10 @@
"es2021.promise",
"es2021.weakref",
"es2021.intl",
"es2022.array",
"es2022.error",
"es2022.object",
"es2022.string",
"esnext.intl",
// Default libraries
"es5.full",
@ -62,6 +67,7 @@
"es2019.full",
"es2020.full",
"es2021.full",
"es2022.full",
"esnext.full"
],
"paths": {

View file

@ -1944,15 +1944,15 @@ namespace ts.server {
for (const resolution of resolutions) {
if (!resolution.resolvedFileName) continue;
const { resolvedFileName, originalPath } = resolution;
if (originalPath) {
symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
}
if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) {
rootNames = append(rootNames, resolvedFileName);
// Avoid creating a large project that would significantly slow down time to editor interactivity
if (dependencySelection === PackageJsonAutoImportPreference.Auto && rootNames.length > this.maxDependencies) {
return ts.emptyArray;
}
if (originalPath) {
symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
}
}
}
}

View file

@ -3199,6 +3199,25 @@ namespace ts.server.protocol {
payload: TypingsInstalledTelemetryEventPayload;
}
// A __GDPR__FRAGMENT__ has no meaning until it is ${include}d by a __GDPR__ comment, at which point
// the included properties are effectively inlined into the __GDPR__ declaration. In this case, for
// example, any __GDPR__ comment including the TypeScriptCommonProperties will be updated with an
// additional version property with the classification below. Obviously, the purpose of such a construct
// is to reduce duplication and keep multiple use sites consistent (e.g. by making sure that all reflect
// any newly added TypeScriptCommonProperties). Unfortunately, the system has limits - in particular,
// these reusable __GDPR__FRAGMENT__s are not accessible across repo boundaries. Therefore, even though
// the code for adding the common properties (i.e. version), along with the corresponding __GDPR__FRAGMENT__,
// lives in the VS Code repo (see https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/utils/telemetry.ts)
// we have to duplicate it here. It would be nice to keep them in sync, but the only likely failure mode
// is adding a property to the VS Code repro but not here and the only consequence would be having that
// property suppressed on the events (i.e. __GDPT__ comments) in this repo that reference the out-of-date
// local __GDPR__FRAGMENT__.
/* __GDPR__FRAGMENT__
"TypeScriptCommonProperties" : {
"version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
/* __GDPR__
"typingsinstalled" : {
"${include}": ["${TypeScriptCommonProperties}"],
@ -3515,6 +3534,7 @@ namespace ts.server.protocol {
ES2019 = "ES2019",
ES2020 = "ES2020",
ES2021 = "ES2021",
ES2022 = "ES2022",
ESNext = "ESNext"
}

View file

@ -2112,7 +2112,7 @@ namespace ts.server {
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): CombineOutputResult<NavigateToItem> {
const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args;
if (currentFileOnly) {
Debug.assertDefined(args.file);
Debug.assertIsDefined(args.file);
const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs);
return [{ project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }];
}

View file

@ -14,24 +14,24 @@ namespace ts.codefix {
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
const token = getTokenAtPosition(sourceFile, pos);
if (!isIdentifier(token)) {
return Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + Debug.formatSyntaxKind(token.kind));
}
const param = token.parent;
if (!isParameter(param)) {
return Debug.fail("Tried to add a parameter name to a non-parameter: " + Debug.formatSyntaxKind(token.kind));
}
const i = param.parent.parameters.indexOf(param);
Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
Debug.assert(i > -1, "Parameter not found in parent parameter list.");
const typeNode = factory.createTypeReferenceNode(param.name as Identifier, /*typeArguments*/ undefined);
const replacement = factory.createParameterDeclaration(
/*decorators*/ undefined,
param.modifiers,
param.dotDotDotToken,
"arg" + i,
param.questionToken,
factory.createTypeReferenceNode(token, /*typeArguments*/ undefined),
param.dotDotDotToken ? factory.createArrayTypeNode(typeNode) : typeNode,
param.initializer);
changeTracker.replaceNode(sourceFile, token, replacement);
changeTracker.replaceNode(sourceFile, param, replacement);
}
}

View file

@ -408,9 +408,7 @@ namespace ts.codefix {
const importSpecifiers = mapAllOrFail(name.elements, e =>
e.dotDotDotToken || e.initializer || e.propertyName && !isIdentifier(e.propertyName) || !isIdentifier(e.name)
? undefined
// (TODO: GH#18217)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
: makeImportSpecifier(e.propertyName && (e.propertyName as Identifier).text, e.name.text));
: makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text));
if (importSpecifiers) {
return convertedImports([makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
}

View file

@ -26,9 +26,9 @@ namespace ts.codefix {
if (!isFunctionDeclaration(fn) && !isFunctionExpression(fn)) return undefined;
if (!isSourceFile(getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
const fnKeyword = Debug.assertDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
const fnKeyword = Debug.checkDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
const { name } = fn;
const body = Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
const body = Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
if (isFunctionExpression(fn)) {
if (name && FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
// Function expression references itself. To fix we would have to extract it to a const.

View file

@ -17,37 +17,81 @@ namespace ts.codefix {
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code,
Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code
Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code,
Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code,
Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code,
];
const errorCodeFixIdMap: Record<number, [DiagnosticMessage, string | undefined, DiagnosticMessage | undefined]> = {
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code]: [
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Add_all_missing_override_modifiers,
],
[Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code]: [
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
],
[Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code]: [
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Add_all_missing_override_modifiers,
],
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code]: [
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
],
[Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code]: [
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
]
interface ErrorCodeFixInfo {
descriptions: DiagnosticMessage;
fixId?: string | undefined;
fixAllDescriptions?: DiagnosticMessage | undefined;
}
const errorCodeFixIdMap: Record<number, ErrorCodeFixInfo> = {
// case #1:
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code]: {
descriptions: Diagnostics.Add_override_modifier,
fixId: fixAddOverrideId,
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
},
[Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code]: {
descriptions: Diagnostics.Add_override_modifier,
fixId: fixAddOverrideId,
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers
},
// case #2:
[Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code]: {
descriptions: Diagnostics.Remove_override_modifier,
fixId: fixRemoveOverrideId,
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
},
[Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code]: {
descriptions: Diagnostics.Remove_override_modifier,
fixId: fixRemoveOverrideId,
fixAllDescriptions: Diagnostics.Remove_override_modifier
},
// case #3:
[Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code]: {
descriptions: Diagnostics.Add_override_modifier,
fixId: fixAddOverrideId,
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
},
[Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code]: {
descriptions: Diagnostics.Add_override_modifier,
fixId: fixAddOverrideId,
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
},
// case #4:
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code]: {
descriptions: Diagnostics.Add_override_modifier,
fixId: fixAddOverrideId,
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
},
// case #5:
[Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code]: {
descriptions: Diagnostics.Remove_override_modifier,
fixId: fixRemoveOverrideId,
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
},
[Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code]: {
descriptions: Diagnostics.Remove_override_modifier,
fixId: fixRemoveOverrideId,
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
}
};
registerCodeFix({
errorCodes,
getCodeActions: context => {
const { errorCode, span, sourceFile } = context;
const { errorCode, span } = context;
const info = errorCodeFixIdMap[errorCode];
if (!info) return emptyArray;
const [ descriptions, fixId, fixAllDescriptions ] = info;
if (isSourceFileJS(sourceFile)) return emptyArray;
const { descriptions, fixId, fixAllDescriptions } = info;
const changes = textChanges.ChangeTracker.with(context, changes => dispatchChanges(changes, context, errorCode, span.start));
return [
@ -57,9 +101,9 @@ namespace ts.codefix {
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
getAllCodeActions: context =>
codeFixAll(context, errorCodes, (changes, diag) => {
const { code, start, file } = diag;
const { code, start } = diag;
const info = errorCodeFixIdMap[code];
if (!info || info[1] !== context.fixId || isSourceFileJS(file)) {
if (!info || info.fixId !== context.fixId) {
return;
}
@ -74,11 +118,15 @@ namespace ts.codefix {
pos: number) {
switch (errorCode) {
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code:
case Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code:
case Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code:
case Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos);
case Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code:
case Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code:
case Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code:
case Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code:
return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos);
default:
Debug.fail("Unexpected error code: " + errorCode);
@ -87,6 +135,10 @@ namespace ts.codefix {
function doAddOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
const classElement = findContainerClassElementLike(sourceFile, pos);
if (isSourceFileJS(sourceFile)) {
changeTracker.addJSDocTags(sourceFile, classElement, [factory.createJSDocOverrideTag(factory.createIdentifier("override"))]);
return;
}
const modifiers = classElement.modifiers || emptyArray;
const staticModifier = find(modifiers, isStaticModifier);
const abstractModifier = find(modifiers, isAbstractModifier);
@ -101,6 +153,10 @@ namespace ts.codefix {
function doRemoveOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
const classElement = findContainerClassElementLike(sourceFile, pos);
if (isSourceFileJS(sourceFile)) {
changeTracker.filterJSDocTags(sourceFile, classElement, not(isJSDocOverrideTag));
return;
}
const overrideModifier = classElement.modifiers && find(classElement.modifiers, modifier => modifier.kind === SyntaxKind.OverrideKeyword);
Debug.assertIsDefined(overrideModifier);

View file

@ -37,6 +37,12 @@ namespace ts.codefix {
type AddNode = PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction;
export const enum PreserveOptionalFlags {
Method = 1 << 0,
Property = 1 << 1,
All = Method | Property
}
/**
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
@ -50,6 +56,7 @@ namespace ts.codefix {
importAdder: ImportAdder | undefined,
addClassElement: (node: AddNode) => void,
body: Block | undefined,
preserveOptional = PreserveOptionalFlags.All,
isAmbient = false,
): void {
const declarations = symbol.getDeclarations();
@ -83,7 +90,7 @@ namespace ts.codefix {
/*decorators*/ undefined,
modifiers,
name,
optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
optional && (preserveOptional & PreserveOptionalFlags.Property) ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
typeNode,
/*initializer*/ undefined));
break;
@ -158,14 +165,14 @@ namespace ts.codefix {
}
else {
Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & PreserveOptionalFlags.Method), modifiers, quotePreference, body));
}
}
break;
}
function outputMethod(quotePreference: QuotePreference, signature: Signature, modifiers: NodeArray<Modifier> | undefined, name: PropertyName, body?: Block): void {
const method = createSignatureDeclarationFromSignature(SyntaxKind.MethodDeclaration, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder);
const method = createSignatureDeclarationFromSignature(SyntaxKind.MethodDeclaration, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & PreserveOptionalFlags.Method), enclosingDeclaration, importAdder);
if (method) addClassElement(method);
}
}

View file

@ -131,7 +131,7 @@ namespace ts.codefix {
if (typeNode) {
// Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags
const typeTag = factory.createJSDocTypeTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined);
addJSDocTags(changes, sourceFile, cast(parent.parent.parent, isExpressionStatement), [typeTag]);
changes.addJSDocTags(sourceFile, cast(parent.parent.parent, isExpressionStatement), [typeTag]);
}
importAdder.writeFixes(changes);
return parent;
@ -271,7 +271,7 @@ namespace ts.codefix {
}
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: SignatureDeclaration, typeNode: TypeNode) {
addJSDocTags(changes, sourceFile, containingFunction, [
changes.addJSDocTags(sourceFile, containingFunction, [
factory.createJSDocThisTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode)),
]);
}
@ -311,7 +311,7 @@ namespace ts.codefix {
}
const typeExpression = factory.createJSDocTypeExpression(typeNode);
const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined);
addJSDocTags(changes, sourceFile, parent, [typeTag]);
changes.addJSDocTags(sourceFile, parent, [typeTag]);
}
else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) {
changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
@ -378,46 +378,7 @@ namespace ts.codefix {
else {
const paramTags = map(inferences, ({ name, typeNode, isOptional }) =>
factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined));
addJSDocTags(changes, sourceFile, signature, paramTags);
}
}
export function addJSDocTags(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parent: HasJSDoc, newTags: readonly JSDocTag[]): void {
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
const unmergedNewTags = newTags.filter(newTag => !oldTags || !oldTags.some((tag, i) => {
const merged = tryMergeJsdocTags(tag, newTag);
if (merged) oldTags[i] = merged;
return !!merged;
}));
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...(oldTags || emptyArray), ...unmergedNewTags]));
const jsDocNode = parent.kind === SyntaxKind.ArrowFunction ? getJsDocNodeForArrowFunction(parent) : parent;
jsDocNode.jsDoc = parent.jsDoc;
jsDocNode.jsDocCache = parent.jsDocCache;
changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
}
function getJsDocNodeForArrowFunction(signature: ArrowFunction): HasJSDoc {
if (signature.parent.kind === SyntaxKind.PropertyDeclaration) {
return signature.parent as HasJSDoc;
}
return signature.parent.parent as HasJSDoc;
}
function tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined {
if (oldTag.kind !== newTag.kind) {
return undefined;
}
switch (oldTag.kind) {
case SyntaxKind.JSDocParameterTag: {
const oldParam = oldTag as JSDocParameterTag;
const newParam = newTag as JSDocParameterTag;
return isIdentifier(oldParam.name) && isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
? factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
: undefined;
}
case SyntaxKind.JSDocReturnTag:
return factory.createJSDocReturnTag(/*tagName*/ undefined, (newTag as JSDocReturnTag).typeExpression, oldTag.comment);
changes.addJSDocTags(sourceFile, signature, paramTags);
}
}
@ -1000,13 +961,25 @@ namespace ts.codefix {
if (usage.numberIndex) {
types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
}
if (usage.properties?.size || usage.calls?.length || usage.constructs?.length || usage.stringIndex) {
if (usage.properties?.size || usage.constructs?.length || usage.stringIndex) {
types.push(inferStructuralType(usage));
}
types.push(...(usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t)));
types.push(...inferNamedTypesFromProperties(usage));
const candidateTypes = (usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t));
const callsType = usage.calls?.length ? inferStructuralType(usage) : undefined;
if (callsType && candidateTypes) {
types.push(checker.getUnionType([callsType, ...candidateTypes], UnionReduction.Subtype));
}
else {
if (callsType) {
types.push(callsType);
}
if (length(candidateTypes)) {
types.push(...candidateTypes);
}
}
types.push(...inferNamedTypesFromProperties(usage));
return types;
}

View file

@ -738,10 +738,6 @@ namespace ts.Completions {
insertText = `${escapeSnippetText(name)}={$1}`;
isSnippet = true;
}
if (isSnippet) {
replacementSpan = createTextSpanFromNode(location, sourceFile);
}
}
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
@ -851,7 +847,7 @@ namespace ts.Completions {
removeComments: true,
module: options.module,
target: options.target,
omitTrailingSemicolon: true,
omitTrailingSemicolon: false,
newLine: getNewLineKind(getNewLineCharacter(options, maybeBind(host, host.getNewLine))),
});
const importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
@ -895,7 +891,7 @@ namespace ts.Completions {
node => {
let requiredModifiers = ModifierFlags.None;
if (isAbstract) {
requiredModifiers |= ModifierFlags.Abstract;
requiredModifiers |= ModifierFlags.Abstract;
}
if (isClassElement(node)
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === MemberOverrideStatus.NeedsOverride) {
@ -919,10 +915,14 @@ namespace ts.Completions {
completionNodes.push(node);
},
body,
codefix.PreserveOptionalFlags.Property,
isAbstract);
if (completionNodes.length) {
insertText = printer.printSnippetList(ListFormat.MultiLine, factory.createNodeArray(completionNodes), sourceFile);
insertText = printer.printSnippetList(
ListFormat.MultiLine | ListFormat.NoTrailingNewLine,
factory.createNodeArray(completionNodes),
sourceFile);
}
return { insertText, isSnippet, importAdder };
@ -3525,6 +3525,7 @@ namespace ts.Completions {
// function f<T>(x: T) {}
// f({ abc/**/: "" }) // `abc` is a member of `T` but only because it declares itself
function hasDeclarationOtherThanSelf(member: Symbol) {
if (!length(member.declarations)) return true;
return some(member.declarations, decl => decl.parent !== obj);
}
}
@ -3888,5 +3889,6 @@ namespace ts.Completions {
}
return charCode;
}
}

View file

@ -1323,7 +1323,7 @@ namespace ts.FindAllReferences {
if (!symbol) return undefined;
for (const token of getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer)) {
if (!isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) continue;
const referenceSymbol: Symbol = checker.getSymbolAtLocation(token)!; // See GH#19955 for why the type annotation is necessary
const referenceSymbol = checker.getSymbolAtLocation(token)!;
if (referenceSymbol === symbol
|| checker.getShorthandAssignmentValueSymbol(token.parent) === symbol
|| isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) {

View file

@ -198,14 +198,17 @@ namespace ts.GoToDefinition {
return undefined;
}
const symbol = typeChecker.getSymbolAtLocation(node);
const symbol = getSymbol(node, typeChecker);
if (!symbol) return undefined;
const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
const returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
const fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
// If a function returns 'void' or some other type with no definition, just return the function definition.
return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
return typeDefinitions.length ? typeDefinitions
: !(symbol.flags & SymbolFlags.Value) && symbol.flags & SymbolFlags.Type ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node)
: undefined;
}
function definitionFromType(type: Type, checker: TypeChecker, node: Node): readonly DefinitionInfo[] {

View file

@ -34,7 +34,7 @@ namespace ts.OutliningElementsCollector {
if (depthRemaining === 0) return;
cancellationToken.throwIfCancellationRequested();
if (isDeclaration(n) || isVariableStatement(n) || isReturnStatement(n) || n.kind === SyntaxKind.EndOfFileToken) {
if (isDeclaration(n) || isVariableStatement(n) || isReturnStatement(n) || isCallOrNewExpression(n) || n.kind === SyntaxKind.EndOfFileToken) {
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
}

View file

@ -314,8 +314,7 @@ namespace ts.refactor.extractSymbol {
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
const statements: Statement[] = [];
const start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248
for (const statement of (start2.parent as BlockLike).statements) {
for (const statement of start.parent.statements) {
if (statement === start || statements.length) {
const errors = checkNode(statement);
if (errors) {
@ -364,10 +363,11 @@ namespace ts.refactor.extractSymbol {
return node.expression;
}
}
else if (isVariableStatement(node)) {
else if (isVariableStatement(node) || isVariableDeclarationList(node)) {
const declarations = isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
let numInitializers = 0;
let lastInitializer: Expression | undefined;
for (const declaration of node.declarationList.declarations) {
for (const declaration of declarations) {
if (declaration.initializer) {
numInitializers++;
lastInitializer = declaration.initializer;
@ -383,7 +383,6 @@ namespace ts.refactor.extractSymbol {
return node.initializer;
}
}
return node;
}

View file

@ -599,10 +599,11 @@ namespace ts {
}
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
if (hasStaticModifier(declaration)) return;
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
if (!classOrInterfaceDeclaration) {
return;
}
if (!classOrInterfaceDeclaration) return;
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
return symbol ? cb(symbol) : undefined;

View file

@ -494,6 +494,27 @@ namespace ts.textChanges {
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
}
public addJSDocTags(sourceFile: SourceFile, parent: HasJSDoc, newTags: readonly JSDocTag[]): void {
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
const unmergedNewTags = newTags.filter(newTag => !oldTags.some((tag, i) => {
const merged = tryMergeJsdocTags(tag, newTag);
if (merged) oldTags[i] = merged;
return !!merged;
}));
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...oldTags, ...unmergedNewTags]));
const host = updateJSDocHost(parent);
this.insertJsdocCommentBefore(sourceFile, host, tag);
}
public filterJSDocTags(sourceFile: SourceFile, parent: HasJSDoc, predicate: (tag: JSDocTag) => boolean): void {
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...(filter(oldTags, predicate) || emptyArray)]));
const host = updateJSDocHost(parent);
this.insertJsdocCommentBefore(sourceFile, host, tag);
}
public replaceRangeWithText(sourceFile: SourceFile, range: TextRange, text: string): void {
this.changes.push({ kind: ChangeKind.Text, sourceFile, range, text });
}
@ -920,6 +941,35 @@ namespace ts.textChanges {
}
}
function updateJSDocHost(parent: HasJSDoc): HasJSDoc {
if (parent.kind !== SyntaxKind.ArrowFunction) {
return parent;
}
const jsDocNode = parent.parent.kind === SyntaxKind.PropertyDeclaration ?
parent.parent as HasJSDoc :
parent.parent.parent as HasJSDoc;
jsDocNode.jsDoc = parent.jsDoc;
jsDocNode.jsDocCache = parent.jsDocCache;
return jsDocNode;
}
function tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined {
if (oldTag.kind !== newTag.kind) {
return undefined;
}
switch (oldTag.kind) {
case SyntaxKind.JSDocParameterTag: {
const oldParam = oldTag as JSDocParameterTag;
const newParam = newTag as JSDocParameterTag;
return isIdentifier(oldParam.name) && isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
? factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
: undefined;
}
case SyntaxKind.JSDocReturnTag:
return factory.createJSDocReturnTag(/*tagName*/ undefined, (newTag as JSDocReturnTag).typeExpression, oldTag.comment);
}
}
// find first non-whitespace position in the leading trivia of the node
function startPositionToDeleteNodeInList(sourceFile: SourceFile, node: Node): number {
return skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);

View file

@ -211,7 +211,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'esnext'.",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,

View file

@ -182,34 +182,3 @@ describe("unittests:: Public APIs:: getChild* methods on EndOfFileToken with JSD
assert.equal(endOfFileToken.getChildCount(), 1);
assert.notEqual(endOfFileToken.getChildAt(0), /*expected*/ undefined);
});
describe("unittests:: Public APIs:: sys", () => {
it("readDirectory", () => {
// #45990, testing passing a non-absolute path
// `sys.readDirectory` is just `matchFiles` plugged into the real FS
const read = ts.matchFiles(
/*path*/ "",
/*extensions*/ [".ts", ".tsx"],
/*excludes*/ ["node_modules", "dist"],
/*includes*/ ["**/*"],
/*useCaseSensitiveFileNames*/ true,
/*currentDirectory*/ "/",
/*depth*/ undefined,
/*getFileSystemEntries*/ path => {
switch (path) {
case "/": return { directories: [], files: ["file.ts"] };
default: return { directories: [], files: [] };
}
},
/*realpath*/ ts.identity,
/*directoryExists*/ path => {
switch (path) {
case "/": return true;
default: return false;
}
}
);
assert.deepEqual(read, ["/file.ts"]);
});
});

View file

@ -191,7 +191,7 @@ namespace ts {
testExtractRange("extractRange28", `[#|return [$|1|];|]`);
// For statements
testExtractRange("extractRange29", `for ([#|var i = 1|]; i < 2; i++) {}`);
testExtractRange("extractRange29", `for ([#|var i = [$|1|]|]; i < 2; i++) {}`);
testExtractRange("extractRange30", `for (var i = [#|[$|1|]|]; i < 2; i++) {}`);
});

View file

@ -326,7 +326,7 @@ namespace ts.projectSystem {
};
function updateFile(path: string, newText: string) {
Debug.assertDefined(files.find(f => f.path === path));
Debug.assertIsDefined(files.find(f => f.path === path));
session.executeCommandSeq<protocol.ApplyChangedToOpenFilesRequest>({
command: protocol.CommandTypes.ApplyChangedToOpenFiles,
arguments: {
@ -339,7 +339,7 @@ namespace ts.projectSystem {
}
function findAllReferences(file: string, line: number, offset: number) {
Debug.assertDefined(files.find(f => f.path === file));
Debug.assertIsDefined(files.find(f => f.path === file));
session.executeCommandSeq<protocol.ReferencesRequest>({
command: protocol.CommandTypes.References,
arguments: {

View file

@ -897,7 +897,7 @@ declare namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsToken;
readonly assertsModifier?: AssertsKeyword;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -968,7 +968,7 @@ declare namespace ts {
}
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -1465,7 +1465,7 @@ declare namespace ts {
}
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeywordToken;
readonly awaitModifier?: AwaitKeyword;
readonly initializer: ForInitializer;
readonly expression: Expression;
}
@ -3078,6 +3078,7 @@ declare namespace ts {
ES2019 = 6,
ES2020 = 7,
ES2021 = 8,
ES2022 = 9,
ESNext = 99,
JSON = 100,
Latest = 99
@ -9666,6 +9667,7 @@ declare namespace ts.server.protocol {
ES2019 = "ES2019",
ES2020 = "ES2020",
ES2021 = "ES2021",
ES2022 = "ES2022",
ESNext = "ESNext"
}
enum ClassificationType {

View file

@ -897,7 +897,7 @@ declare namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsToken;
readonly assertsModifier?: AssertsKeyword;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -968,7 +968,7 @@ declare namespace ts {
}
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -1465,7 +1465,7 @@ declare namespace ts {
}
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeywordToken;
readonly awaitModifier?: AwaitKeyword;
readonly initializer: ForInitializer;
readonly expression: Expression;
}
@ -3078,6 +3078,7 @@ declare namespace ts {
ES2019 = 6,
ES2020 = 7,
ES2021 = 8,
ES2022 = 9,
ESNext = 99,
JSON = 100,
Latest = 99

View file

@ -0,0 +1,46 @@
/a.js(18,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
==== /a.js (1 errors) ====
class A {
/**
* Constructor
*
* @param {object} [foo={}]
*/
constructor(foo = {}) {
const key = "bar";
/**
* @type object
*/
this.foo = foo;
/**
* @type object
*/
const arguments = this.arguments;
~~~~~~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
/**
* @type object
*/
this.bar = arguments.bar;
/**
* @type object
*/
this.baz = arguments[key];
/**
* @type object
*/
this.options = arguments;
}
get arguments() {
return { bar: {} };
}
}

View file

@ -0,0 +1,44 @@
/a.js(16,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
==== /a.js (1 errors) ====
class A {
/**
* @param {object} [foo={}]
*/
m(foo = {}) {
const key = "bar";
/**
* @type object
*/
this.foo = foo;
/**
* @type object
*/
const arguments = this.arguments;
~~~~~~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
/**
* @type object
*/
this.bar = arguments.bar;
/**
* @type object
*/
this.baz = arguments[key];
/**
* @type object
*/
this.options = arguments;
}
get arguments() {
return { bar: {} };
}
}

View file

@ -0,0 +1,18 @@
//// [callChainWithSuper.ts]
// GH#34952
class Base { method?() {} }
class Derived extends Base {
method1() { return super.method?.(); }
method2() { return super["method"]?.(); }
}
//// [callChainWithSuper.js]
"use strict";
// GH#34952
class Base {
method() { }
}
class Derived extends Base {
method1() { return super.method?.(); }
method2() { return super["method"]?.(); }
}

View file

@ -30,7 +30,7 @@ declare const pli: {
(streams: ReadonlyArray<R | W | RW>): Promise<void>;
>streams : Symbol(streams, Decl(callWithSpread4.ts, 5, 5))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more)
>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0))
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
@ -43,7 +43,7 @@ declare const pli: {
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
>streams : Symbol(streams, Decl(callWithSpread4.ts, 6, 23))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

View file

@ -0,0 +1,9 @@
//// [defaultNamedExportWithType1.ts]
type Foo = number;
export const Foo = 1;
export default Foo;
//// [defaultNamedExportWithType1.js]
export const Foo = 1;
export default Foo;

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
type Foo = number;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))
export const Foo = 1;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 1, 12))
export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
type Foo = number;
>Foo : number
export const Foo = 1;
>Foo : 1
>1 : 1
export default Foo;
>Foo : number

View file

@ -0,0 +1,9 @@
//// [defaultNamedExportWithType2.ts]
type Foo = number;
const Foo = 1;
export default Foo;
//// [defaultNamedExportWithType2.js]
const Foo = 1;
export default Foo;

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
type Foo = number;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
const Foo = 1;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
type Foo = number;
>Foo : number
const Foo = 1;
>Foo : 1
>1 : 1
export default Foo;
>Foo : number

View file

@ -0,0 +1,9 @@
//// [defaultNamedExportWithType3.ts]
interface Foo {}
export const Foo = {};
export default Foo;
//// [defaultNamedExportWithType3.js]
export const Foo = {};
export default Foo;

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
interface Foo {}
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))
export const Foo = {};
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 1, 12))
export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
interface Foo {}
export const Foo = {};
>Foo : {}
>{} : {}
export default Foo;
>Foo : Foo

View file

@ -0,0 +1,9 @@
//// [defaultNamedExportWithType4.ts]
interface Foo {}
const Foo = {};
export default Foo;
//// [defaultNamedExportWithType4.js]
const Foo = {};
export default Foo;

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
interface Foo {}
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
const Foo = {};
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
interface Foo {}
const Foo = {};
>Foo : {}
>{} : {}
export default Foo;
>Foo : Foo

View file

@ -16,7 +16,7 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(20,27): err
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(21,35): error TS2583: Cannot find name 'AsyncGeneratorFunction'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(22,26): error TS2583: Cannot find name 'AsyncIterable'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(23,34): error TS2583: Cannot find name 'AsyncIterableIterator'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(24,70): error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(24,70): error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(27,26): error TS2550: Property 'flat' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(28,29): error TS2550: Property 'flatMap' does not exist on type 'undefined[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(29,49): error TS2550: Property 'fromEntries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later.
@ -95,7 +95,7 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): err
!!! error TS2583: Cannot find name 'AsyncIterableIterator'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts();
~~~~~~~~~~~~~
!!! error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
!!! error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later.
// es2019
const testArrayFlat = [].flat();

View file

@ -43,6 +43,7 @@ var x = 0;
var y = "";
var z = 0;
//// [duplicateVarsAcrossFileBoundaries_4.js]
var p = P;
var q;
//// [duplicateVarsAcrossFileBoundaries_5.js]
var p;

View file

@ -3,6 +3,6 @@ enum E {
>E : Symbol(E, Decl(enumWithUnicodeEscape1.ts, 0, 0))
'gold \u2730'
>'gold \u2730' : Symbol(E['gold u2730'], Decl(enumWithUnicodeEscape1.ts, 0, 8))
>'gold \u2730' : Symbol(E['gold \u2730'], Decl(enumWithUnicodeEscape1.ts, 0, 8))
}

View file

@ -0,0 +1,8 @@
tests/cases/compiler/errorCause.ts(1,18): error TS2554: Expected 0-1 arguments, but got 2.
==== tests/cases/compiler/errorCause.ts (1 errors) ====
new Error("foo", { cause: new Error("bar") });
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 0-1 arguments, but got 2.

View file

@ -0,0 +1,6 @@
//// [errorCause.ts]
new Error("foo", { cause: new Error("bar") });
//// [errorCause.js]
new Error("foo", { cause: new Error("bar") });

View file

@ -0,0 +1,6 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>new Error("foo", { cause: new Error("bar") }) : Error
>Error : ErrorConstructor
>"foo" : "foo"
>{ cause: new Error("bar") } : { cause: Error; }
>cause : Error
>new Error("bar") : Error
>Error : ErrorConstructor
>"bar" : "bar"

View file

@ -0,0 +1,6 @@
//// [errorCause.ts]
new Error("foo", { cause: new Error("bar") });
//// [errorCause.js]
new Error("foo", { cause: new Error("bar") });

View file

@ -0,0 +1,6 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>new Error("foo", { cause: new Error("bar") }) : Error
>Error : ErrorConstructor
>"foo" : "foo"
>{ cause: new Error("bar") } : { cause: Error; }
>cause : Error
>new Error("bar") : Error
>Error : ErrorConstructor
>"bar" : "bar"

View file

@ -0,0 +1,6 @@
//// [errorCause.ts]
new Error("foo", { cause: new Error("bar") });
//// [errorCause.js]
new Error("foo", { cause: new Error("bar") });

View file

@ -0,0 +1,6 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/errorCause.ts ===
new Error("foo", { cause: new Error("bar") });
>new Error("foo", { cause: new Error("bar") }) : Error
>Error : ErrorConstructor
>"foo" : "foo"
>{ cause: new Error("bar") } : { cause: Error; }
>cause : Error
>new Error("bar") : Error
>Error : ErrorConstructor
>"bar" : "bar"

View file

@ -297,7 +297,7 @@ export class IterableWeakMap<K extends object, V> implements WeakMap<K, V> {
Object.defineProperties(IterableWeakMap.prototype, {
>Object.defineProperties : Symbol(ObjectConstructor.defineProperties, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.object.d.ts, --, --))
>defineProperties : Symbol(ObjectConstructor.defineProperties, Decl(lib.es5.d.ts, --, --))
>IterableWeakMap.prototype : Symbol(IterableWeakMap.prototype)
>IterableWeakMap : Symbol(IterableWeakMap, Decl(esNextWeakRefs_IterableWeakMap.ts, 6, 2))
@ -322,7 +322,7 @@ Object.defineProperties(IterableWeakMap.prototype, {
>value : Symbol(value, Decl(esNextWeakRefs_IterableWeakMap.ts, 89, 23))
>Object.getOwnPropertyDescriptor( IterableWeakMap.prototype, "entries", )!.value : Symbol(PropertyDescriptor.value, Decl(lib.es5.d.ts, --, --))
>Object.getOwnPropertyDescriptor : Symbol(ObjectConstructor.getOwnPropertyDescriptor, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.object.d.ts, --, --))
>getOwnPropertyDescriptor : Symbol(ObjectConstructor.getOwnPropertyDescriptor, Decl(lib.es5.d.ts, --, --))
IterableWeakMap.prototype,

View file

@ -15,7 +15,7 @@ const bar = foo.flatMap(bar => bar as Foo);
interface Foo extends Array<string> {}
>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
// Repros from comments in #43249

View file

@ -8,6 +8,6 @@ export = x;
//// [importDeclWithExportModifierAndExportAssignment.js]
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = x.c;
module.exports = x;

View file

@ -4,7 +4,7 @@ declare module "foo";
=== tests/cases/compiler/default.ts ===
/*1*/ export /*2*/ default /*3*/ Array /*4*/;
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
=== tests/cases/compiler/index.ts ===
/*1*/ import /*2*/ D /*3*/, /*4*/ { /*5*/ A /*6*/, /*7*/ B /*8*/ as /*9*/ C /*10*/ } /*11*/ from /*12*/ "foo";

View file

@ -0,0 +1,56 @@
tests/cases/compiler/indexAt.ts(1,5): error TS2550: Property 'at' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(2,7): error TS2550: Property 'at' does not exist on type '"foo"'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(3,17): error TS2550: Property 'at' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(4,18): error TS2550: Property 'at' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(5,25): error TS2550: Property 'at' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(6,18): error TS2550: Property 'at' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(7,19): error TS2550: Property 'at' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(8,18): error TS2550: Property 'at' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(9,19): error TS2550: Property 'at' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(10,20): error TS2550: Property 'at' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(11,20): error TS2550: Property 'at' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(12,21): error TS2550: Property 'at' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(13,22): error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
==== tests/cases/compiler/indexAt.ts (13 errors) ====
[0].at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
"foo".at(0);
~~
!!! error TS2550: Property 'at' does not exist on type '"foo"'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int8Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint8Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint8ClampedArray().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int16Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint16Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int32Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint32Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Float32Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Float64Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new BigInt64Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new BigUint64Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.

View file

@ -0,0 +1,30 @@
//// [indexAt.ts]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);
//// [indexAt.js]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);

View file

@ -0,0 +1,36 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Uint8Array().at(0);
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Uint8ClampedArray().at(0);
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Int16Array().at(0);
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Uint16Array().at(0);
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Int32Array().at(0);
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Uint32Array().at(0);
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Float32Array().at(0);
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new Float64Array().at(0);
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
new BigInt64Array().at(0);
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
new BigUint64Array().at(0);
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))

View file

@ -0,0 +1,104 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
>[0].at(0) : any
>[0].at : any
>[0] : number[]
>0 : 0
>at : any
>0 : 0
"foo".at(0);
>"foo".at(0) : any
>"foo".at : any
>"foo" : "foo"
>at : any
>0 : 0
new Int8Array().at(0);
>new Int8Array().at(0) : any
>new Int8Array().at : any
>new Int8Array() : Int8Array
>Int8Array : Int8ArrayConstructor
>at : any
>0 : 0
new Uint8Array().at(0);
>new Uint8Array().at(0) : any
>new Uint8Array().at : any
>new Uint8Array() : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>at : any
>0 : 0
new Uint8ClampedArray().at(0);
>new Uint8ClampedArray().at(0) : any
>new Uint8ClampedArray().at : any
>new Uint8ClampedArray() : Uint8ClampedArray
>Uint8ClampedArray : Uint8ClampedArrayConstructor
>at : any
>0 : 0
new Int16Array().at(0);
>new Int16Array().at(0) : any
>new Int16Array().at : any
>new Int16Array() : Int16Array
>Int16Array : Int16ArrayConstructor
>at : any
>0 : 0
new Uint16Array().at(0);
>new Uint16Array().at(0) : any
>new Uint16Array().at : any
>new Uint16Array() : Uint16Array
>Uint16Array : Uint16ArrayConstructor
>at : any
>0 : 0
new Int32Array().at(0);
>new Int32Array().at(0) : any
>new Int32Array().at : any
>new Int32Array() : Int32Array
>Int32Array : Int32ArrayConstructor
>at : any
>0 : 0
new Uint32Array().at(0);
>new Uint32Array().at(0) : any
>new Uint32Array().at : any
>new Uint32Array() : Uint32Array
>Uint32Array : Uint32ArrayConstructor
>at : any
>0 : 0
new Float32Array().at(0);
>new Float32Array().at(0) : any
>new Float32Array().at : any
>new Float32Array() : Float32Array
>Float32Array : Float32ArrayConstructor
>at : any
>0 : 0
new Float64Array().at(0);
>new Float64Array().at(0) : any
>new Float64Array().at : any
>new Float64Array() : Float64Array
>Float64Array : Float64ArrayConstructor
>at : any
>0 : 0
new BigInt64Array().at(0);
>new BigInt64Array().at(0) : any
>new BigInt64Array().at : any
>new BigInt64Array() : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>at : any
>0 : 0
new BigUint64Array().at(0);
>new BigUint64Array().at(0) : any
>new BigUint64Array().at : any
>new BigUint64Array() : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>at : any
>0 : 0

View file

@ -0,0 +1,30 @@
//// [indexAt.ts]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);
//// [indexAt.js]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);

View file

@ -0,0 +1,64 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
>[0].at : Symbol(Array.at, Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(Array.at, Decl(lib.es2022.array.d.ts, --, --))
"foo".at(0);
>"foo".at : Symbol(String.at, Decl(lib.es2022.string.d.ts, --, --))
>at : Symbol(String.at, Decl(lib.es2022.string.d.ts, --, --))
new Int8Array().at(0);
>new Int8Array().at : Symbol(Int8Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int8Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint8Array().at(0);
>new Uint8Array().at : Symbol(Uint8Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint8Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint8ClampedArray().at(0);
>new Uint8ClampedArray().at : Symbol(Uint8ClampedArray.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint8ClampedArray.at, Decl(lib.es2022.array.d.ts, --, --))
new Int16Array().at(0);
>new Int16Array().at : Symbol(Int16Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int16Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint16Array().at(0);
>new Uint16Array().at : Symbol(Uint16Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint16Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Int32Array().at(0);
>new Int32Array().at : Symbol(Int32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint32Array().at(0);
>new Uint32Array().at : Symbol(Uint32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Float32Array().at(0);
>new Float32Array().at : Symbol(Float32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Float32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Float64Array().at(0);
>new Float64Array().at : Symbol(Float64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Float64Array.at, Decl(lib.es2022.array.d.ts, --, --))
new BigInt64Array().at(0);
>new BigInt64Array().at : Symbol(BigInt64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(BigInt64Array.at, Decl(lib.es2022.array.d.ts, --, --))
new BigUint64Array().at(0);
>new BigUint64Array().at : Symbol(BigUint64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(BigUint64Array.at, Decl(lib.es2022.array.d.ts, --, --))

View file

@ -0,0 +1,104 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
>[0].at(0) : number
>[0].at : (index: number) => number
>[0] : number[]
>0 : 0
>at : (index: number) => number
>0 : 0
"foo".at(0);
>"foo".at(0) : string
>"foo".at : (index: number) => string
>"foo" : "foo"
>at : (index: number) => string
>0 : 0
new Int8Array().at(0);
>new Int8Array().at(0) : number
>new Int8Array().at : (index: number) => number
>new Int8Array() : Int8Array
>Int8Array : Int8ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint8Array().at(0);
>new Uint8Array().at(0) : number
>new Uint8Array().at : (index: number) => number
>new Uint8Array() : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint8ClampedArray().at(0);
>new Uint8ClampedArray().at(0) : number
>new Uint8ClampedArray().at : (index: number) => number
>new Uint8ClampedArray() : Uint8ClampedArray
>Uint8ClampedArray : Uint8ClampedArrayConstructor
>at : (index: number) => number
>0 : 0
new Int16Array().at(0);
>new Int16Array().at(0) : number
>new Int16Array().at : (index: number) => number
>new Int16Array() : Int16Array
>Int16Array : Int16ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint16Array().at(0);
>new Uint16Array().at(0) : number
>new Uint16Array().at : (index: number) => number
>new Uint16Array() : Uint16Array
>Uint16Array : Uint16ArrayConstructor
>at : (index: number) => number
>0 : 0
new Int32Array().at(0);
>new Int32Array().at(0) : number
>new Int32Array().at : (index: number) => number
>new Int32Array() : Int32Array
>Int32Array : Int32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint32Array().at(0);
>new Uint32Array().at(0) : number
>new Uint32Array().at : (index: number) => number
>new Uint32Array() : Uint32Array
>Uint32Array : Uint32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Float32Array().at(0);
>new Float32Array().at(0) : number
>new Float32Array().at : (index: number) => number
>new Float32Array() : Float32Array
>Float32Array : Float32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Float64Array().at(0);
>new Float64Array().at(0) : number
>new Float64Array().at : (index: number) => number
>new Float64Array() : Float64Array
>Float64Array : Float64ArrayConstructor
>at : (index: number) => number
>0 : 0
new BigInt64Array().at(0);
>new BigInt64Array().at(0) : bigint
>new BigInt64Array().at : (index: number) => bigint
>new BigInt64Array() : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>at : (index: number) => bigint
>0 : 0
new BigUint64Array().at(0);
>new BigUint64Array().at(0) : bigint
>new BigUint64Array().at : (index: number) => bigint
>new BigUint64Array() : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>at : (index: number) => bigint
>0 : 0

View file

@ -0,0 +1,30 @@
//// [indexAt.ts]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);
//// [indexAt.js]
[0].at(0);
"foo".at(0);
new Int8Array().at(0);
new Uint8Array().at(0);
new Uint8ClampedArray().at(0);
new Int16Array().at(0);
new Uint16Array().at(0);
new Int32Array().at(0);
new Uint32Array().at(0);
new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);

View file

@ -0,0 +1,64 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
>[0].at : Symbol(Array.at, Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(Array.at, Decl(lib.es2022.array.d.ts, --, --))
"foo".at(0);
>"foo".at : Symbol(String.at, Decl(lib.es2022.string.d.ts, --, --))
>at : Symbol(String.at, Decl(lib.es2022.string.d.ts, --, --))
new Int8Array().at(0);
>new Int8Array().at : Symbol(Int8Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int8Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint8Array().at(0);
>new Uint8Array().at : Symbol(Uint8Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint8Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint8ClampedArray().at(0);
>new Uint8ClampedArray().at : Symbol(Uint8ClampedArray.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint8ClampedArray.at, Decl(lib.es2022.array.d.ts, --, --))
new Int16Array().at(0);
>new Int16Array().at : Symbol(Int16Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int16Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint16Array().at(0);
>new Uint16Array().at : Symbol(Uint16Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint16Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Int32Array().at(0);
>new Int32Array().at : Symbol(Int32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Int32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Uint32Array().at(0);
>new Uint32Array().at : Symbol(Uint32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Uint32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Float32Array().at(0);
>new Float32Array().at : Symbol(Float32Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Float32Array.at, Decl(lib.es2022.array.d.ts, --, --))
new Float64Array().at(0);
>new Float64Array().at : Symbol(Float64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 1 more)
>at : Symbol(Float64Array.at, Decl(lib.es2022.array.d.ts, --, --))
new BigInt64Array().at(0);
>new BigInt64Array().at : Symbol(BigInt64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(BigInt64Array.at, Decl(lib.es2022.array.d.ts, --, --))
new BigUint64Array().at(0);
>new BigUint64Array().at : Symbol(BigUint64Array.at, Decl(lib.es2022.array.d.ts, --, --))
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2022.array.d.ts, --, --))
>at : Symbol(BigUint64Array.at, Decl(lib.es2022.array.d.ts, --, --))

View file

@ -0,0 +1,104 @@
=== tests/cases/compiler/indexAt.ts ===
[0].at(0);
>[0].at(0) : number
>[0].at : (index: number) => number
>[0] : number[]
>0 : 0
>at : (index: number) => number
>0 : 0
"foo".at(0);
>"foo".at(0) : string
>"foo".at : (index: number) => string
>"foo" : "foo"
>at : (index: number) => string
>0 : 0
new Int8Array().at(0);
>new Int8Array().at(0) : number
>new Int8Array().at : (index: number) => number
>new Int8Array() : Int8Array
>Int8Array : Int8ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint8Array().at(0);
>new Uint8Array().at(0) : number
>new Uint8Array().at : (index: number) => number
>new Uint8Array() : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint8ClampedArray().at(0);
>new Uint8ClampedArray().at(0) : number
>new Uint8ClampedArray().at : (index: number) => number
>new Uint8ClampedArray() : Uint8ClampedArray
>Uint8ClampedArray : Uint8ClampedArrayConstructor
>at : (index: number) => number
>0 : 0
new Int16Array().at(0);
>new Int16Array().at(0) : number
>new Int16Array().at : (index: number) => number
>new Int16Array() : Int16Array
>Int16Array : Int16ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint16Array().at(0);
>new Uint16Array().at(0) : number
>new Uint16Array().at : (index: number) => number
>new Uint16Array() : Uint16Array
>Uint16Array : Uint16ArrayConstructor
>at : (index: number) => number
>0 : 0
new Int32Array().at(0);
>new Int32Array().at(0) : number
>new Int32Array().at : (index: number) => number
>new Int32Array() : Int32Array
>Int32Array : Int32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Uint32Array().at(0);
>new Uint32Array().at(0) : number
>new Uint32Array().at : (index: number) => number
>new Uint32Array() : Uint32Array
>Uint32Array : Uint32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Float32Array().at(0);
>new Float32Array().at(0) : number
>new Float32Array().at : (index: number) => number
>new Float32Array() : Float32Array
>Float32Array : Float32ArrayConstructor
>at : (index: number) => number
>0 : 0
new Float64Array().at(0);
>new Float64Array().at(0) : number
>new Float64Array().at : (index: number) => number
>new Float64Array() : Float64Array
>Float64Array : Float64ArrayConstructor
>at : (index: number) => number
>0 : 0
new BigInt64Array().at(0);
>new BigInt64Array().at(0) : bigint
>new BigInt64Array().at : (index: number) => bigint
>new BigInt64Array() : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>at : (index: number) => bigint
>0 : 0
new BigUint64Array().at(0);
>new BigUint64Array().at(0) : bigint
>new BigUint64Array().at : (index: number) => bigint
>new BigUint64Array() : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>at : (index: number) => bigint
>0 : 0

View file

@ -72,7 +72,7 @@ const query = Object.entries(obj).map(
>Object.entries(obj).map( ([k, v]) => `${k}=${encodeURIComponent(v)}`).join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --))
>Object.entries(obj).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.object.d.ts, --, --))
>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
>obj : Symbol(obj, Decl(inferenceOptionalPropertiesToIndexSignatures.ts, 16, 5))
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))

View file

@ -1,12 +1,18 @@
tests/cases/compiler/export.js(1,13): error TS2451: Cannot redeclare block-scoped variable 'foo'.
tests/cases/compiler/export.js(1,13): error TS8008: Type aliases can only be used in TypeScript files.
tests/cases/compiler/export.js(6,14): error TS2451: Cannot redeclare block-scoped variable 'foo'.
==== tests/cases/compiler/export.js (1 errors) ====
==== tests/cases/compiler/export.js (3 errors) ====
export type foo = 5;
~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'foo'.
~~~
!!! error TS8008: Type aliases can only be used in TypeScript files.
/**
* @typedef {{
* }}
*/
export const foo = 5;
export const foo = 5;
~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'foo'.

View file

@ -440,9 +440,9 @@ function fn<T extends {elements: Array<string>} | {elements: Array<number>}>(par
>fn : Symbol(fn, Decl(keyofAndIndexedAccess2.ts, 115, 69))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 119, 12))
>elements : Symbol(elements, Decl(keyofAndIndexedAccess2.ts, 119, 23))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
>elements : Symbol(elements, Decl(keyofAndIndexedAccess2.ts, 119, 51))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
>param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 119, 77))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 119, 12))
>cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 119, 86))
@ -459,7 +459,7 @@ function fn<T extends {elements: Array<string>} | {elements: Array<number>}>(par
function fn2<T extends Array<string>>(param: T, cb: (element: T[number]) => void) {
>fn2 : Symbol(fn2, Decl(keyofAndIndexedAccess2.ts, 121, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 123, 13))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
>param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 123, 38))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 123, 13))
>cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 123, 47))
@ -476,7 +476,7 @@ function fn2<T extends Array<string>>(param: T, cb: (element: T[number]) => void
function fn3<T extends ReadonlyArray<string>>(param: T, cb: (element: T[number]) => void) {
>fn3 : Symbol(fn3, Decl(keyofAndIndexedAccess2.ts, 125, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more)
>param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 129, 46))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13))
>cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 129, 55))
@ -494,12 +494,12 @@ function fn4<K extends number>() {
let x: Array<string>[K] = 'abc';
>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 134, 7))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13))
let y: ReadonlyArray<string>[K] = 'abc';
>y : Symbol(y, Decl(keyofAndIndexedAccess2.ts, 135, 7))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more)
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13))
}

View file

@ -0,0 +1,84 @@
//// [tests/cases/conformance/node/legacyNodeModulesExportsSpecifierGenerationConditions.ts] ////
//// [index.ts]
export const a = async () => (await import("inner")).x();
//// [index.d.ts]
export { x } from "./other.js";
//// [other.d.ts]
import { Thing } from "./private.js"
export const x: () => Thing;
//// [private.d.ts]
export interface Thing {} // not exported in export map, inaccessible under new module modes
//// [package.json]
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.js"
}
//// [package.json]
{
"name": "inner",
"private": true,
"type": "module",
"exports": {
".": {
"default": "./index.js"
},
"./other": {
"default": "./other.js"
}
}
}
//// [index.js]
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
exports.__esModule = true;
exports.a = void 0;
var a = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require("inner"); })];
case 1: return [2 /*return*/, (_a.sent()).x()];
}
}); }); };
exports.a = a;
//// [index.d.ts]
export declare const a: () => Promise<import("inner/private").Thing>;

View file

@ -0,0 +1,23 @@
=== tests/cases/conformance/node/index.ts ===
export const a = async () => (await import("inner")).x();
>a : Symbol(a, Decl(index.ts, 0, 12))
>(await import("inner")).x : Symbol(x, Decl(index.d.ts, 0, 8))
>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0))
>x : Symbol(x, Decl(index.d.ts, 0, 8))
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
export { x } from "./other.js";
>x : Symbol(x, Decl(index.d.ts, 0, 8))
=== tests/cases/conformance/node/node_modules/inner/other.d.ts ===
import { Thing } from "./private.js"
>Thing : Symbol(Thing, Decl(other.d.ts, 0, 8))
export const x: () => Thing;
>x : Symbol(x, Decl(other.d.ts, 1, 12))
>Thing : Symbol(Thing, Decl(other.d.ts, 0, 8))
=== tests/cases/conformance/node/node_modules/inner/private.d.ts ===
export interface Thing {} // not exported in export map, inaccessible under new module modes
>Thing : Symbol(Thing, Decl(private.d.ts, 0, 0))

View file

@ -0,0 +1,26 @@
=== tests/cases/conformance/node/index.ts ===
export const a = async () => (await import("inner")).x();
>a : () => Promise<import("tests/cases/conformance/node/node_modules/inner/private").Thing>
>async () => (await import("inner")).x() : () => Promise<import("tests/cases/conformance/node/node_modules/inner/private").Thing>
>(await import("inner")).x() : import("tests/cases/conformance/node/node_modules/inner/private").Thing
>(await import("inner")).x : () => import("tests/cases/conformance/node/node_modules/inner/private").Thing
>(await import("inner")) : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>await import("inner") : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>import("inner") : Promise<typeof import("tests/cases/conformance/node/node_modules/inner/index")>
>"inner" : "inner"
>x : () => import("tests/cases/conformance/node/node_modules/inner/private").Thing
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
export { x } from "./other.js";
>x : () => import("tests/cases/conformance/node/node_modules/inner/private").Thing
=== tests/cases/conformance/node/node_modules/inner/other.d.ts ===
import { Thing } from "./private.js"
>Thing : any
export const x: () => Thing;
>x : () => Thing
=== tests/cases/conformance/node/node_modules/inner/private.d.ts ===
export interface Thing {} // not exported in export map, inaccessible under new module modes
No type information for this code.

Some files were not shown because too many files have changed in this diff Show more