Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38295

This commit is contained in:
Alexander T
2020-05-20 20:13:50 +03:00
135 changed files with 4676 additions and 1036 deletions
+203 -216
View File
@@ -1,216 +1,203 @@
# Instructions for Logging Issues
## 1. Read the FAQ
Please [read the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) before logging new issues, even if you think you have found a bug.
Issues that ask questions answered in the FAQ will be closed without elaboration.
## 2. Search for Duplicates
[Search the existing issues](https://github.com/Microsoft/TypeScript/search?type=Issues) before logging a new one.
Some search tips:
* *Don't* restrict your search to only open issues. An issue with a title similar to yours may have been closed as a duplicate of one with a less-findable title.
* Check for synonyms. For example, if your bug involves an interface, it likely also occurs with type aliases or classes.
* Search for the title of the issue you're about to log. This sounds obvious but 80% of the time this is sufficient to find a duplicate when one exists.
* Read more than the first page of results. Many bugs here use the same words so relevancy sorting is not particularly strong.
* If you have a crash, search for the first few topmost function names shown in the call stack.
## 3. Do you have a question?
The issue tracker is for **issues**, in other words, bugs and suggestions.
If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
Due to increased traffic, we can no longer answer questions in the issue tracker.
## 4. Did you find a bug?
When logging a bug, please be sure to include the following:
* What version of TypeScript you're using (run `tsc --v`)
* If at all possible, an *isolated* way to reproduce the behavior
* The behavior you expect to see, and the actual behavior
You can try out the nightly build of TypeScript (`npm install typescript@next`) to see if the bug has already been fixed.
## 5. Do you have a suggestion?
We also accept suggestions in the issue tracker.
Be sure to [check the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) and [search](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) first.
In general, things we find useful when reviewing suggestions are:
* A description of the problem you're trying to solve
* An overview of the suggested solution
* Examples of how the suggestion would work in various places
* Code examples showing e.g. "this would be an error, this wouldn't"
* Code examples showing the generated JavaScript (if applicable)
* If relevant, precedent in other languages can be useful for establishing context and expected behavior
# Instructions for Contributing Code
## Tips
### Faster clones
The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using `git clone --depth=1`.
### Using local builds
Run `gulp` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.
## Contributing bug fixes
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog milestone") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
## Contributing features
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog" milestone) by a TypeScript project maintainer) in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
## Legal
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. Upon submitting a pull request, you will automatically be given instructions on how to sign the CLA.
## Housekeeping
Your pull request should:
* Include a description of what your change intends to do
* Be a child commit of a reasonably recent commit in the **master** branch
* Requests need not be a single commit, but should be a linear sequence of commits (i.e. no merge commits in your PR)
* It is desirable, but not necessary, for the tests to pass at each commit
* Have clear commit messages
* e.g. "Minor refactor in goToTypeDefinition", "Fix iterated type in for-await-of", "Add test for preserveWatchOutput on command line"
* Include adequate tests
* At least one test should fail in the absence of your non-test code changes. If your PR does not match this criteria, please specify why
* Tests should include reasonable permutations of the target fix/change
* Include baseline changes with your change
* All changed code must have 100% code coverage
* Follow the code conventions described in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
## Contributing `lib.d.ts` fixes
There are three relevant locations to be aware of when it comes to TypeScript's library declaration files:
* `src/lib`: the location of the sources themselves.
* `lib`: the location of the last-known-good (LKG) versions of the files which are updated periodically.
* `built/local`: the build output location, including where `src/lib` files will be copied to.
Any changes should be made to [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib). **Most** of these files can be updated by hand, with the exception of any generated files (see below).
Library files in `built/local/` are updated automatically by running the standard build task:
```sh
gulp
```
The files in `lib/` are used to bootstrap compilation and usually **should not** be updated unless publishing a new version or updating the LKG.
### Modifying generated library files
The files `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` both represent type declarations for the DOM and are auto-generated. To make any modifications to them, you will have to direct changes to https://github.com/Microsoft/TSJS-lib-generator
## Running the Tests
To run all tests, invoke the `runtests-parallel` target using gulp:
```Shell
gulp runtests-parallel
```
This will run all tests; to run only a specific subset of tests, use:
```Shell
gulp runtests --tests=<regex>
```
e.g. to run all compiler baseline tests:
```Shell
gulp runtests --tests=compiler
```
or to run a specific test: `tests\cases\compiler\2dArrays.ts`
```Shell
gulp runtests --tests=2dArrays
```
## Debugging the tests
To debug the tests, invoke the `runtests-browser` task from gulp.
You will probably only want to debug one test at a time:
```Shell
gulp runtests-browser --tests=2dArrays
```
You can specify which browser to use for debugging. Currently, Chrome and IE are supported:
```Shell
gulp runtests-browser --tests=2dArrays --browser=chrome
```
You can debug with VS Code or Node instead with `gulp runtests --inspect=true`:
```Shell
gulp runtests --tests=2dArrays --inspect=true
```
You can also use the [provided VS Code launch configuration](./.vscode/launch.template.json) to launch a debug session for an open test file. Rename the file 'launch.json', open the test file of interest, and launch the debugger from the debug panel (or press F5).
## Adding a Test
To add a new test case, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
These files support metadata tags in the format `// @metaDataName: value`.
The supported names and values are the same as those supported in the compiler itself, with the addition of the `fileName` flag.
`fileName` tags delimit sections of a file to be used as separate compilation units.
They are useful for tests relating to modules.
See below for examples.
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
### Tests for multiple files
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
```TypeScript
// @fileName: file1.ts
export function f() {
}
// @fileName: file2.ts
import { f as g } from "file1";
var x = g();
```
One can also write a project test, but it is slightly more involved.
## Managing the Baselines
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
```Shell
gulp diff
```
After verifying that the changes in the baselines are correct, run
```Shell
gulp baseline-accept
```
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
## Localization
All strings the user may see are stored in [`diagnosticMessages.json`](./src/compiler/diagnosticMessages.json).
If you make changes to it, run `gulp generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`.
See [coding guidelines on diagnostic messages](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-messages).
# Instructions for Logging Issues
## 1. Read the FAQ
Please [read the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) before logging new issues, even if you think you have found a bug.
Issues that ask questions answered in the FAQ will be closed without elaboration.
## 2. Search for Duplicates
[Search the existing issues](https://github.com/Microsoft/TypeScript/search?type=Issues) before logging a new one.
Some search tips:
* *Don't* restrict your search to only open issues. An issue with a title similar to yours may have been closed as a duplicate of one with a less-findable title.
* Check for synonyms. For example, if your bug involves an interface, it likely also occurs with type aliases or classes.
* Search for the title of the issue you're about to log. This sounds obvious but 80% of the time this is sufficient to find a duplicate when one exists.
* Read more than the first page of results. Many bugs here use the same words so relevancy sorting is not particularly strong.
* If you have a crash, search for the first few topmost function names shown in the call stack.
## 3. Do you have a question?
The issue tracker is for **issues**, in other words, bugs and suggestions.
If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
Due to increased traffic, we can no longer answer questions in the issue tracker.
## 4. Did you find a bug?
When logging a bug, please be sure to include the following:
* What version of TypeScript you're using (run `tsc --v`)
* If at all possible, an *isolated* way to reproduce the behavior
* The behavior you expect to see, and the actual behavior
You can try out the nightly build of TypeScript (`npm install typescript@next`) to see if the bug has already been fixed.
## 5. Do you have a suggestion?
We also accept suggestions in the issue tracker.
Be sure to [check the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) and [search](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) first.
In general, things we find useful when reviewing suggestions are:
* A description of the problem you're trying to solve
* An overview of the suggested solution
* Examples of how the suggestion would work in various places
* Code examples showing e.g. "this would be an error, this wouldn't"
* Code examples showing the generated JavaScript (if applicable)
* If relevant, precedent in other languages can be useful for establishing context and expected behavior
# Instructions for Contributing Code
## Tips
### Faster clones
The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using `git clone --depth=1`.
### Using local builds
Run `gulp` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.
## Contributing bug fixes
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog milestone") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
## Contributing features
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog" milestone) by a TypeScript project maintainer) in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
## Legal
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. Upon submitting a pull request, you will automatically be given instructions on how to sign the CLA.
## Housekeeping
Your pull request should:
* Include a description of what your change intends to do
* Be a child commit of a reasonably recent commit in the **master** branch
* Requests need not be a single commit, but should be a linear sequence of commits (i.e. no merge commits in your PR)
* It is desirable, but not necessary, for the tests to pass at each commit
* Have clear commit messages
* e.g. "Minor refactor in goToTypeDefinition", "Fix iterated type in for-await-of", "Add test for preserveWatchOutput on command line"
* Include adequate tests
* At least one test should fail in the absence of your non-test code changes. If your PR does not match this criteria, please specify why
* Tests should include reasonable permutations of the target fix/change
* Include baseline changes with your change
* All changed code must have 100% code coverage
* Follow the code conventions described in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
## Contributing `lib.d.ts` fixes
There are three relevant locations to be aware of when it comes to TypeScript's library declaration files:
* `src/lib`: the location of the sources themselves.
* `lib`: the location of the last-known-good (LKG) versions of the files which are updated periodically.
* `built/local`: the build output location, including where `src/lib` files will be copied to.
Any changes should be made to [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib). **Most** of these files can be updated by hand, with the exception of any generated files (see below).
Library files in `built/local/` are updated automatically by running the standard build task:
```sh
gulp
```
The files in `lib/` are used to bootstrap compilation and usually **should not** be updated unless publishing a new version or updating the LKG.
### Modifying generated library files
The files `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` both represent type declarations for the DOM and are auto-generated. To make any modifications to them, you will have to direct changes to https://github.com/Microsoft/TSJS-lib-generator
## Running the Tests
To run all tests, invoke the `runtests-parallel` target using gulp:
```Shell
gulp runtests-parallel
```
This will run all tests; to run only a specific subset of tests, use:
```Shell
gulp runtests --tests=<regex>
```
e.g. to run all compiler baseline tests:
```Shell
gulp runtests --tests=compiler
```
or to run a specific test: `tests\cases\compiler\2dArrays.ts`
```Shell
gulp runtests --tests=2dArrays
```
## Debugging the tests
You can debug with VS Code or Node instead with `gulp runtests --inspect`:
```Shell
gulp runtests --tests=2dArrays --inspect
```
You can also use the [provided VS Code launch configuration](./.vscode/launch.template.json) to launch a debug session for an open test file. Rename the file 'launch.json', open the test file of interest, and launch the debugger from the debug panel (or press F5).
## Adding a Test
To add a new test case, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
These files support metadata tags in the format `// @metaDataName: value`.
The supported names and values are the same as those supported in the compiler itself, with the addition of the `fileName` flag.
`fileName` tags delimit sections of a file to be used as separate compilation units.
They are useful for tests relating to modules.
See below for examples.
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
### Tests for multiple files
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
```TypeScript
// @fileName: file1.ts
export function f() {
}
// @fileName: file2.ts
import { f as g } from "file1";
var x = g();
```
One can also write a project test, but it is slightly more involved.
## Managing the Baselines
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
```Shell
gulp diff
```
After verifying that the changes in the baselines are correct, run
```Shell
gulp baseline-accept
```
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
## Localization
All strings the user may see are stored in [`diagnosticMessages.json`](./src/compiler/diagnosticMessages.json).
If you make changes to it, run `gulp generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`.
See [coding guidelines on diagnostic messages](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-messages).
+1 -1
View File
@@ -96,7 +96,7 @@
"source-map-support": "latest",
"through2": "latest",
"travis-fold": "latest",
"typescript": "next",
"typescript": "^3.9.3",
"vinyl": "latest",
"vinyl-sourcemaps-apply": "latest",
"xml2js": "^0.4.19"
+8 -2
View File
@@ -985,7 +985,7 @@ namespace ts {
return initFlowNode({ flags: FlowFlags.SwitchClause, antecedent, switchStatement, clauseStart, clauseEnd });
}
function createFlowMutation(flags: FlowFlags, antecedent: FlowNode, node: Node): FlowNode {
function createFlowMutation(flags: FlowFlags, antecedent: FlowNode, node: Expression | VariableDeclaration | ArrayBindingElement): FlowNode {
setFlowNodeReferenced(antecedent);
const result = initFlowNode({ flags, antecedent, node });
if (currentExceptionTarget) {
@@ -1341,7 +1341,7 @@ namespace ts {
// is potentially an assertion and is therefore included in the control flow.
if (node.expression.kind === SyntaxKind.CallExpression) {
const call = <CallExpression>node.expression;
if (isDottedName(call.expression)) {
if (isDottedName(call.expression) && call.expression.kind !== SyntaxKind.SuperKeyword) {
currentFlow = createFlowCall(currentFlow, call);
}
}
@@ -1747,6 +1747,9 @@ namespace ts {
}
else {
bindEachChild(node);
if (node.expression.kind === SyntaxKind.SuperKeyword) {
currentFlow = createFlowCall(currentFlow, node);
}
}
}
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
@@ -2464,6 +2467,9 @@ namespace ts {
node.flowNode = currentFlow;
}
return checkStrictModeIdentifier(<Identifier>node);
case SyntaxKind.SuperKeyword:
node.flowNode = currentFlow;
break;
case SyntaxKind.PrivateIdentifier:
return checkPrivateIdentifier(node as PrivateIdentifier);
case SyntaxKind.PropertyAccessExpression:
+266 -106
View File
@@ -911,6 +911,7 @@ namespace ts {
const sharedFlowNodes: FlowNode[] = [];
const sharedFlowTypes: FlowType[] = [];
const flowNodeReachable: (boolean | undefined)[] = [];
const flowNodePostSuper: (boolean | undefined)[] = [];
const potentialThisCollisions: Node[] = [];
const potentialNewTargetCollisions: Node[] = [];
const potentialWeakMapCollisions: Node[] = [];
@@ -4563,17 +4564,32 @@ namespace ts {
const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
const hasRestElement = (<TupleType>type.target).hasRestElement;
if (tupleConstituentNodes) {
for (let i = (<TupleType>type.target).minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
createRestTypeNode(createArrayTypeNode(tupleConstituentNodes[i])) :
createOptionalTypeNode(tupleConstituentNodes[i]);
if ((type.target as TupleType).labeledElementDeclarations) {
for (let i = 0; i < tupleConstituentNodes.length; i++) {
const isOptionalOrRest = i >= (<TupleType>type.target).minLength;
const isRest = isOptionalOrRest && hasRestElement && i === arity - 1;
const isOptional = isOptionalOrRest && !isRest;
tupleConstituentNodes[i] = createNamedTupleMember(
isRest ? createToken(SyntaxKind.DotDotDotToken) : undefined,
createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel((type.target as TupleType).labeledElementDeclarations![i]))),
isOptional ? createToken(SyntaxKind.QuestionToken) : undefined,
isRest ? createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
);
}
}
const tupleTypeNode = createTupleTypeNode(tupleConstituentNodes);
else {
for (let i = (<TupleType>type.target).minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
createRestTypeNode(createArrayTypeNode(tupleConstituentNodes[i])) :
createOptionalTypeNode(tupleConstituentNodes[i]);
}
}
const tupleTypeNode = setEmitFlags(createTupleTypeNode(tupleConstituentNodes), EmitFlags.SingleLine);
return (<TupleType>type.target).readonly ? createTypeOperatorNode(SyntaxKind.ReadonlyKeyword, tupleTypeNode) : tupleTypeNode;
}
}
if (context.encounteredError || (context.flags & NodeBuilderFlags.AllowEmptyTuple)) {
const tupleTypeNode = createTupleTypeNode([]);
const tupleTypeNode = setEmitFlags(createTupleTypeNode([]), EmitFlags.SingleLine);
return (<TupleType>type.target).readonly ? createTypeOperatorNode(SyntaxKind.ReadonlyKeyword, tupleTypeNode) : tupleTypeNode;
}
context.encounteredError = true;
@@ -4907,7 +4923,7 @@ namespace ts {
typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, context));
}
const parameters = getExpandedParameters(signature).map(parameter => symbolToParameterDeclaration(parameter, context, kind === SyntaxKind.Constructor, privateSymbolVisitor, bundledImports));
const parameters = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0].map(parameter => symbolToParameterDeclaration(parameter, context, kind === SyntaxKind.Constructor, privateSymbolVisitor, bundledImports));
if (signature.thisParameter) {
const thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
parameters.unshift(thisParameter);
@@ -5555,6 +5571,7 @@ namespace ts {
cancellationToken.throwIfCancellationRequested();
}
let hadError = false;
const file = getSourceFileOfNode(existing);
const transformed = visitNode(existing, visitExistingNodeTreeSymbols);
if (hadError) {
return undefined;
@@ -5683,6 +5700,10 @@ namespace ts {
}
}
if (file && isTupleTypeNode(node) && (getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line)) {
setEmitFlags(node, EmitFlags.SingleLine);
}
return visitEachChild(node, visitExistingNodeTreeSymbols, nullTransformationContext);
function getEffectiveDotDotDotForParameter(p: ParameterDeclaration) {
@@ -5949,6 +5970,7 @@ namespace ts {
}
}
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
// or a merge of some number of those.
// An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping
@@ -6317,7 +6339,10 @@ namespace ts {
const baseTypes = getBaseTypes(classType);
const implementsTypes = getImplementsTypes(classType);
const staticType = getTypeOfSymbol(symbol);
const staticBaseType = getBaseConstructorTypeOfClass(staticType as InterfaceType);
const isClass = !!staticType.symbol?.valueDeclaration && isClassLike(staticType.symbol.valueDeclaration);
const staticBaseType = isClass
? getBaseConstructorTypeOfClass(staticType as InterfaceType)
: anyType;
const heritageClauses = [
...!length(baseTypes) ? [] : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))],
...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeBaseType(b, staticBaseType, localName)))]
@@ -6353,7 +6378,17 @@ namespace ts {
const staticMembers = flatMap(
filter(getPropertiesOfType(staticType), p => !(p.flags & SymbolFlags.Prototype) && p.escapedName !== "prototype" && !isNamespaceMember(p)),
p => serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType));
const constructors = serializeSignatures(SignatureKind.Construct, staticType, baseTypes[0], SyntaxKind.Constructor) as ConstructorDeclaration[];
// When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether
// the value is ever initialized with a class or function-like value. For cases where `X` could never be
// created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable.
const isNonConstructableClassLikeInJsFile =
!isClass &&
!!symbol.valueDeclaration &&
isInJSFile(symbol.valueDeclaration) &&
!some(getSignaturesOfType(staticType, SignatureKind.Construct));
const constructors = isNonConstructableClassLikeInJsFile ?
[createConstructor(/*decorators*/ undefined, createModifiersFromModifierFlags(ModifierFlags.Private), [], /*body*/ undefined)] :
serializeSignatures(SignatureKind.Construct, staticType, baseTypes[0], SyntaxKind.Constructor) as ConstructorDeclaration[];
for (const c of constructors) {
// A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration
// `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here
@@ -6929,7 +6964,7 @@ namespace ts {
function getTypeAliasForTypeLiteral(type: Type): Symbol | undefined {
if (type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral) {
const node = findAncestor(type.symbol.declarations[0].parent, n => n.kind !== SyntaxKind.ParenthesizedType)!;
const node = walkUpParenthesizedTypes(type.symbol.declarations[0].parent);
if (node.kind === SyntaxKind.TypeAliasDeclaration) {
return getSymbolOfNode(node);
}
@@ -7117,6 +7152,7 @@ namespace ts {
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.NamedTupleMember:
return isDeclarationVisible(node.parent);
// Default binding, import specifier and namespace import is visible
@@ -9520,27 +9556,36 @@ namespace ts {
return result;
}
function getExpandedParameters(sig: Signature): readonly Symbol[] {
function getExpandedParameters(sig: Signature, skipUnionExpanding?: boolean): readonly (readonly Symbol[])[] {
if (signatureHasRestParameter(sig)) {
const restIndex = sig.parameters.length - 1;
const restParameter = sig.parameters[restIndex];
const restType = getTypeOfSymbol(restParameter);
const restType = getTypeOfSymbol(sig.parameters[restIndex]);
if (isTupleType(restType)) {
const elementTypes = getTypeArguments(restType);
const minLength = restType.target.minLength;
const tupleRestIndex = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
const restParams = map(elementTypes, (t, i) => {
const name = getParameterNameAtPosition(sig, restIndex + i);
const checkFlags = i === tupleRestIndex ? CheckFlags.RestParameter :
i >= minLength ? CheckFlags.OptionalParameter : 0;
const symbol = createSymbol(SymbolFlags.FunctionScopedVariable, name, checkFlags);
symbol.type = i === tupleRestIndex ? createArrayType(t) : t;
return symbol;
});
return concatenate(sig.parameters.slice(0, restIndex), restParams);
return [expandSignatureParametersWithTupleMembers(restType, restIndex)];
}
else if (!skipUnionExpanding && restType.flags & TypeFlags.Union && every((restType as UnionType).types, isTupleType)) {
return map((restType as UnionType).types, t => expandSignatureParametersWithTupleMembers(t as TupleTypeReference, restIndex));
}
}
return sig.parameters;
return [sig.parameters];
function expandSignatureParametersWithTupleMembers(restType: TupleTypeReference, restIndex: number) {
const elementTypes = getTypeArguments(restType);
const minLength = restType.target.minLength;
const tupleRestIndex = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
const associatedNames = restType.target.labeledElementDeclarations;
const restParams = map(elementTypes, (t, i) => {
// Lookup the label from the individual tuple passed in before falling back to the signature `rest` parameter name
const tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]);
const name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i);
const checkFlags = i === tupleRestIndex ? CheckFlags.RestParameter :
i >= minLength ? CheckFlags.OptionalParameter : 0;
const symbol = createSymbol(SymbolFlags.FunctionScopedVariable, name, checkFlags);
symbol.type = i === tupleRestIndex ? createArrayType(t) : t;
return symbol;
});
return concatenate(sig.parameters.slice(0, restIndex), restParams);
}
}
function getDefaultConstructSignatures(classType: InterfaceType): Signature[] {
@@ -11583,7 +11628,7 @@ namespace ts {
const typeArguments = !node ? emptyArray :
node.kind === SyntaxKind.TypeReference ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters!)) :
node.kind === SyntaxKind.ArrayType ? [getTypeFromTypeNode(node.elementType)] :
map(node.elementTypes, getTypeFromTypeNode);
map(node.elements, getTypeFromTypeNode);
if (popTypeResolution()) {
type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
}
@@ -11789,11 +11834,11 @@ namespace ts {
}
function isUnaryTupleTypeNode(node: TypeNode) {
return node.kind === SyntaxKind.TupleType && (<TupleTypeNode>node).elementTypes.length === 1;
return node.kind === SyntaxKind.TupleType && (<TupleTypeNode>node).elements.length === 1;
}
function getImpliedConstraint(type: Type, checkNode: TypeNode, extendsNode: TypeNode): Type | undefined {
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, (<TupleTypeNode>checkNode).elementTypes[0], (<TupleTypeNode>extendsNode).elementTypes[0]) :
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, (<TupleTypeNode>checkNode).elements[0], (<TupleTypeNode>extendsNode).elements[0]) :
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
undefined;
}
@@ -12089,15 +12134,24 @@ namespace ts {
return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
}
function isTupleRestElement(node: TypeNode) {
return node.kind === SyntaxKind.RestType || (node.kind === SyntaxKind.NamedTupleMember && !!(node as NamedTupleMember).dotDotDotToken);
}
function isTupleOptionalElement(node: TypeNode) {
return node.kind === SyntaxKind.OptionalType || (node.kind === SyntaxKind.NamedTupleMember && !!(node as NamedTupleMember).questionToken);
}
function getArrayOrTupleTargetType(node: ArrayTypeNode | TupleTypeNode): GenericType {
const readonly = isReadonlyTypeOperator(node.parent);
if (node.kind === SyntaxKind.ArrayType || node.elementTypes.length === 1 && node.elementTypes[0].kind === SyntaxKind.RestType) {
if (node.kind === SyntaxKind.ArrayType || node.elements.length === 1 && isTupleRestElement(node.elements[0])) {
return readonly ? globalReadonlyArrayType : globalArrayType;
}
const lastElement = lastOrUndefined(node.elementTypes);
const restElement = lastElement && lastElement.kind === SyntaxKind.RestType ? lastElement : undefined;
const minLength = findLastIndex(node.elementTypes, n => n.kind !== SyntaxKind.OptionalType && n !== restElement) + 1;
return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined);
const lastElement = lastOrUndefined(node.elements);
const restElement = lastElement && isTupleRestElement(lastElement) ? lastElement : undefined;
const minLength = findLastIndex(node.elements, n => !isTupleOptionalElement(n) && n !== restElement) + 1;
const missingName = some(node.elements, e => e.kind !== SyntaxKind.NamedTupleMember);
return getTupleTypeOfArity(node.elements.length, minLength, !!restElement, readonly, /*associatedNames*/ missingName ? undefined : node.elements as readonly NamedTupleMember[]);
}
// Return true if the given type reference node is directly aliased or if it needs to be deferred
@@ -12105,7 +12159,7 @@ namespace ts {
function isDeferredTypeReferenceNode(node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode, hasDefaultTypeArguments?: boolean) {
return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (
node.kind === SyntaxKind.ArrayType ? mayResolveTypeAlias(node.elementType) :
node.kind === SyntaxKind.TupleType ? some(node.elementTypes, mayResolveTypeAlias) :
node.kind === SyntaxKind.TupleType ? some(node.elements, mayResolveTypeAlias) :
hasDefaultTypeArguments || some(node.typeArguments, mayResolveTypeAlias));
}
@@ -12116,6 +12170,7 @@ namespace ts {
const parent = node.parent;
switch (parent.kind) {
case SyntaxKind.ParenthesizedType:
case SyntaxKind.NamedTupleMember:
case SyntaxKind.TypeReference:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
@@ -12143,11 +12198,12 @@ namespace ts {
return (<TypeOperatorNode>node).operator !== SyntaxKind.UniqueKeyword && mayResolveTypeAlias((<TypeOperatorNode>node).type);
case SyntaxKind.ParenthesizedType:
case SyntaxKind.OptionalType:
case SyntaxKind.NamedTupleMember:
case SyntaxKind.JSDocOptionalType:
case SyntaxKind.JSDocNullableType:
case SyntaxKind.JSDocNonNullableType:
case SyntaxKind.JSDocTypeExpression:
return mayResolveTypeAlias((<ParenthesizedTypeNode | OptionalTypeNode | JSDocTypeReferencingNode>node).type);
return mayResolveTypeAlias((<ParenthesizedTypeNode | OptionalTypeNode | JSDocTypeReferencingNode | NamedTupleMember>node).type);
case SyntaxKind.RestType:
return (<RestTypeNode>node).type.kind !== SyntaxKind.ArrayType || mayResolveTypeAlias((<ArrayTypeNode>(<RestTypeNode>node).type).elementType);
case SyntaxKind.UnionType:
@@ -12170,11 +12226,11 @@ namespace ts {
links.resolvedType = emptyObjectType;
}
else if (isDeferredTypeReferenceNode(node)) {
links.resolvedType = node.kind === SyntaxKind.TupleType && node.elementTypes.length === 0 ? target :
links.resolvedType = node.kind === SyntaxKind.TupleType && node.elements.length === 0 ? target :
createDeferredTypeReference(target, node, /*mapper*/ undefined);
}
else {
const elementTypes = node.kind === SyntaxKind.ArrayType ? [getTypeFromTypeNode(node.elementType)] : map(node.elementTypes, getTypeFromTypeNode);
const elementTypes = node.kind === SyntaxKind.ArrayType ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
links.resolvedType = createTypeReference(target, elementTypes);
}
}
@@ -12192,7 +12248,7 @@ namespace ts {
//
// Note that the generic type created by this function has no symbol associated with it. The same
// is true for each of the synthesized type parameters.
function createTupleTypeOfArity(arity: number, minLength: number, hasRestElement: boolean, readonly: boolean, associatedNames: __String[] | undefined): TupleType {
function createTupleTypeOfArity(arity: number, minLength: number, hasRestElement: boolean, readonly: boolean, namedMemberDeclarations: readonly (NamedTupleMember | ParameterDeclaration)[] | undefined): TupleType {
let typeParameters: TypeParameter[] | undefined;
const properties: Symbol[] = [];
const maxLength = hasRestElement ? arity - 1 : arity;
@@ -12203,6 +12259,7 @@ namespace ts {
if (i < maxLength) {
const property = createSymbol(SymbolFlags.Property | (i >= minLength ? SymbolFlags.Optional : 0),
"" + i as __String, readonly ? CheckFlags.Readonly : 0);
property.tupleLabelDeclaration = namedMemberDeclarations?.[i];
property.type = typeParameter;
properties.push(property);
}
@@ -12232,25 +12289,25 @@ namespace ts {
type.minLength = minLength;
type.hasRestElement = hasRestElement;
type.readonly = readonly;
type.associatedNames = associatedNames;
type.labeledElementDeclarations = namedMemberDeclarations;
return type;
}
function getTupleTypeOfArity(arity: number, minLength: number, hasRestElement: boolean, readonly: boolean, associatedNames?: __String[]): GenericType {
const key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : "");
function getTupleTypeOfArity(arity: number, minLength: number, hasRestElement: boolean, readonly: boolean, namedMemberDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[]): GenericType {
const key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + map(namedMemberDeclarations, getNodeId).join(",") : "");
let type = tupleTypes.get(key);
if (!type) {
tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames));
tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, namedMemberDeclarations));
}
return type;
}
function createTupleType(elementTypes: readonly Type[], minLength = elementTypes.length, hasRestElement = false, readonly = false, associatedNames?: __String[]) {
function createTupleType(elementTypes: readonly Type[], minLength = elementTypes.length, hasRestElement = false, readonly = false, namedMemberDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[]) {
const arity = elementTypes.length;
if (arity === 1 && hasRestElement) {
return createArrayType(elementTypes[0], readonly);
}
const tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames);
const tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, namedMemberDeclarations);
return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType;
}
@@ -12265,7 +12322,7 @@ namespace ts {
Math.max(0, tuple.minLength - index),
tuple.hasRestElement,
tuple.readonly,
tuple.associatedNames && tuple.associatedNames.slice(index),
tuple.labeledElementDeclarations && tuple.labeledElementDeclarations.slice(index),
);
}
@@ -13844,6 +13901,21 @@ namespace ts {
return links.resolvedType;
}
function getTypeFromNamedTupleTypeNode(node: NamedTupleMember): Type {
const links = getNodeLinks(node);
if (!links.resolvedType) {
let type = getTypeFromTypeNode(node.type);
if (node.dotDotDotToken) {
type = getElementTypeOfArrayType(type) || errorType;
}
if (node.questionToken && strictNullChecks) {
type = getOptionalType(type);
}
links.resolvedType = type;
}
return links.resolvedType;
}
function getTypeFromTypeNode(node: TypeNode): Type {
return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
}
@@ -13902,10 +13974,12 @@ namespace ts {
return getTypeFromJSDocNullableTypeNode(<JSDocNullableType>node);
case SyntaxKind.JSDocOptionalType:
return addOptionality(getTypeFromTypeNode((node as JSDocOptionalType).type));
case SyntaxKind.NamedTupleMember:
return getTypeFromNamedTupleTypeNode(node as NamedTupleMember);
case SyntaxKind.ParenthesizedType:
case SyntaxKind.JSDocNonNullableType:
case SyntaxKind.JSDocTypeExpression:
return getTypeFromTypeNode((<ParenthesizedTypeNode | JSDocTypeReferencingNode | JSDocTypeExpression>node).type);
return getTypeFromTypeNode((<ParenthesizedTypeNode | JSDocTypeReferencingNode | JSDocTypeExpression | NamedTupleMember>node).type);
case SyntaxKind.RestType:
return getElementTypeOfArrayType(getTypeFromTypeNode((<RestTypeNode>node).type)) || errorType;
case SyntaxKind.JSDocVariadicType:
@@ -14264,7 +14338,7 @@ namespace ts {
minLength;
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
return contains(elementTypes, errorType) ? errorType :
createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames);
createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.labeledElementDeclarations);
}
function instantiateMappedTypeTemplate(type: MappedType, key: Type, isOptional: boolean, mapper: TypeMapper) {
@@ -18521,7 +18595,7 @@ namespace ts {
const elementTypes = map(getTypeArguments(source), t => inferReverseMappedType(t, target, constraint));
const minLength = getMappedTypeModifiers(target) & MappedTypeModifiers.IncludeOptional ?
getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength;
return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames);
return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.labeledElementDeclarations);
}
// For all other object types we infer a new object type where the reverse mapping has been
// applied to the type of each property.
@@ -20134,7 +20208,7 @@ namespace ts {
noCacheCheck = false;
}
if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation)) {
flow = (<FlowAssignment | FlowCondition | FlowArrayMutation | PreFinallyFlow>flow).antecedent;
flow = (<FlowAssignment | FlowCondition | FlowArrayMutation>flow).antecedent;
}
else if (flags & FlowFlags.Call) {
const signature = getEffectsSignature((<FlowCall>flow).node);
@@ -20184,6 +20258,51 @@ namespace ts {
}
}
// Return true if the given flow node is preceded by a 'super(...)' call in every possible code path
// leading to the node.
function isPostSuperFlowNode(flow: FlowNode, noCacheCheck: boolean): boolean {
while (true) {
const flags = flow.flags;
if (flags & FlowFlags.Shared) {
if (!noCacheCheck) {
const id = getFlowNodeId(flow);
const postSuper = flowNodePostSuper[id];
return postSuper !== undefined ? postSuper : (flowNodePostSuper[id] = isPostSuperFlowNode(flow, /*noCacheCheck*/ true));
}
noCacheCheck = false;
}
if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.SwitchClause)) {
flow = (<FlowAssignment | FlowCondition | FlowArrayMutation | FlowSwitchClause>flow).antecedent;
}
else if (flags & FlowFlags.Call) {
if ((<FlowCall>flow).node.expression.kind === SyntaxKind.SuperKeyword) {
return true;
}
flow = (<FlowCall>flow).antecedent;
}
else if (flags & FlowFlags.BranchLabel) {
// A branching point is post-super if every branch is post-super.
return every((<FlowLabel>flow).antecedents, f => isPostSuperFlowNode(f, /*noCacheCheck*/ false));
}
else if (flags & FlowFlags.LoopLabel) {
// A loop is post-super if the control flow path that leads to the top is post-super.
flow = (<FlowLabel>flow).antecedents![0];
}
else if (flags & FlowFlags.ReduceLabel) {
const target = (<FlowReduceLabel>flow).target;
const saveAntecedents = target.antecedents;
target.antecedents = (<FlowReduceLabel>flow).antecedents;
const result = isPostSuperFlowNode((<FlowReduceLabel>flow).antecedent, /*noCacheCheck*/ false);
target.antecedents = saveAntecedents;
return result;
}
else {
// Unreachable nodes are considered post-super to silence errors
return !!(flags & FlowFlags.Unreachable);
}
}
}
function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) {
let key: string | undefined;
let keySet = false;
@@ -21583,31 +21702,10 @@ namespace ts {
}
}
function findFirstSuperCall(n: Node): SuperCall | undefined {
if (isSuperCall(n)) {
return n;
}
else if (isFunctionLike(n)) {
return undefined;
}
return forEachChild(n, findFirstSuperCall);
}
/**
* Return a cached result if super-statement is already found.
* Otherwise, find a super statement in a given constructor function and cache the result in the node-links of the constructor
*
* @param constructor constructor-function to look for super statement
*/
function getSuperCallInConstructor(constructor: ConstructorDeclaration): SuperCall | undefined {
const links = getNodeLinks(constructor);
// Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result
if (links.hasSuperCall === undefined) {
links.superCall = findFirstSuperCall(constructor.body!);
links.hasSuperCall = links.superCall ? true : false;
}
return links.superCall!;
function findFirstSuperCall(node: Node): SuperCall | undefined {
return isSuperCall(node) ? node :
isFunctionLike(node) ? undefined :
forEachChild(node, findFirstSuperCall);
}
/**
@@ -21630,17 +21728,7 @@ namespace ts {
// If a containing class does not have extends clause or the class extends null
// skip checking whether super statement is called before "this" accessing.
if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
// We should give an error in the following cases:
// - No super-call
// - "this" is accessing before super-call.
// i.e super(this)
// this.x; super();
// We want to make sure that super-call is done before accessing "this" so that
// "this" is not accessed as a parameter of the super-call.
if (!superCall || superCall.end > node.pos) {
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
if (node.flowNode && !isPostSuperFlowNode(node.flowNode, /*noCacheCheck*/ false)) {
error(node, diagnosticMessage);
}
}
@@ -21865,7 +21953,8 @@ namespace ts {
function checkSuperExpression(node: Node): Type {
const isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).expression === node;
let container = getSuperContainer(node, /*stopOnFunctions*/ true);
const immediateContainer = getSuperContainer(node, /*stopOnFunctions*/ true);
let container = immediateContainer;
let needToCaptureLexicalThis = false;
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
@@ -21901,7 +21990,7 @@ namespace ts {
return errorType;
}
if (!isCallExpression && container.kind === SyntaxKind.Constructor) {
if (!isCallExpression && immediateContainer.kind === SyntaxKind.Constructor) {
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
}
@@ -22439,6 +22528,10 @@ namespace ts {
}
}
function isCircularMappedProperty(symbol: Symbol) {
return !!(getCheckFlags(symbol) & CheckFlags.Mapped && !(<MappedSymbol>symbol).type && findResolutionCycleStartIndex(symbol, TypeSystemPropertyName.Type) >= 0);
}
function getTypeOfPropertyOfContextualType(type: Type, name: __String) {
return mapType(type, t => {
if (isGenericMappedType(t)) {
@@ -22452,7 +22545,7 @@ namespace ts {
else if (t.flags & TypeFlags.StructuredType) {
const prop = getPropertyOfType(t, name);
if (prop) {
return getTypeOfSymbol(prop);
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
}
if (isTupleType(t)) {
const restType = getRestTypeOfTupleType(t);
@@ -25101,7 +25194,7 @@ namespace ts {
function getArrayifiedType(type: Type) {
return type.flags & TypeFlags.Union ? mapType(type, getArrayifiedType) :
type.flags & (TypeFlags.Any | TypeFlags.Instantiable) || isMutableArrayOrTuple(type) ? type :
isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, /*readonly*/ false, type.target.associatedNames) :
isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, /*readonly*/ false, type.target.labeledElementDeclarations) :
createArrayType(getIndexedAccessType(type, numberType));
}
@@ -25117,6 +25210,7 @@ namespace ts {
}
}
const types = [];
const names: (ParameterDeclaration | NamedTupleMember)[] = [];
let spreadIndex = -1;
for (let i = index; i < argCount; i++) {
const contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
@@ -25124,12 +25218,15 @@ namespace ts {
if (spreadIndex < 0 && isSpreadArgument(args[i])) {
spreadIndex = i - index;
}
if (args[i].kind === SyntaxKind.SyntheticExpression && (args[i] as SyntheticExpression).tupleNameSource) {
names.push((args[i] as SyntheticExpression).tupleNameSource!);
}
const hasPrimitiveContextualType = maybeTypeOfKind(contextualType, TypeFlags.Primitive | TypeFlags.Index);
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
}
return spreadIndex < 0 ?
createTupleType(types) :
createTupleType(append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true);
createTupleType(types, /*minLength*/ undefined, /*hasRestElement*/ undefined, /*readonly*/ undefined, length(names) === length(types) ? names : undefined) :
createTupleType(append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true, /*readonly*/ undefined);
}
function checkTypeArguments(signature: Signature, typeArgumentNodes: readonly TypeNode[], reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | undefined {
@@ -25380,11 +25477,12 @@ namespace ts {
}
}
function createSyntheticExpression(parent: Node, type: Type, isSpread?: boolean) {
function createSyntheticExpression(parent: Node, type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember) {
const result = <SyntheticExpression>createNode(SyntaxKind.SyntheticExpression, parent.pos, parent.end);
result.parent = parent;
result.type = type;
result.isSpread = isSpread || false;
result.tupleNameSource = tupleNameSource;
return result;
}
@@ -25419,7 +25517,7 @@ namespace ts {
if (isTupleType(type)) {
const typeArguments = getTypeArguments(<TypeReference>type);
const restIndex = type.target.hasRestElement ? typeArguments.length - 1 : -1;
const syntheticArgs = map(typeArguments, (t, i) => createSyntheticExpression(spreadArgument, t, /*isSpread*/ i === restIndex));
const syntheticArgs = map(typeArguments, (t, i) => createSyntheticExpression(spreadArgument, t, /*isSpread*/ i === restIndex, type.target.labeledElementDeclarations?.[i]));
return concatenate(args.slice(0, length - 1), syntheticArgs);
}
}
@@ -26961,6 +27059,11 @@ namespace ts {
return type;
}
function getTupleElementLabel(d: ParameterDeclaration | NamedTupleMember) {
Debug.assert(isIdentifier(d.name)); // Parameter declarations could be binding patterns, but we only allow identifier names
return d.name.escapedText;
}
function getParameterNameAtPosition(signature: Signature, pos: number) {
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
if (pos < paramCount) {
@@ -26969,13 +27072,33 @@ namespace ts {
const restParameter = signature.parameters[paramCount] || unknownSymbol;
const restType = getTypeOfSymbol(restParameter);
if (isTupleType(restType)) {
const associatedNames = (<TupleType>(<TypeReference>restType).target).associatedNames;
const associatedNames = (<TupleType>(<TypeReference>restType).target).labeledElementDeclarations;
const index = pos - paramCount;
return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index as __String;
return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index as __String;
}
return restParameter.escapedName;
}
function isValidDeclarationForTupleLabel(d: Declaration): d is NamedTupleMember | (ParameterDeclaration & { name: Identifier }) {
return d.kind === SyntaxKind.NamedTupleMember || (isParameter(d) && d.name && isIdentifier(d.name));
}
function getNameableDeclarationAtPosition(signature: Signature, pos: number) {
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
if (pos < paramCount) {
const decl = signature.parameters[pos].valueDeclaration;
return decl && isValidDeclarationForTupleLabel(decl) ? decl : undefined;
}
const restParameter = signature.parameters[paramCount] || unknownSymbol;
const restType = getTypeOfSymbol(restParameter);
if (isTupleType(restType)) {
const associatedNames = (<TupleType>(<TypeReference>restType).target).labeledElementDeclarations;
const index = pos - paramCount;
return associatedNames && associatedNames[index];
}
return restParameter.valueDeclaration && isValidDeclarationForTupleLabel(restParameter.valueDeclaration) ? restParameter.valueDeclaration : undefined;
}
function getTypeAtPosition(signature: Signature, pos: number): Type {
return tryGetTypeAtPosition(signature, pos) || anyType;
}
@@ -27006,14 +27129,26 @@ namespace ts {
return restType;
}
const types = [];
const names = [];
let names: (NamedTupleMember | ParameterDeclaration)[] | undefined = [];
for (let i = pos; i < nonRestCount; i++) {
types.push(getTypeAtPosition(source, i));
names.push(getParameterNameAtPosition(source, i));
const name = getNameableDeclarationAtPosition(source, i);
if (name && names) {
names.push(name);
}
else {
names = undefined;
}
}
if (restType) {
types.push(getIndexedAccessType(restType, numberType));
names.push(getParameterNameAtPosition(source, nonRestCount));
const name = getNameableDeclarationAtPosition(source, nonRestCount);
if (name && names) {
names.push(name);
}
else {
names = undefined;
}
}
const minArgumentCount = getMinArgumentCount(source);
const minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos;
@@ -29898,7 +30033,7 @@ namespace ts {
if (getClassExtendsHeritageElement(containingClassDecl)) {
captureLexicalThis(node.parent, containingClassDecl);
const classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
const superCall = getSuperCallInConstructor(node);
const superCall = findFirstSuperCall(node.body!);
if (superCall) {
if (classExtendsNull) {
error(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
@@ -30089,11 +30224,19 @@ namespace ts {
}
function checkTupleType(node: TupleTypeNode) {
const elementTypes = node.elementTypes;
const elementTypes = node.elements;
let seenOptionalElement = false;
let seenNamedElement = false;
for (let i = 0; i < elementTypes.length; i++) {
const e = elementTypes[i];
if (e.kind === SyntaxKind.RestType) {
if (e.kind === SyntaxKind.NamedTupleMember) {
seenNamedElement = true;
}
else if (seenNamedElement) {
grammarErrorOnNode(e, Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
break;
}
if (isTupleRestElement(e)) {
if (i !== elementTypes.length - 1) {
grammarErrorOnNode(e, Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
break;
@@ -30102,7 +30245,7 @@ namespace ts {
error(e, Diagnostics.A_rest_element_type_must_be_an_array_type);
}
}
else if (e.kind === SyntaxKind.OptionalType) {
else if (isTupleOptionalElement(e)) {
seenOptionalElement = true;
}
else if (seenOptionalElement) {
@@ -30110,7 +30253,7 @@ namespace ts {
break;
}
}
forEach(node.elementTypes, checkSourceElement);
forEach(node.elements, checkSourceElement);
}
function checkUnionOrIntersectionType(node: UnionOrIntersectionTypeNode) {
@@ -30196,6 +30339,20 @@ namespace ts {
getTypeFromTypeNode(node);
}
function checkNamedTupleMember(node: NamedTupleMember) {
if (node.dotDotDotToken && node.questionToken) {
grammarErrorOnNode(node, Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest);
}
if (node.type.kind === SyntaxKind.OptionalType) {
grammarErrorOnNode(node.type, Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type);
}
if (node.type.kind === SyntaxKind.RestType) {
grammarErrorOnNode(node.type, Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
}
checkSourceElement(node.type);
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node: Node): boolean {
return (hasEffectiveModifier(node, ModifierFlags.Private) || isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & NodeFlags.Ambient);
}
@@ -30975,6 +31132,7 @@ namespace ts {
return getEntityNameForDecoratorMetadataFromTypeList([(<ConditionalTypeNode>node).trueType, (<ConditionalTypeNode>node).falseType]);
case SyntaxKind.ParenthesizedType:
case SyntaxKind.NamedTupleMember:
return getEntityNameForDecoratorMetadata((<ParenthesizedTypeNode>node).type);
case SyntaxKind.TypeReference:
@@ -30986,8 +31144,8 @@ namespace ts {
function getEntityNameForDecoratorMetadataFromTypeList(types: readonly TypeNode[]): EntityName | undefined {
let commonEntityName: EntityName | undefined;
for (let typeNode of types) {
while (typeNode.kind === SyntaxKind.ParenthesizedType) {
typeNode = (typeNode as ParenthesizedTypeNode).type; // Skip parens if need be
while (typeNode.kind === SyntaxKind.ParenthesizedType || typeNode.kind === SyntaxKind.NamedTupleMember) {
typeNode = (typeNode as ParenthesizedTypeNode | NamedTupleMember).type; // Skip parens if need be
}
if (typeNode.kind === SyntaxKind.NeverKeyword) {
continue; // Always elide `never` from the union/intersection if possible
@@ -34740,6 +34898,8 @@ namespace ts {
return checkInferType(<InferTypeNode>node);
case SyntaxKind.ImportType:
return checkImportType(<ImportTypeNode>node);
case SyntaxKind.NamedTupleMember:
return checkNamedTupleMember(<NamedTupleMember>node);
case SyntaxKind.JSDocAugmentsTag:
return checkJSDocAugmentsTag(node as JSDocAugmentsTag);
case SyntaxKind.JSDocImplementsTag:
+1
View File
@@ -53,6 +53,7 @@ namespace ts {
["es2020.promise", "lib.es2020.promise.d.ts"],
["es2020.string", "lib.es2020.string.d.ts"],
["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
["es2020.intl", "lib.es2020.intl.d.ts"],
["esnext.array", "lib.es2019.array.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
+1 -1
View File
@@ -150,7 +150,7 @@ namespace ts {
* returns a falsey value, then returns false.
* If no such value is found, the callback is applied to each element of array and `true` is returned.
*/
export function every<T>(array: readonly T[], callback: (element: T, index: number) => boolean): boolean {
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean {
if (array) {
for (let i = 0; i < array.length; i++) {
if (!callback(array[i], i)) {
+24
View File
@@ -3517,6 +3517,22 @@
"category": "Error",
"code": 5083
},
"Tuple members must all have names or all not have names.": {
"category": "Error",
"code": 5084
},
"A tuple member cannot be both optional and rest.": {
"category": "Error",
"code": 5085
},
"A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.": {
"category": "Error",
"code": 5086
},
"A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.": {
"category": "Error",
"code": 5087
},
"Generates a sourcemap for each corresponding '.d.ts' file.": {
"category": "Message",
@@ -5677,6 +5693,14 @@
"category": "Message",
"code": 95116
},
"Move labeled tuple element modifiers to labels": {
"category": "Message",
"code": 95117
},
"Convert overload list to single signature": {
"category": "Message",
"code": 95118
},
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
"category": "Error",
+16 -4
View File
@@ -1370,6 +1370,8 @@ namespace ts {
case SyntaxKind.RestType:
case SyntaxKind.JSDocVariadicType:
return emitRestOrJSDocVariadicType(node as RestTypeNode | JSDocVariadicType);
case SyntaxKind.NamedTupleMember:
return emitNamedTupleMember(node as NamedTupleMember);
// Binding patterns
case SyntaxKind.ObjectBindingPattern:
@@ -2099,9 +2101,19 @@ namespace ts {
}
function emitTupleType(node: TupleTypeNode) {
writePunctuation("[");
emitList(node, node.elementTypes, ListFormat.TupleTypeElements);
writePunctuation("]");
emitTokenWithComment(SyntaxKind.OpenBracketToken, node.pos, writePunctuation, node);
const flags = getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTupleTypeElements : ListFormat.MultiLineTupleTypeElements;
emitList(node, node.elements, flags | ListFormat.NoSpaceIfEmpty);
emitTokenWithComment(SyntaxKind.CloseBracketToken, node.elements.end, writePunctuation, node);
}
function emitNamedTupleMember(node: NamedTupleMember) {
emit(node.dotDotDotToken);
emit(node.name);
emit(node.questionToken);
emitTokenWithComment(SyntaxKind.ColonToken, node.name.end, writePunctuation, node);
writeSpace();
emit(node.type);
}
function emitOptionalType(node: OptionalTypeNode) {
@@ -4968,7 +4980,7 @@ namespace ts {
}
function emitLeadingSynthesizedComment(comment: SynthesizedComment) {
if (comment.kind === SyntaxKind.SingleLineCommentTrivia) {
if (comment.hasLeadingNewline || comment.kind === SyntaxKind.SingleLineCommentTrivia) {
writer.writeLine();
}
writeSynthesizedComment(comment);
+38 -5
View File
@@ -810,15 +810,15 @@ namespace ts {
: node;
}
export function createTupleTypeNode(elementTypes: readonly TypeNode[]) {
export function createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]) {
const node = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode;
node.elementTypes = createNodeArray(elementTypes);
node.elements = createNodeArray(elements);
return node;
}
export function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]) {
return node.elementTypes !== elementTypes
? updateNode(createTupleTypeNode(elementTypes), node)
export function updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]) {
return node.elements !== elements
? updateNode(createTupleTypeNode(elements), node)
: node;
}
@@ -934,6 +934,24 @@ namespace ts {
: node;
}
export function createNamedTupleMember(dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode) {
const node = <NamedTupleMember>createSynthesizedNode(SyntaxKind.NamedTupleMember);
node.dotDotDotToken = dotDotDotToken;
node.name = name;
node.questionToken = questionToken;
node.type = type;
return node;
}
export function updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode) {
return node.dotDotDotToken !== dotDotDotToken
|| node.name !== name
|| node.questionToken !== questionToken
|| node.type !== type
? updateNode(createNamedTupleMember(dotDotDotToken, name, questionToken, type), node)
: node;
}
export function createThisTypeNode() {
return <ThisTypeNode>createSynthesizedNode(SyntaxKind.ThisType);
}
@@ -2616,6 +2634,21 @@ namespace ts {
return node;
}
/* @internal */
export function createJSDocVariadicType(type: TypeNode): JSDocVariadicType {
const node = createSynthesizedNode(SyntaxKind.JSDocVariadicType) as JSDocVariadicType;
node.type = type;
return node;
}
/* @internal */
export function updateJSDocVariadicType(node: JSDocVariadicType, type: TypeNode): JSDocVariadicType {
return node.type !== type
? updateNode(createJSDocVariadicType(type), node)
: node;
}
// JSX
export function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) {
+31 -2
View File
@@ -179,7 +179,7 @@ namespace ts {
case SyntaxKind.ArrayType:
return visitNode(cbNode, (<ArrayTypeNode>node).elementType);
case SyntaxKind.TupleType:
return visitNodes(cbNode, cbNodes, (<TupleTypeNode>node).elementTypes);
return visitNodes(cbNode, cbNodes, (<TupleTypeNode>node).elements);
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
return visitNodes(cbNode, cbNodes, (<UnionOrIntersectionTypeNode>node).types);
@@ -207,6 +207,11 @@ namespace ts {
visitNode(cbNode, (<MappedTypeNode>node).type);
case SyntaxKind.LiteralType:
return visitNode(cbNode, (<LiteralTypeNode>node).literal);
case SyntaxKind.NamedTupleMember:
return visitNode(cbNode, (<NamedTupleMember>node).dotDotDotToken) ||
visitNode(cbNode, (<NamedTupleMember>node).name) ||
visitNode(cbNode, (<NamedTupleMember>node).questionToken) ||
visitNode(cbNode, (<NamedTupleMember>node).type);
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
return visitNodes(cbNode, cbNodes, (<BindingPattern>node).elements);
@@ -3056,9 +3061,33 @@ namespace ts {
return type;
}
function isNextTokenColonOrQuestionColon() {
return nextToken() === SyntaxKind.ColonToken || (token() === SyntaxKind.QuestionToken && nextToken() === SyntaxKind.ColonToken);
}
function isTupleElementName() {
if (token() === SyntaxKind.DotDotDotToken) {
return tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
}
return tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
}
function parseTupleElementNameOrTupleElementType() {
if (lookAhead(isTupleElementName)) {
const node = <NamedTupleMember>createNode(SyntaxKind.NamedTupleMember);
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
node.name = parseIdentifierName();
node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
parseExpected(SyntaxKind.ColonToken);
node.type = parseTupleElementType();
return addJSDocComment(finishNode(node));
}
return parseTupleElementType();
}
function parseTupleType(): TupleTypeNode {
const node = <TupleTypeNode>createNode(SyntaxKind.TupleType);
node.elementTypes = parseBracketedList(ParsingContext.TupleElementTypes, parseTupleElementType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
node.elements = parseBracketedList(ParsingContext.TupleElementTypes, parseTupleElementNameOrTupleElementType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
return finishNode(node);
}
@@ -1018,6 +1018,10 @@ namespace ts {
}
}
if (isTupleTypeNode(input) && (getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
setEmitFlags(input, EmitFlags.SingleLine);
}
return cleanup(visitEachChild(input, visitDeclarationSubtree, context));
function cleanup<T extends Node>(returnValue: T | undefined): T | undefined {
+1 -1
View File
@@ -2583,7 +2583,7 @@ namespace ts {
&& i < numInitialPropertiesWithoutYield) {
numInitialPropertiesWithoutYield = i;
}
if (property.name!.kind === SyntaxKind.ComputedPropertyName) {
if (Debug.checkDefined(property.name).kind === SyntaxKind.ComputedPropertyName) {
numInitialProperties = i;
break;
}
+15 -10
View File
@@ -8,7 +8,7 @@ namespace ts {
export function processTaggedTemplateExpression(
context: TransformationContext,
node: TaggedTemplateExpression,
visitor: ((node: Node) => VisitResult<Node>) | undefined,
visitor: Visitor,
currentSourceFile: SourceFile,
recordTaggedTemplateString: (temp: Identifier) => void,
level: ProcessLevel) {
@@ -24,7 +24,9 @@ namespace ts {
const rawStrings: Expression[] = [];
const template = node.template;
if (level === ProcessLevel.LiftRestriction && !hasInvalidEscape(template)) return node;
if (level === ProcessLevel.LiftRestriction && !hasInvalidEscape(template)) {
return visitEachChild(node, visitor, context);
}
if (isNoSubstitutionTemplateLiteral(template)) {
cookedStrings.push(createTemplateCooked(template));
@@ -71,18 +73,21 @@ namespace ts {
*
* @param node The ES6 template literal.
*/
function getRawLiteral(node: LiteralLikeNode, currentSourceFile: SourceFile) {
function getRawLiteral(node: TemplateLiteralLikeNode, currentSourceFile: SourceFile) {
// Find original source text, since we need to emit the raw strings of the tagged template.
// The raw strings contain the (escaped) strings of what the user wrote.
// Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
let text = node.rawText;
if (text === undefined) {
text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
// thus we need to remove those characters.
// First template piece starts with "`", others with "}"
// Last template piece ends with "`", others with "${"
const isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail;
text = text.substring(1, text.length - (isLast ? 1 : 2));
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
// thus we need to remove those characters.
// First template piece starts with "`", others with "}"
// Last template piece ends with "`", others with "${"
const isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail;
text = text.substring(1, text.length - (isLast ? 1 : 2));
}
// Newline normalization:
// ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's
+21 -22
View File
@@ -328,6 +328,7 @@ namespace ts {
IndexedAccessType,
MappedType,
LiteralType,
NamedTupleMember,
ImportType,
// Binding patterns
ObjectBindingPattern,
@@ -700,6 +701,7 @@ namespace ts {
| ConstructorTypeNode
| JSDocFunctionType
| ExportDeclaration
| NamedTupleMember
| EndOfFileToken;
export type HasType =
@@ -1274,7 +1276,15 @@ namespace ts {
export interface TupleTypeNode extends TypeNode {
kind: SyntaxKind.TupleType;
elementTypes: NodeArray<TypeNode>;
elements: NodeArray<TypeNode | NamedTupleMember>;
}
export interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
kind: SyntaxKind.NamedTupleMember;
dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
name: Identifier;
questionToken?: Token<SyntaxKind.QuestionToken>;
type: TypeNode;
}
export interface OptionalTypeNode extends TypeNode {
@@ -1478,6 +1488,7 @@ namespace ts {
kind: SyntaxKind.SyntheticExpression;
isSpread: boolean;
type: Type;
tupleNameSource?: ParameterDeclaration | NamedTupleMember;
}
// see: https://tc39.github.io/ecma262/#prod-ExponentiationExpression
@@ -2590,6 +2601,7 @@ namespace ts {
text: string;
pos: -1;
end: -1;
hasLeadingNewline?: boolean;
}
// represents a top level: { type } expression in a JSDoc comment.
@@ -2791,34 +2803,21 @@ namespace ts {
}
export type FlowNode =
| AfterFinallyFlow
| PreFinallyFlow
| FlowStart
| FlowLabel
| FlowAssignment
| FlowCall
| FlowCondition
| FlowSwitchClause
| FlowArrayMutation;
| FlowArrayMutation
| FlowCall
| FlowReduceLabel;
export interface FlowNodeBase {
flags: FlowFlags;
id?: number; // Node id used by flow type cache in checker
}
export interface FlowLock {
locked?: boolean;
}
export interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
export interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
// FlowStart represents the start of a control flow. For a function expression or arrow
// function, the node property references the function (which in turn has a flowNode
// property for the containing control flow).
@@ -3508,7 +3507,7 @@ namespace ts {
*/
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
/* @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
/* @internal */ getExpandedParameters(sig: Signature): readonly Symbol[];
/* @internal */ getExpandedParameters(sig: Signature): readonly (readonly Symbol[])[];
/* @internal */ hasEffectiveRestParameter(sig: Signature): boolean;
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
@@ -4161,6 +4160,7 @@ namespace ts {
cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target
typeOnlyDeclaration?: TypeOnlyCompatibleAliasDeclaration | false; // First resolved alias declaration that makes the symbol only usable in type constructs
isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor
tupleLabelDeclaration?: NamedTupleMember | ParameterDeclaration; // Declaration associated with the tuple's label
}
/* @internal */
@@ -4316,8 +4316,6 @@ namespace ts {
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element
resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt.
superCall?: SuperCall; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing
switchTypes?: Type[]; // Cached array of switch case expression types
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
@@ -4633,7 +4631,7 @@ namespace ts {
minLength: number;
hasRestElement: boolean;
readonly: boolean;
associatedNames?: __String[];
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
export interface TupleTypeReference extends TypeReference {
@@ -6574,7 +6572,8 @@ namespace ts {
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings,
MultiLineTypeLiteralMembers = MultiLine | Indented | OptionalIfEmpty,
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
SingleLineTupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
MultiLineTupleTypeElements = CommaDelimited | Indented | SpaceBetweenSiblings | MultiLine,
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty,
+9 -1
View File
@@ -480,7 +480,7 @@ namespace ts {
case SyntaxKind.TupleType:
return updateTupleTypeNode((<TupleTypeNode>node),
nodesVisitor((<TupleTypeNode>node).elementTypes, visitor, isTypeNode));
nodesVisitor((<TupleTypeNode>node).elements, visitor, isTypeNode));
case SyntaxKind.OptionalType:
return updateOptionalTypeNode((<OptionalTypeNode>node),
@@ -517,6 +517,14 @@ namespace ts {
(<ImportTypeNode>node).isTypeOf
);
case SyntaxKind.NamedTupleMember:
return updateNamedTupleMember(<NamedTupleMember>node,
visitNode((<NamedTupleMember>node).dotDotDotToken, visitor, isToken),
visitNode((<NamedTupleMember>node).name, visitor, isIdentifier),
visitNode((<NamedTupleMember>node).questionToken, visitor, isToken),
visitNode((<NamedTupleMember>node).type, visitor, isTypeNode),
);
case SyntaxKind.ParenthesizedType:
return updateParenthesizedType(<ParenthesizedTypeNode>node,
visitNode((<ParenthesizedTypeNode>node).type, visitor, isTypeNode));
+6
View File
@@ -515,6 +515,12 @@ namespace FourSlash {
}
}
public verifyOrganizeImports(newContent: string) {
const changes = this.languageService.organizeImports({ fileName: this.activeFile.fileName, type: "file" }, this.formatCodeSettings, ts.emptyOptions);
this.applyChanges(changes);
this.verifyFileContent(this.activeFile.fileName, newContent);
}
private raiseError(message: string): never {
throw new Error(this.messageAtLastKnownMarker(message));
}
+4
View File
@@ -560,6 +560,10 @@ namespace FourSlashInterface {
public noMoveToNewFile(): void {
this.state.noMoveToNewFile();
}
public organizeImports(newContent: string) {
this.state.verifyOrganizeImports(newContent);
}
}
export class Edit {
+1
View File
@@ -3,3 +3,4 @@
/// <reference lib="es2020.promise" />
/// <reference lib="es2020.string" />
/// <reference lib="es2020.symbol.wellknown" />
/// <reference lib="es2020.intl" />
+264
View File
@@ -0,0 +1,264 @@
declare namespace Intl {
/**
* [BCP 47 language tag](http://tools.ietf.org/html/rfc5646) definition.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
*
* [Wikipedia](https://en.wikipedia.org/wiki/IETF_language_tag).
*/
type BCP47LanguageTag = string;
/**
* Unit to use in the relative time internationalized message.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format#Parameters).
*
* [Specification](https://tc39.es/ecma402/#sec-singularrelativetimeunit).
*/
type RelativeTimeFormatUnit =
| "year" | "years"
| "quarter" | "quarters"
| "month" | "months"
| "week" | "weeks"
| "day" | "days"
| "hour" | "hours"
| "minute" | "minutes"
| "second" | "seconds"
;
/**
* The locale matching algorithm to use.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
*
* [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat).
*/
type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit";
/**
* The format of output message.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
*
* [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat).
*/
type RelativeTimeFormatNumeric = "always" | "auto";
/**
* The length of the internationalized message.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
*
* [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat).
*/
type RelativeTimeFormatStyle = "long" | "short" | "narrow";
/**
* An object with some or all of properties of `options` parameter
* of `Intl.RelativeTimeFormat` constructor.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
*
* [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat).
*/
interface RelativeTimeFormatOptions {
localeMatcher?: RelativeTimeFormatLocaleMatcher;
numeric?: RelativeTimeFormatNumeric;
style?: RelativeTimeFormatStyle;
}
/**
* An object with properties reflecting the locale
* and formatting options computed during initialization
* of the `Intel.RelativeTimeFormat` object
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions#Description).
*
* [Specification](https://tc39.es/ecma402/#table-relativetimeformat-resolvedoptions-properties)
*/
interface ResolvedRelativeTimeFormatOptions {
locale: BCP47LanguageTag;
style: RelativeTimeFormatStyle;
numeric: RelativeTimeFormatNumeric;
numberingSystem: string;
}
/**
* An object representing the relative time format in parts
* that can be used for custom locale-aware formatting.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
*
* [Specification](https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts).
*/
interface RelativeTimeFormatPart {
type: string;
value: string;
unit?: RelativeTimeFormatUnit;
}
interface RelativeTimeFormat {
/**
* Formats a value and a unit according to the locale
* and formatting options of the given
* [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
* object.
*
* While this method automatically provides the correct plural forms,
* the grammatical form is otherwise as neutral as possible.
* It is the caller's responsibility to handle cut-off logic
* such as deciding between displaying "in 7 days" or "in 1 week".
* This API does not support relative dates involving compound units.
* e.g "in 5 days and 4 hours".
*
* @param value - Numeric value to use in the internationalized relative time message
*
* @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit)
* to use in the relative time internationalized message.
* Possible values are: `"year"`, `"quarter"`, `"month"`, `"week"`,
* `"day"`, `"hour"`, `"minute"`, `"second"`.
* Plural forms are also permitted.
*
* @throws `RangeError` if `unit` was given something other than `unit` possible values
*
* @returns Internationalized relative time message as string
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format).
*
* [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format).
*/
format(
value: number,
unit: RelativeTimeFormatUnit,
): string;
/**
* A version of the format method which it returns an array of objects
* which represent "parts" of the object,
* separating the formatted number into its constituent parts
* and separating it from other surrounding text.
* These objects have two properties:
* `type` a NumberFormat formatToParts type, and `value`,
* which is the String which is the component of the output.
* If a "part" came from NumberFormat,
* it will have a unit property which indicates the `unit` being formatted;
* literals which are part of the larger frame will not have this property.
*
* @param value - Numeric value to use in the internationalized relative time message
*
* @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit)
* to use in the relative time internationalized message.
* Possible values are: `"year"`, `"quarter"`, `"month"`, `"week"`,
* `"day"`, `"hour"`, `"minute"`, `"second"`.
* Plural forms are also permitted.
*
* @throws `RangeError` if `unit` was given something other than `unit` possible values
*
* @returns Array of [FormatRelativeTimeToParts](https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts)
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts).
*
* [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts).
*/
formatToParts(
value: number,
unit: RelativeTimeFormatUnit,
): RelativeTimeFormatPart[];
/**
* Provides access to the locale and options computed during initialization of this `Intl.RelativeTimeFormat` object.
*
* @returns A new object with properties reflecting the locale
* and formatting options computed during initialization
* of the `Intel.RelativeTimeFormat` object.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions).
*
* [Specification](https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions)
*/
resolvedOptions(): ResolvedRelativeTimeFormatOptions;
}
/**
* The [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
* object is a constructor for objects that enable language-sensitive relative time formatting.
*
* Part of [Intl object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)
* namespace and the [ECMAScript Internationalization API](https://www.ecma-international.org/publications/standards/Ecma-402.htm).
*
* [Compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat#Browser_compatibility).
*
* [Polyfills](https://github.com/tc39/proposal-intl-relative-time#polyfills).
*/
const RelativeTimeFormat: {
/**
* Constructor creates [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
* objects
*
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
* For the general form and interpretation of the locales argument,
* see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
*
* @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)
* with some or all of options of the formatting.
* An object with some or all of the following properties:
* - `localeMatcher` - The locale matching algorithm to use.
* Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`.
* For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
* - `numeric` - The format of output message.
* Possible values are: `"always"` (default, e.g., `1 day ago`) or `"auto"` (e.g., `yesterday`).
* The `"auto"` value allows to not always have to use numeric values in the output.
* - `style` - The length of the internationalized message. Possible values are:
* `"long"` (default, e.g., in 1 month),
* `"short"` (e.g., in 1 mo.)
* or `"narrow"` (e.g., in 1 mo.). The narrow style could be similar to the short style for some locales.
*
* @returns [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) object.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat).
*
* [Specification](https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor).
*/
new(
locales?: BCP47LanguageTag | BCP47LanguageTag[],
options?: RelativeTimeFormatOptions,
): RelativeTimeFormat;
/**
* Returns an array containing those of the provided locales
* that are supported in date and time formatting
* without having to fall back to the runtime's default locale.
*
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
* For the general form and interpretation of the locales argument,
* see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
*
* @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)
* with some or all of options of the formatting.
* An object with some or all of the following properties:
* - `localeMatcher` - The locale matching algorithm to use.
* Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`.
* For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
* - `numeric` - The format of output message.
* Possible values are: `"always"` (default, e.g., `1 day ago`) or `"auto"` (e.g., `yesterday`).
* The `"auto"` value allows to not always have to use numeric values in the output.
* - `style` - The length of the internationalized message. Possible values are:
* `"long"` (default, e.g., in 1 month),
* `"short"` (e.g., in 1 mo.)
* or `"narrow"` (e.g., in 1 mo.). The narrow style could be similar to the short style for some locales.
*
* @returns An array containing those of the provided locales
* that are supported in date and time formatting
* without having to fall back to the runtime's default locale.
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/supportedLocalesOf).
*
* [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf).
*/
supportedLocalesOf(
locales: BCP47LanguageTag | BCP47LanguageTag[],
options?: RelativeTimeFormatOptions,
): BCP47LanguageTag[];
};
}
+1
View File
@@ -44,6 +44,7 @@
"es2020.promise",
"es2020.string",
"es2020.symbol.wellknown",
"es2020.intl",
"esnext.intl",
"esnext.string",
"esnext.promise",
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[JSDoc "@typedef" 注释不能包含多个 "@type" 标记。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3720,6 +3729,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[声明私有方法 "{0}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8610,15 +8622,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[删除所有错误的正文块括号]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8646,11 +8649,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[删除块正文括号]]></Val>
<Val><![CDATA[从所有带有相关问题的箭头函数主体中删除大括号]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8664,6 +8667,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[从箭头函数主体中删除大括号]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10389,6 +10401,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[第一次在此处指定了标记。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[JSDoc '@typedef' 註解不能包含多個 '@type' 標籤。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3720,6 +3729,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[宣告私人方法 '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7207,7 +7219,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[只有具名的匯出可以使用「匯出類型」。]]></Val>
<Val><![CDATA[只有具名的匯出可以使用 'export type'。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8610,15 +8622,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[移除所有不正確的主體區塊大括弧]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8646,11 +8649,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[移除區塊主體大括]]></Val>
<Val><![CDATA[從具有相關問題的所有箭號函式主體中移除大括]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8664,6 +8667,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[從箭號函式主體中移除大括號]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10389,6 +10401,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[此標籤第一次指定於此處。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -57,6 +57,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Komentář JSDoc @typedef nemůže obsahovat více než jednu značku @type.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3726,6 +3735,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Deklarovat privátní metodu {0}]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Declare_private_property_0_90035" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private property '{0}']]></Val>
@@ -7210,7 +7228,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Jenom pojmenované exporty mohou používat typ exportu.]]></Val>
<Val><![CDATA[Jen pojmenované exporty můžou používat export type.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8613,15 +8631,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat všechny nesprávné závorky bloku kódu]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8649,11 +8658,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat všechny závorky bloku kódu]]></Val>
<Val><![CDATA[Odeberte složené závorky ze všech těl funkcí šipek, u kterých dochází k problémům.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8667,6 +8676,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat složené závorky z těla funkce šipky]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10392,6 +10410,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Značka se poprvé zadala tady.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Ein JSDoc-Kommentar "@typedef" darf nicht mehrere @type-Tags enthalten.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3717,6 +3726,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Private Methode "{0}" deklarieren]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7204,7 +7216,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["Exporttyp" kann nur von benannten Exporten verwendet werden.]]></Val>
<Val><![CDATA["export type" kann nur von benannten Exporten verwendet werden.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8604,15 +8616,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Alle falschen geschweiften Klammern aus Textblock entfernen]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8640,11 +8643,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Geschweifte Klammern aus Blocktextkörper entfernen]]></Val>
<Val><![CDATA[Entfernen Sie die geschweiften Klammern aus dem Text aller Pfeilfunktionen mit entsprechenden Problemen.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8658,6 +8661,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Geschweifte Klammern aus Pfeilfunktionstext entfernen]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10383,6 +10395,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Das Tag wurde zuerst hier angegeben.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -57,6 +57,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un comentario "@typedef" de JSDoc no puede contener varias etiquetas "@type".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3732,6 +3741,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Declarar el método "{0}" privado]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7219,7 +7231,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Solo las exportaciones con nombre pueden usar "tipo de exportación".]]></Val>
<Val><![CDATA[Solo las exportaciones con nombre pueden usar "export type".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8622,15 +8634,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar todas las llaves de cuerpo de bloque incorrectas]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8658,11 +8661,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar llaves de cuerpo del bloque]]></Val>
<Val><![CDATA[Quitar las llaves de todos los cuerpos de función de flecha con problemas relevantes]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8676,6 +8679,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar las llaves del cuerpo de función de flecha]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10401,6 +10413,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La etiqueta se especificó aquí primero.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -57,6 +57,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un commentaire JSDoc '@typedef' ne peut pas contenir plusieurs balises '@type'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3732,6 +3741,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Déclarer la méthode privée '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8622,15 +8634,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer toutes les accolades de corps de bloc incorrectes]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8658,11 +8661,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer les accolades de corps de bloc]]></Val>
<Val><![CDATA[Supprimer les accolades de tous les corps de fonction arrow présentant des problèmes pertinents]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8676,6 +8679,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer les accolades du corps de fonction arrow]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10401,6 +10413,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La balise a d'abord été spécifiée ici.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un commento '@typedef' di JSDoc non può contenere più tag '@type'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3720,6 +3729,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Dichiarare il metodo privato '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8610,15 +8622,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere tutte le parentesi graffe errate presenti nel corpo del blocco]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8646,11 +8649,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere le parentesi graffe presenti nel corpo del blocco]]></Val>
<Val><![CDATA[Rimuovere le parentesi graffe da tutti i corpi della funzione arrow con problemi specifici]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8664,6 +8667,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere le parentesi graffe dal corpo della funzione arrow]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10389,6 +10401,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Il tag è stato specificato per la prima volta in questo punto.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[JSDoc '@typedef' コメントに複数の '@type' タグを含めることはできません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3720,6 +3729,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[プライベート メソッド '{0}' を宣言する]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7207,7 +7219,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['export type' を使用できるのは名前付きエクスポートのみです。]]></Val>
<Val><![CDATA[名前付きエクスポートでのみ、'export type' を使用できす。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8610,15 +8622,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[本体ブロックの中かっこで間違っているものをすべて削除する]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8646,11 +8649,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[ブロック本体の中かっこを削除す]]></Val>
<Val><![CDATA[関連する問題のあるすべてのアロー関数本体から中かっこを削除します]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8664,6 +8667,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[アロー関数本体から中かっこを削除します]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10389,6 +10401,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[このタグは最初にこちらで指定されました。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -48,6 +48,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[JSDoc '@typedef' 주석에 여러 '@type' 태그를 포함하지 못할 수 있습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3720,6 +3729,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[프라이빗 메서드 '{0}' 선언]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7207,7 +7219,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[명명된 내보내기에서만 '내보내기 형식'을 사용할 수 있습니다.]]></Val>
<Val><![CDATA[명명된 내보내기에서만 'export type'을 사용할 수 있습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8610,15 +8622,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[잘못된 본문 블록 중괄호 모두 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8646,11 +8649,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[블록 본문 중괄호 제거]]></Val>
<Val><![CDATA[관련 문제가 있는 모든 화살표 함수 본문에서 중괄호 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8664,6 +8667,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[화살표 함수 본문에서 중괄호 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10389,6 +10401,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[태그가 처음에 여기에 지정되었습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -41,6 +41,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Komentarz JSDoc „@typedef” nie może zawierać wielu tagów „@type”.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -8600,15 +8609,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń wszystkie niepoprawne nawiasy klamrowe bloku treści]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8636,11 +8636,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń nawiasy klamrowe treści bloku]]></Val>
<Val><![CDATA[Usuń nawiasy klamrowe ze wszystkich treści funkcji strzałkowej z odpowiednimi problemami]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8654,6 +8654,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń nawiasy klamrowe z treści funkcji strzałkowej]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10379,6 +10388,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Tag został najpierw określony w tym miejscu.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -41,6 +41,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Um comentário de JSDoc '@typedef' não pode conter várias marcas '@type'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -7203,7 +7212,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Somente as exportações nomeadas podem usar 'tipo de exportação'.]]></Val>
<Val><![CDATA[Somente as exportações nomeadas podem usar 'export type'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8603,15 +8612,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover todas as chaves incorretas do bloco de corpo]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8639,11 +8639,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover as chaves do corpo do bloco]]></Val>
<Val><![CDATA[Remover as chaves de todos os corpos de função de seta com problemas relevantes]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8657,6 +8657,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover as chaves do corpo de função de seta]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10382,6 +10391,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[A marca foi especificada primeiro aqui.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -47,6 +47,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Комментарий "@typedef" JSDoc не может содержать несколько тегов "@type".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3719,6 +3728,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Объявление закрытого метода "{0}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7206,7 +7218,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Только именованные экспорты могут использовать export type.]]></Val>
<Val><![CDATA["export type" может использоваться только в именованном экспорте.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8609,15 +8621,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалить все неправильные фигурные скобки вокруг тел блоков]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8645,11 +8648,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалить фигурные скобки вокруг тела блока]]></Val>
<Val><![CDATA[Удалить скобки из всех тел стрелочных функций с соответствующими проблемами]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8663,6 +8666,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалить скобки из тела стрелочной функции]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10388,6 +10400,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Этот тег был впервые указан здесь.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -41,6 +41,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A JSDoc '@typedef' comment may not contain multiple '@type' tags.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[JSDoc '@typedef' açıklaması, birden çok '@type' etiketi içeremez.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_bigint_literal_cannot_use_exponential_notation_1352" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A bigint literal cannot use exponential notation.]]></Val>
@@ -3713,6 +3722,9 @@
<Item ItemId=";Declare_private_method_0_90038" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Declare private method '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' özel metodunu bildirin.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -7200,7 +7212,7 @@
<Str Cat="Text">
<Val><![CDATA[Only named exports may use 'export type'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Yalnızca adlandırılmış dışarı aktarmalarda 'dışarı aktarma türü' kullanılabilir.]]></Val>
<Val><![CDATA[Yalnızca adlandırılmış dışarı aktarmalarda 'export type' kullanılabilir.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8603,15 +8615,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_incorrect_body_block_braces_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all incorrect body block braces]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Tüm yanlış gövde bloğu küme ayraçlarını kaldırın]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_all_unnecessary_uses_of_await_95087" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove all unnecessary uses of 'await']]></Val>
@@ -8639,11 +8642,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_block_body_braces_95112" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove block body braces]]></Val>
<Val><![CDATA[Remove braces from all arrow function bodies with relevant issues]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Blok gövdesi küme ayraçlarını kaldırın]]></Val>
<Val><![CDATA[İlgili sorunları olan tüm ok işlev gövdelerinden ayraçları kaldır]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8657,6 +8660,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_braces_from_arrow_function_body_95112" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove braces from arrow function body]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Ok işlevi gövdesinden küme ayraçlarını kaldır]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
@@ -10382,6 +10394,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_tag_was_first_specified_here_8034" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The tag was first specified here.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Etiket ilk olarak burada belirtildi.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The target of an assignment must be a variable or a property access.]]></Val>
@@ -0,0 +1,52 @@
/* @internal */
namespace ts.codefix {
const fixId = "fixIncorrectNamedTupleSyntax";
const errorCodes = [
Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type.code,
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
];
registerCodeFix({
errorCodes,
getCodeActions: context => {
const { sourceFile, span } = context;
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, namedTupleMember));
return [createCodeFixAction(fixId, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
},
fixIds: [fixId]
});
function getNamedTupleMember(sourceFile: SourceFile, pos: number) {
const token = getTokenAtPosition(sourceFile, pos);
return findAncestor(token, t => t.kind === SyntaxKind.NamedTupleMember) as NamedTupleMember | undefined;
}
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, namedTupleMember?: NamedTupleMember) {
if (!namedTupleMember) {
return;
}
let unwrappedType = namedTupleMember.type;
let sawOptional = false;
let sawRest = false;
while (unwrappedType.kind === SyntaxKind.OptionalType || unwrappedType.kind === SyntaxKind.RestType || unwrappedType.kind === SyntaxKind.ParenthesizedType) {
if (unwrappedType.kind === SyntaxKind.OptionalType) {
sawOptional = true;
}
else if (unwrappedType.kind === SyntaxKind.RestType) {
sawRest = true;
}
unwrappedType = (unwrappedType as OptionalTypeNode | RestTypeNode | ParenthesizedTypeNode).type;
}
const updated = updateNamedTupleMember(
namedTupleMember,
namedTupleMember.dotDotDotToken || (sawRest ? createToken(SyntaxKind.DotDotDotToken) : undefined),
namedTupleMember.name,
namedTupleMember.questionToken || (sawOptional ? createToken(SyntaxKind.QuestionToken) : undefined),
unwrappedType
);
if (updated === namedTupleMember) {
return;
}
changes.replaceNode(sourceFile, namedTupleMember, updated);
}
}
+4 -3
View File
@@ -3,6 +3,7 @@ namespace ts.formatting {
export interface FormatContext {
readonly options: FormatCodeSettings;
readonly getRules: RulesMap;
readonly host: FormattingHost;
}
export interface TextRangeWithKind<T extends SyntaxKind = SyntaxKind> extends TextRange {
@@ -394,7 +395,7 @@ namespace ts.formatting {
initialIndentation: number,
delta: number,
formattingScanner: FormattingScanner,
{ options, getRules }: FormatContext,
{ options, getRules, host }: FormatContext,
requestKind: FormattingRequestKind,
rangeContainsError: (r: TextRange) => boolean,
sourceFile: SourceFileLike): TextChange[] {
@@ -1193,7 +1194,7 @@ namespace ts.formatting {
previousRange: TextRangeWithKind,
previousStartLine: number,
currentRange: TextRangeWithKind,
currentStartLine: number,
currentStartLine: number
): LineAction {
const onLaterLine = currentStartLine !== previousStartLine;
switch (rule.action) {
@@ -1221,7 +1222,7 @@ namespace ts.formatting {
// edit should not be applied if we have one line feed between elements
const lineDelta = currentStartLine - previousStartLine;
if (lineDelta !== 1) {
recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter!);
recordReplace(previousRange.end, currentRange.pos - previousRange.end, getNewLineOrDefaultFromHost(host, options));
return onLaterLine ? LineAction.None : LineAction.LineAdded;
}
break;
+2 -2
View File
@@ -1,7 +1,7 @@
/* @internal */
namespace ts.formatting {
export function getFormatContext(options: FormatCodeSettings): FormatContext {
return { options, getRules: getRulesMap() };
export function getFormatContext(options: FormatCodeSettings, host: FormattingHost): FormatContext {
return { options, getRules: getRulesMap(), host };
}
let rulesMapCache: RulesMap | undefined;
+1 -1
View File
@@ -574,7 +574,7 @@ namespace ts.formatting {
return childKind !== SyntaxKind.JsxClosingFragment;
case SyntaxKind.IntersectionType:
case SyntaxKind.UnionType:
if (childKind === SyntaxKind.TypeLiteral) {
if (childKind === SyntaxKind.TypeLiteral || childKind === SyntaxKind.TupleType) {
return false;
}
// falls through
+10 -9
View File
@@ -100,10 +100,13 @@ namespace ts.GoToDefinition {
/**
* True if we should not add definitions for both the signature symbol and the definition symbol.
* True for `const |f = |() => 0`, false for `function |f() {} const |g = f;`.
* Also true for any assignment RHS.
*/
function symbolMatchesSignature(s: Symbol, calledDeclaration: SignatureDeclaration) {
return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent ||
!isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol;
return s === calledDeclaration.symbol
|| s === calledDeclaration.symbol.parent
|| isAssignmentExpression(calledDeclaration.parent)
|| (!isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol);
}
export function getReferenceAtPosition(sourceFile: SourceFile, position: number, program: Program): { fileName: string, file: SourceFile } | undefined {
@@ -246,7 +249,9 @@ namespace ts.GoToDefinition {
// There are cases when you extend a function by adding properties to it afterwards,
// we want to strip those extra properties.
// For deduping purposes, we also want to exclude any declarationNodes if provided.
const filteredDeclarations = filter(symbol.declarations, d => d !== declarationNode && (!isAssignmentDeclaration(d) || d === symbol.valueDeclaration)) || undefined;
const filteredDeclarations =
filter(symbol.declarations, d => d !== declarationNode && (!isAssignmentDeclaration(d) || d === symbol.valueDeclaration))
|| undefined;
return getConstructSignatureDefinition() || getCallSignatureDefinition() || map(filteredDeclarations, declaration => createDefinitionInfo(declaration, typeChecker, symbol, node));
function getConstructSignatureDefinition(): DefinitionInfo[] | undefined {
@@ -330,15 +335,11 @@ namespace ts.GoToDefinition {
/** Returns a CallLikeExpression where `node` is the target being invoked. */
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined {
const target = climbPastManyPropertyAccesses(node);
const callLike = target.parent;
const target = findAncestor(node, n => !isRightSideOfPropertyAccess(n));
const callLike = target?.parent;
return callLike && isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target ? callLike : undefined;
}
function climbPastManyPropertyAccesses(node: Node): Node {
return isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node;
}
function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined {
const callLike = getAncestorCallLikeExpression(node);
const signature = callLike && typeChecker.getResolvedSignature(callLike);
+1 -1
View File
@@ -76,7 +76,7 @@ namespace ts.OrganizeImports {
// Delete any subsequent imports.
for (let i = 1; i < oldImportDecls.length; i++) {
changeTracker.delete(sourceFile, oldImportDecls[i]);
changeTracker.deleteNode(sourceFile, oldImportDecls[i]);
}
}
}
@@ -42,6 +42,10 @@ namespace ts.OutliningElementsCollector {
addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out);
}
if (isFunctionLike(n) && isBinaryExpression(n.parent) && isPropertyAccessExpression(n.parent.left)) {
addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out);
}
const span = getOutliningSpanForNode(n, sourceFile);
if (span) out.push(span);
@@ -0,0 +1,219 @@
/* @internal */
namespace ts.refactor.addOrRemoveBracesToArrowFunction {
const refactorName = "Convert overload list to single signature";
const refactorDescription = Diagnostics.Convert_overload_list_to_single_signature.message;
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[] {
const { file, startPosition, program } = context;
const info = getConvertableOverloadListAtPosition(file, startPosition, program);
if (!info) return emptyArray;
return [{
name: refactorName,
description: refactorDescription,
actions: [{
name: refactorName,
description: refactorDescription
}]
}];
}
function getEditsForAction(context: RefactorContext): RefactorEditInfo | undefined {
const { file, startPosition, program } = context;
const signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
if (!signatureDecls) return undefined;
const checker = program.getTypeChecker();
const lastDeclaration = signatureDecls[signatureDecls.length - 1];
let updated = lastDeclaration;
switch (lastDeclaration.kind) {
case SyntaxKind.MethodSignature: {
updated = updateMethodSignature(
lastDeclaration,
lastDeclaration.typeParameters,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.type,
lastDeclaration.name,
lastDeclaration.questionToken
);
break;
}
case SyntaxKind.MethodDeclaration: {
updated = updateMethod(
lastDeclaration,
lastDeclaration.decorators,
lastDeclaration.modifiers,
lastDeclaration.asteriskToken,
lastDeclaration.name,
lastDeclaration.questionToken,
lastDeclaration.typeParameters,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.type,
lastDeclaration.body
);
break;
}
case SyntaxKind.CallSignature: {
updated = updateCallSignature(
lastDeclaration,
lastDeclaration.typeParameters,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.type,
);
break;
}
case SyntaxKind.Constructor: {
updated = updateConstructor(
lastDeclaration,
lastDeclaration.decorators,
lastDeclaration.modifiers,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.body
);
break;
}
case SyntaxKind.ConstructSignature: {
updated = updateConstructSignature(
lastDeclaration,
lastDeclaration.typeParameters,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.type,
);
break;
}
case SyntaxKind.FunctionDeclaration: {
updated = updateFunctionDeclaration(
lastDeclaration,
lastDeclaration.decorators,
lastDeclaration.modifiers,
lastDeclaration.asteriskToken,
lastDeclaration.name,
lastDeclaration.typeParameters,
getNewParametersForCombinedSignature(signatureDecls),
lastDeclaration.type,
lastDeclaration.body
);
break;
}
default: return Debug.failBadSyntaxKind(lastDeclaration, "Unhandled signature kind in overload list conversion refactoring");
}
if (updated === lastDeclaration) {
return; // No edits to apply, do nothing
}
const edits = textChanges.ChangeTracker.with(context, t => {
t.replaceNodeRange(file, signatureDecls[0], signatureDecls[signatureDecls.length - 1], updated);
});
return { renameFilename: undefined, renameLocation: undefined, edits };
function getNewParametersForCombinedSignature(signatureDeclarations: (MethodSignature | MethodDeclaration | CallSignatureDeclaration | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration)[]): NodeArray<ParameterDeclaration> {
const lastSig = signatureDeclarations[signatureDeclarations.length - 1];
if (isFunctionLikeDeclaration(lastSig) && lastSig.body) {
// Trim away implementation signature arguments (they should already be compatible with overloads, but are likely less precise to guarantee compatability with the overloads)
signatureDeclarations = signatureDeclarations.slice(0, signatureDeclarations.length - 1);
}
return createNodeArray([
createParameter(
/*decorators*/ undefined,
/*modifiers*/ undefined,
createToken(SyntaxKind.DotDotDotToken),
"args",
/*questionToken*/ undefined,
createUnionTypeNode(map(signatureDeclarations, convertSignatureParametersToTuple))
)
]);
}
function convertSignatureParametersToTuple(decl: MethodSignature | MethodDeclaration | CallSignatureDeclaration | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration): TupleTypeNode {
const members = map(decl.parameters, convertParameterToNamedTupleMember);
return setEmitFlags(createTupleTypeNode(members), some(members, m => !!length(getSyntheticLeadingComments(m))) ? EmitFlags.None : EmitFlags.SingleLine);
}
function convertParameterToNamedTupleMember(p: ParameterDeclaration): NamedTupleMember {
Debug.assert(isIdentifier(p.name)); // This is checked during refactoring applicability checking
const result = setTextRange(createNamedTupleMember(
p.dotDotDotToken,
p.name,
p.questionToken,
p.type || createKeywordTypeNode(SyntaxKind.AnyKeyword)
), p);
const parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker);
if (parameterDocComment) {
const newComment = displayPartsToString(parameterDocComment);
if (newComment.length) {
setSyntheticLeadingComments(result, [{
text: `*
${newComment.split("\n").map(c => ` * ${c}`).join("\n")}
`,
kind: SyntaxKind.MultiLineCommentTrivia,
pos: -1,
end: -1,
hasTrailingNewLine: true,
hasLeadingNewline: true,
}]);
}
}
return result;
}
}
function isConvertableSignatureDeclaration(d: Node): d is MethodSignature | MethodDeclaration | CallSignatureDeclaration | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration {
switch (d.kind) {
case SyntaxKind.MethodSignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.CallSignature:
case SyntaxKind.Constructor:
case SyntaxKind.ConstructSignature:
case SyntaxKind.FunctionDeclaration:
return true;
}
return false;
}
function getConvertableOverloadListAtPosition(file: SourceFile, startPosition: number, program: Program) {
const node = getTokenAtPosition(file, startPosition);
const containingDecl = findAncestor(node, isConvertableSignatureDeclaration);
if (!containingDecl) {
return;
}
const checker = program.getTypeChecker();
const signatureSymbol = containingDecl.symbol;
if (!signatureSymbol) {
return;
}
const decls = signatureSymbol.declarations;
if (length(decls) <= 1) {
return;
}
if (!every(decls, d => getSourceFileOfNode(d) === file)) {
return;
}
if (!isConvertableSignatureDeclaration(decls[0])) {
return;
}
const kindOne = decls[0].kind;
if (!every(decls, d => d.kind === kindOne)) {
return;
}
const signatureDecls = decls as (MethodSignature | MethodDeclaration | CallSignatureDeclaration | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration)[];
if (some(signatureDecls, d => !!d.typeParameters || some(d.parameters, p => !!p.decorators || !!p.modifiers || !isIdentifier(p.name)))) {
return;
}
const signatures = mapDefined(signatureDecls, d => checker.getSignatureFromDeclaration(d));
if (length(signatures) !== length(decls)) {
return;
}
const returnOne = checker.getReturnTypeOfSignature(signatures[0]);
if (!every(signatures, s => checker.getReturnTypeOfSignature(s) === returnOne)) {
return;
}
return signatureDecls;
}
}
+16 -5
View File
@@ -28,7 +28,7 @@ namespace ts.refactor.extractSymbol {
const usedConstantNames: Map<boolean> = createMap();
let i = 0;
for (const {functionExtraction, constantExtraction} of extractions) {
for (const { functionExtraction, constantExtraction } of extractions) {
// Skip these since we don't have a way to report errors yet
if (functionExtraction.errors.length === 0) {
// Don't issue refactorings with duplicated names.
@@ -1103,7 +1103,12 @@ namespace ts.refactor.extractSymbol {
changeTracker.delete(context.file, node.parent);
}
else {
const localReference = createIdentifier(localNameText);
let localReference: Expression = createIdentifier(localNameText);
// When extract to a new variable in JSX content, need to wrap a {} out of the new variable
// or it will become a plain text
if (isInJSXContent(node)) {
localReference = createJsxExpression(/*dotDotDotToken*/ undefined, localReference);
}
changeTracker.replaceNode(context.file, node, localReference);
}
}
@@ -1115,6 +1120,12 @@ namespace ts.refactor.extractSymbol {
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true);
return { renameFilename, renameLocation, edits };
function isInJSXContent(node: Node) {
if (!isJsxElement(node)) return false;
if (isJsxElement(node.parent)) return true;
return false;
}
function transformFunctionInitializerAndType(variableType: TypeNode | undefined, initializer: Expression): { variableType: TypeNode | undefined, initializer: Expression } {
// If no contextual type exists there is nothing to transfer to the function signature
if (variableType === undefined) return { variableType, initializer };
@@ -1215,8 +1226,8 @@ namespace ts.refactor.extractSymbol {
}
function compareTypesByDeclarationOrder(
{type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration},
{type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) {
{ type: type1, declaration: declaration1 }: { type: Type, declaration?: Declaration },
{ type: type2, declaration: declaration2 }: { type: Type, declaration?: Declaration }) {
return compareProperties(declaration1, declaration2, "pos", compareValues)
|| compareStringsCaseSensitive(
@@ -1621,7 +1632,7 @@ namespace ts.refactor.extractSymbol {
// a lot of properties, each of which the walker will visit. Unfortunately, the
// solution isn't as trivial as filtering to user types because of (e.g.) Array.
const symbolWalker = checker.getSymbolWalker(() => (cancellationToken.throwIfCancellationRequested(), true));
const {visitedTypes} = symbolWalker.walkType(type);
const { visitedTypes } = symbolWalker.walkType(type);
for (const visitedType of visitedTypes) {
if (visitedType.isTypeParameter()) {
+5
View File
@@ -145,6 +145,11 @@ namespace ts.refactor {
}
}
}
if (file && isTupleTypeNode(node) && (getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line)) {
setEmitFlags(node, EmitFlags.SingleLine);
}
return forEachChild(node, visitor);
}
}
+17 -10
View File
@@ -328,7 +328,14 @@ namespace ts {
getDocumentationComment(checker: TypeChecker | undefined): SymbolDisplayPart[] {
if (!this.documentationComment) {
this.documentationComment = emptyArray; // Set temporarily to avoid an infinite loop finding inherited docs
this.documentationComment = getDocumentationComment(this.declarations, checker);
if (!this.declarations && (this as Symbol as TransientSymbol).target && ((this as Symbol as TransientSymbol).target as TransientSymbol).tupleLabelDeclaration) {
const labelDecl = ((this as Symbol as TransientSymbol).target as TransientSymbol).tupleLabelDeclaration!;
this.documentationComment = getDocumentationComment([labelDecl], checker);
}
else {
this.documentationComment = getDocumentationComment(this.declarations, checker);
}
}
return this.documentationComment;
}
@@ -1502,7 +1509,7 @@ namespace ts {
position,
{ name, source },
host,
(formattingOptions && formatting.getFormatContext(formattingOptions))!, // TODO: GH#18217
(formattingOptions && formatting.getFormatContext(formattingOptions, host))!, // TODO: GH#18217
preferences,
cancellationToken,
);
@@ -1840,16 +1847,16 @@ namespace ts {
function getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[] {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
return formatting.formatSelection(start, end, sourceFile, formatting.getFormatContext(toEditorSettings(options)));
return formatting.formatSelection(start, end, sourceFile, formatting.getFormatContext(toEditorSettings(options), host));
}
function getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[] {
return formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), formatting.getFormatContext(toEditorSettings(options)));
return formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), formatting.getFormatContext(toEditorSettings(options), host));
}
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[] {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
const formatContext = formatting.getFormatContext(toEditorSettings(options));
const formatContext = formatting.getFormatContext(toEditorSettings(options), host);
if (!isInComment(sourceFile, position)) {
switch (key) {
@@ -1871,7 +1878,7 @@ namespace ts {
synchronizeHostData();
const sourceFile = getValidSourceFile(fileName);
const span = createTextSpanFromBounds(start, end);
const formatContext = formatting.getFormatContext(formatOptions);
const formatContext = formatting.getFormatContext(formatOptions, host);
return flatMap(deduplicate<number>(errorCodes, equateValues, compareValues), errorCode => {
cancellationToken.throwIfCancellationRequested();
@@ -1883,7 +1890,7 @@ namespace ts {
synchronizeHostData();
Debug.assert(scope.type === "file");
const sourceFile = getValidSourceFile(scope.fileName);
const formatContext = formatting.getFormatContext(formatOptions);
const formatContext = formatting.getFormatContext(formatOptions, host);
return codefix.getAllFixes({ fixId, sourceFile, program, host, cancellationToken, formatContext, preferences });
}
@@ -1892,13 +1899,13 @@ namespace ts {
synchronizeHostData();
Debug.assert(scope.type === "file");
const sourceFile = getValidSourceFile(scope.fileName);
const formatContext = formatting.getFormatContext(formatOptions);
const formatContext = formatting.getFormatContext(formatOptions, host);
return OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences);
}
function getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): readonly FileTextChanges[] {
return ts.getEditsForFileRename(getProgram()!, oldFilePath, newFilePath, host, formatting.getFormatContext(formatOptions), preferences, sourceMapper);
return ts.getEditsForFileRename(getProgram()!, oldFilePath, newFilePath, host, formatting.getFormatContext(formatOptions, host), preferences, sourceMapper);
}
function applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult>;
@@ -2141,7 +2148,7 @@ namespace ts {
endPosition,
program: getProgram()!,
host,
formatContext: formatting.getFormatContext(formatOptions!), // TODO: GH#18217
formatContext: formatting.getFormatContext(formatOptions!, host), // TODO: GH#18217
cancellationToken,
preferences,
};
+52 -19
View File
@@ -500,16 +500,37 @@ namespace ts.SignatureHelp {
const enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation);
const callTargetSymbol = invocation.kind === InvocationKind.Contextual ? invocation.symbol : typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation));
const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined) : emptyArray;
const items = candidates.map(candidateSignature => getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile));
const items = map(candidates, candidateSignature => getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile));
if (argumentIndex !== 0) {
Debug.assertLessThan(argumentIndex, argumentCount);
}
const selectedItemIndex = candidates.indexOf(resolvedSignature);
let selectedItemIndex = 0;
let itemsSeen = 0;
for (let i = 0; i < items.length; i++) {
const item = items[i];
if (candidates[i] === resolvedSignature) {
selectedItemIndex = itemsSeen;
if (item.length > 1) {
// check to see if any items in the list better match than the first one, as the checker isn't filtering the nested lists
// (those come from tuple parameter expansion)
let count = 0;
for (const i of item) {
if (i.isVariadic || i.parameters.length >= argumentCount) {
selectedItemIndex = itemsSeen + count;
break;
}
count++;
}
}
}
itemsSeen += item.length;
}
Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function.
return { items, applicableSpan, selectedItemIndex, argumentIndex, argumentCount };
return { items: flatMapToMutable(items, identity), applicableSpan, selectedItemIndex, argumentIndex, argumentCount };
}
function createTypeHelpItems(
@@ -538,13 +559,15 @@ namespace ts.SignatureHelp {
const separatorDisplayParts: SymbolDisplayPart[] = [punctuationPart(SyntaxKind.CommaToken), spacePart()];
function getSignatureHelpItem(candidateSignature: Signature, callTargetDisplayParts: readonly SymbolDisplayPart[], isTypeParameterList: boolean, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem {
const { isVariadic, parameters, prefix, suffix } = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile);
const prefixDisplayParts = [...callTargetDisplayParts, ...prefix];
const suffixDisplayParts = [...suffix, ...returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)];
const documentation = candidateSignature.getDocumentationComment(checker);
const tags = candidateSignature.getJsDocTags();
return { isVariadic, prefixDisplayParts, suffixDisplayParts, separatorDisplayParts, parameters, documentation, tags };
function getSignatureHelpItem(candidateSignature: Signature, callTargetDisplayParts: readonly SymbolDisplayPart[], isTypeParameterList: boolean, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem[] {
const infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile);
return map(infos, ({ isVariadic, parameters, prefix, suffix }) => {
const prefixDisplayParts = [...callTargetDisplayParts, ...prefix];
const suffixDisplayParts = [...suffix, ...returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)];
const documentation = candidateSignature.getDocumentationComment(checker);
const tags = candidateSignature.getJsDocTags();
return { isVariadic, prefixDisplayParts, suffixDisplayParts, separatorDisplayParts, parameters, documentation, tags };
});
}
function returnTypeToDisplayParts(candidateSignature: Signature, enclosingDeclaration: Node, checker: TypeChecker): readonly SymbolDisplayPart[] {
@@ -563,19 +586,22 @@ namespace ts.SignatureHelp {
interface SignatureHelpItemInfo { readonly isVariadic: boolean; readonly parameters: SignatureHelpParameter[]; readonly prefix: readonly SymbolDisplayPart[]; readonly suffix: readonly SymbolDisplayPart[]; }
function itemInfoForTypeParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo {
function itemInfoForTypeParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo[] {
const typeParameters = (candidateSignature.target || candidateSignature).typeParameters;
const printer = createPrinter({ removeComments: true });
const parameters = (typeParameters || emptyArray).map(t => createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer));
const parameterParts = mapToDisplayParts(writer => {
const thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)!] : [];
const params = createNodeArray([...thisParameter, ...checker.getExpandedParameters(candidateSignature).map(param => checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags)!)]);
printer.writeList(ListFormat.CallExpressionArguments, params, sourceFile, writer);
const thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)!] : [];
return checker.getExpandedParameters(candidateSignature).map(paramList => {
const params = createNodeArray([...thisParameter, ...map(paramList, param => checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags)!)]);
const parameterParts = mapToDisplayParts(writer => {
printer.writeList(ListFormat.CallExpressionArguments, params, sourceFile, writer);
});
return { isVariadic: false, parameters, prefix: [punctuationPart(SyntaxKind.LessThanToken)], suffix: [punctuationPart(SyntaxKind.GreaterThanToken), ...parameterParts] };
});
return { isVariadic: false, parameters, prefix: [punctuationPart(SyntaxKind.LessThanToken)], suffix: [punctuationPart(SyntaxKind.GreaterThanToken), ...parameterParts] };
}
function itemInfoForParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo {
function itemInfoForParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo[] {
const isVariadic = checker.hasEffectiveRestParameter(candidateSignature);
const printer = createPrinter({ removeComments: true });
const typeParameterParts = mapToDisplayParts(writer => {
@@ -584,8 +610,15 @@ namespace ts.SignatureHelp {
printer.writeList(ListFormat.TypeParameters, args, sourceFile, writer);
}
});
const parameters = checker.getExpandedParameters(candidateSignature).map(p => createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer));
return { isVariadic, parameters, prefix: [...typeParameterParts, punctuationPart(SyntaxKind.OpenParenToken)], suffix: [punctuationPart(SyntaxKind.CloseParenToken)] };
const lists = checker.getExpandedParameters(candidateSignature);
return lists.map(parameterList => {
return {
isVariadic: isVariadic && (lists.length === 1 || !!((parameterList[parameterList.length - 1] as TransientSymbol).checkFlags & CheckFlags.RestParameter)),
parameters: parameterList.map(p => createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer)),
prefix: [...typeParameterParts, punctuationPart(SyntaxKind.OpenParenToken)],
suffix: [punctuationPart(SyntaxKind.CloseParenToken)]
};
});
}
function createSignatureHelpParameterForParameter(parameter: Symbol, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile, printer: Printer): SignatureHelpParameter {
+8
View File
@@ -481,6 +481,14 @@ namespace ts.SymbolDisplay {
else {
addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
}
if ((symbol as TransientSymbol).target && ((symbol as TransientSymbol).target as TransientSymbol).tupleLabelDeclaration) {
const labelDecl = ((symbol as TransientSymbol).target as TransientSymbol).tupleLabelDeclaration!;
Debug.assertNode(labelDecl.name, isIdentifier);
displayParts.push(spacePart());
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
displayParts.push(textPart(idText(labelDecl.name)));
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
}
}
else if (symbolFlags & SymbolFlags.Function ||
symbolFlags & SymbolFlags.Method ||
+4
View File
@@ -286,6 +286,10 @@ namespace ts.textChanges {
this.deletedNodes.push({ sourceFile, node });
}
public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }): void {
this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
}
public deleteModifier(sourceFile: SourceFile, modifier: Modifier): void {
this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) });
}
+2
View File
@@ -64,6 +64,7 @@
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
"codefixes/importFixes.ts",
"codefixes/fixImplicitThis.ts",
"codefixes/fixIncorrectNamedTupleSyntax.ts",
"codefixes/fixSpelling.ts",
"codefixes/returnValueCorrect.ts",
"codefixes/fixAddMissingMember.ts",
@@ -101,6 +102,7 @@
"codefixes/fixExpectedComma.ts",
"refactors/convertExport.ts",
"refactors/convertImport.ts",
"refactors/convertOverloadListToSingleSignature.ts",
"refactors/extractSymbol.ts",
"refactors/extractType.ts",
"refactors/generateGetAccessorAndSetAccessor.ts",
+5
View File
@@ -203,6 +203,11 @@ namespace ts {
has(dependencyName: string, inGroups?: PackageJsonDependencyGroup): boolean;
}
/** @internal */
export interface FormattingHost {
getNewLine?(): string;
}
//
// Public interface of the host of a language service instance.
//
+3 -3
View File
@@ -2085,9 +2085,9 @@ namespace ts {
/**
* The default is CRLF.
*/
export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost, formatSettings?: FormatCodeSettings) {
return (formatSettings && formatSettings.newLineCharacter) ||
(host.getNewLine && host.getNewLine()) ||
export function getNewLineOrDefaultFromHost(host: FormattingHost, formatSettings?: FormatCodeSettings) {
return formatSettings?.newLineCharacter ||
host.getNewLine?.() ||
carriageReturnLineFeed;
}
@@ -83,7 +83,7 @@ namespace ts {
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -285,7 +285,7 @@ namespace ts {
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -304,7 +304,7 @@ namespace ts {
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
+2 -2
View File
@@ -229,7 +229,7 @@ namespace ts {
// https://github.com/Microsoft/TypeScript/issues/15651
printsCorrectly("functionTypes", {}, printer => printer.printNode(
EmitHint.Unspecified,
createTupleTypeNode([
setEmitFlags(createTupleTypeNode([
createFunctionTypeNode(
/*typeArguments*/ undefined,
[createParameter(
@@ -293,7 +293,7 @@ namespace ts {
)],
createKeywordTypeNode(SyntaxKind.AnyKeyword)
),
]),
]), EmitFlags.SingleLine),
createSourceFile("source.ts", "", ScriptTarget.ES2015)
));
});
@@ -306,7 +306,7 @@ interface Array<T> {}`
cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse },
preferences: emptyOptions,
host: notImplementedHost,
formatContext: formatting.getFormatContext(testFormatSettings)
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost)
};
const diagnostics = languageService.getSuggestionDiagnostics(f.path);
@@ -102,7 +102,7 @@ namespace ts {
startPosition: selectionRange.pos,
endPosition: selectionRange.end,
host: notImplementedHost,
formatContext: formatting.getFormatContext(testFormatSettings),
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost),
preferences: emptyOptions,
};
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
@@ -164,7 +164,7 @@ namespace ts {
startPosition: selectionRange.pos,
endPosition: selectionRange.end,
host: notImplementedHost,
formatContext: formatting.getFormatContext(testFormatSettings),
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost),
preferences: emptyOptions,
};
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
@@ -592,6 +592,22 @@ import "lib1";
{ path: "/lib1.ts", content: "" },
{ path: "/lib2.ts", content: "" });
testOrganizeImports("SortComments",
{
path: "/test.ts",
content: `
// Header
import "lib3";
// Comment2
import "lib2";
// Comment1
import "lib1";
`,
},
{ path: "/lib1.ts", content: "" },
{ path: "/lib2.ts", content: "" },
{ path: "/lib3.ts", content: "" });
testOrganizeImports("AmbientModule",
{
path: "/test.ts",
@@ -19,7 +19,7 @@ namespace ts {
const newLineCharacter = getNewLineCharacter(printerOptions);
function getRuleProvider(placeOpenBraceOnNewLineForFunctions: boolean): formatting.FormatContext {
return formatting.getFormatContext(placeOpenBraceOnNewLineForFunctions ? { ...testFormatSettings, placeOpenBraceOnNewLineForFunctions: true } : testFormatSettings);
return formatting.getFormatContext(placeOpenBraceOnNewLineForFunctions ? { ...testFormatSettings, placeOpenBraceOnNewLineForFunctions: true } : testFormatSettings, notImplementedHost);
}
// validate that positions that were recovered from the printed text actually match positions that will be created if the same text is parsed.
+20
View File
@@ -50,6 +50,15 @@ namespace ts {
return (node: SourceFile) => visitNode(node, visitor);
}
function createTaggedTemplateLiteral(): Transformer<SourceFile> {
return sourceFile => updateSourceFileNode(sourceFile, [
createStatement(
createTaggedTemplate(
createIdentifier("$tpl"),
createNoSubstitutionTemplateLiteral("foo", "foo")))
]);
}
function transformSourceFile(sourceText: string, transformers: TransformerFactory<SourceFile>[]) {
const transformed = transform(createSourceFile("source.ts", sourceText, ScriptTarget.ES2015), transformers);
const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, {
@@ -120,6 +129,17 @@ namespace ts {
}).outputText;
});
testBaseline("transformTaggedTemplateLiteral", () => {
return transpileModule("", {
transformers: {
before: [createTaggedTemplateLiteral],
},
compilerOptions: {
target: ScriptTarget.ES5
}
}).outputText;
});
testBaseline("issue27854", () => {
return transpileModule(`oldName<{ a: string; }>\` ... \`;`, {
transformers: {
@@ -5,7 +5,7 @@
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"elementTypes": {
"elements": {
"length": 0,
"pos": 2,
"end": 2
@@ -5,7 +5,7 @@
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"elementTypes": {
"elements": {
"0": {
"kind": "NumberKeyword",
"pos": 2,
@@ -5,7 +5,7 @@
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"elementTypes": {
"elements": {
"0": {
"kind": "NumberKeyword",
"pos": 2,
@@ -5,7 +5,7 @@
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"elementTypes": {
"elements": {
"0": {
"kind": "NumberKeyword",
"pos": 2,
@@ -5,7 +5,7 @@
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"elementTypes": {
"elements": {
"0": {
"kind": "NumberKeyword",
"pos": 2,
+171 -168
View File
@@ -263,150 +263,151 @@ declare namespace ts {
IndexedAccessType = 185,
MappedType = 186,
LiteralType = 187,
ImportType = 188,
ObjectBindingPattern = 189,
ArrayBindingPattern = 190,
BindingElement = 191,
ArrayLiteralExpression = 192,
ObjectLiteralExpression = 193,
PropertyAccessExpression = 194,
ElementAccessExpression = 195,
CallExpression = 196,
NewExpression = 197,
TaggedTemplateExpression = 198,
TypeAssertionExpression = 199,
ParenthesizedExpression = 200,
FunctionExpression = 201,
ArrowFunction = 202,
DeleteExpression = 203,
TypeOfExpression = 204,
VoidExpression = 205,
AwaitExpression = 206,
PrefixUnaryExpression = 207,
PostfixUnaryExpression = 208,
BinaryExpression = 209,
ConditionalExpression = 210,
TemplateExpression = 211,
YieldExpression = 212,
SpreadElement = 213,
ClassExpression = 214,
OmittedExpression = 215,
ExpressionWithTypeArguments = 216,
AsExpression = 217,
NonNullExpression = 218,
MetaProperty = 219,
SyntheticExpression = 220,
TemplateSpan = 221,
SemicolonClassElement = 222,
Block = 223,
EmptyStatement = 224,
VariableStatement = 225,
ExpressionStatement = 226,
IfStatement = 227,
DoStatement = 228,
WhileStatement = 229,
ForStatement = 230,
ForInStatement = 231,
ForOfStatement = 232,
ContinueStatement = 233,
BreakStatement = 234,
ReturnStatement = 235,
WithStatement = 236,
SwitchStatement = 237,
LabeledStatement = 238,
ThrowStatement = 239,
TryStatement = 240,
DebuggerStatement = 241,
VariableDeclaration = 242,
VariableDeclarationList = 243,
FunctionDeclaration = 244,
ClassDeclaration = 245,
InterfaceDeclaration = 246,
TypeAliasDeclaration = 247,
EnumDeclaration = 248,
ModuleDeclaration = 249,
ModuleBlock = 250,
CaseBlock = 251,
NamespaceExportDeclaration = 252,
ImportEqualsDeclaration = 253,
ImportDeclaration = 254,
ImportClause = 255,
NamespaceImport = 256,
NamedImports = 257,
ImportSpecifier = 258,
ExportAssignment = 259,
ExportDeclaration = 260,
NamedExports = 261,
NamespaceExport = 262,
ExportSpecifier = 263,
MissingDeclaration = 264,
ExternalModuleReference = 265,
JsxElement = 266,
JsxSelfClosingElement = 267,
JsxOpeningElement = 268,
JsxClosingElement = 269,
JsxFragment = 270,
JsxOpeningFragment = 271,
JsxClosingFragment = 272,
JsxAttribute = 273,
JsxAttributes = 274,
JsxSpreadAttribute = 275,
JsxExpression = 276,
CaseClause = 277,
DefaultClause = 278,
HeritageClause = 279,
CatchClause = 280,
PropertyAssignment = 281,
ShorthandPropertyAssignment = 282,
SpreadAssignment = 283,
EnumMember = 284,
UnparsedPrologue = 285,
UnparsedPrepend = 286,
UnparsedText = 287,
UnparsedInternalText = 288,
UnparsedSyntheticReference = 289,
SourceFile = 290,
Bundle = 291,
UnparsedSource = 292,
InputFiles = 293,
JSDocTypeExpression = 294,
JSDocAllType = 295,
JSDocUnknownType = 296,
JSDocNullableType = 297,
JSDocNonNullableType = 298,
JSDocOptionalType = 299,
JSDocFunctionType = 300,
JSDocVariadicType = 301,
JSDocNamepathType = 302,
JSDocComment = 303,
JSDocTypeLiteral = 304,
JSDocSignature = 305,
JSDocTag = 306,
JSDocAugmentsTag = 307,
JSDocImplementsTag = 308,
JSDocAuthorTag = 309,
JSDocClassTag = 310,
JSDocPublicTag = 311,
JSDocPrivateTag = 312,
JSDocProtectedTag = 313,
JSDocReadonlyTag = 314,
JSDocCallbackTag = 315,
JSDocEnumTag = 316,
JSDocParameterTag = 317,
JSDocReturnTag = 318,
JSDocThisTag = 319,
JSDocTypeTag = 320,
JSDocTemplateTag = 321,
JSDocTypedefTag = 322,
JSDocPropertyTag = 323,
SyntaxList = 324,
NotEmittedStatement = 325,
PartiallyEmittedExpression = 326,
CommaListExpression = 327,
MergeDeclarationMarker = 328,
EndOfDeclarationMarker = 329,
SyntheticReferenceExpression = 330,
Count = 331,
NamedTupleMember = 188,
ImportType = 189,
ObjectBindingPattern = 190,
ArrayBindingPattern = 191,
BindingElement = 192,
ArrayLiteralExpression = 193,
ObjectLiteralExpression = 194,
PropertyAccessExpression = 195,
ElementAccessExpression = 196,
CallExpression = 197,
NewExpression = 198,
TaggedTemplateExpression = 199,
TypeAssertionExpression = 200,
ParenthesizedExpression = 201,
FunctionExpression = 202,
ArrowFunction = 203,
DeleteExpression = 204,
TypeOfExpression = 205,
VoidExpression = 206,
AwaitExpression = 207,
PrefixUnaryExpression = 208,
PostfixUnaryExpression = 209,
BinaryExpression = 210,
ConditionalExpression = 211,
TemplateExpression = 212,
YieldExpression = 213,
SpreadElement = 214,
ClassExpression = 215,
OmittedExpression = 216,
ExpressionWithTypeArguments = 217,
AsExpression = 218,
NonNullExpression = 219,
MetaProperty = 220,
SyntheticExpression = 221,
TemplateSpan = 222,
SemicolonClassElement = 223,
Block = 224,
EmptyStatement = 225,
VariableStatement = 226,
ExpressionStatement = 227,
IfStatement = 228,
DoStatement = 229,
WhileStatement = 230,
ForStatement = 231,
ForInStatement = 232,
ForOfStatement = 233,
ContinueStatement = 234,
BreakStatement = 235,
ReturnStatement = 236,
WithStatement = 237,
SwitchStatement = 238,
LabeledStatement = 239,
ThrowStatement = 240,
TryStatement = 241,
DebuggerStatement = 242,
VariableDeclaration = 243,
VariableDeclarationList = 244,
FunctionDeclaration = 245,
ClassDeclaration = 246,
InterfaceDeclaration = 247,
TypeAliasDeclaration = 248,
EnumDeclaration = 249,
ModuleDeclaration = 250,
ModuleBlock = 251,
CaseBlock = 252,
NamespaceExportDeclaration = 253,
ImportEqualsDeclaration = 254,
ImportDeclaration = 255,
ImportClause = 256,
NamespaceImport = 257,
NamedImports = 258,
ImportSpecifier = 259,
ExportAssignment = 260,
ExportDeclaration = 261,
NamedExports = 262,
NamespaceExport = 263,
ExportSpecifier = 264,
MissingDeclaration = 265,
ExternalModuleReference = 266,
JsxElement = 267,
JsxSelfClosingElement = 268,
JsxOpeningElement = 269,
JsxClosingElement = 270,
JsxFragment = 271,
JsxOpeningFragment = 272,
JsxClosingFragment = 273,
JsxAttribute = 274,
JsxAttributes = 275,
JsxSpreadAttribute = 276,
JsxExpression = 277,
CaseClause = 278,
DefaultClause = 279,
HeritageClause = 280,
CatchClause = 281,
PropertyAssignment = 282,
ShorthandPropertyAssignment = 283,
SpreadAssignment = 284,
EnumMember = 285,
UnparsedPrologue = 286,
UnparsedPrepend = 287,
UnparsedText = 288,
UnparsedInternalText = 289,
UnparsedSyntheticReference = 290,
SourceFile = 291,
Bundle = 292,
UnparsedSource = 293,
InputFiles = 294,
JSDocTypeExpression = 295,
JSDocAllType = 296,
JSDocUnknownType = 297,
JSDocNullableType = 298,
JSDocNonNullableType = 299,
JSDocOptionalType = 300,
JSDocFunctionType = 301,
JSDocVariadicType = 302,
JSDocNamepathType = 303,
JSDocComment = 304,
JSDocTypeLiteral = 305,
JSDocSignature = 306,
JSDocTag = 307,
JSDocAugmentsTag = 308,
JSDocImplementsTag = 309,
JSDocAuthorTag = 310,
JSDocClassTag = 311,
JSDocPublicTag = 312,
JSDocPrivateTag = 313,
JSDocProtectedTag = 314,
JSDocReadonlyTag = 315,
JSDocCallbackTag = 316,
JSDocEnumTag = 317,
JSDocParameterTag = 318,
JSDocReturnTag = 319,
JSDocThisTag = 320,
JSDocTypeTag = 321,
JSDocTemplateTag = 322,
JSDocTypedefTag = 323,
JSDocPropertyTag = 324,
SyntaxList = 325,
NotEmittedStatement = 326,
PartiallyEmittedExpression = 327,
CommaListExpression = 328,
MergeDeclarationMarker = 329,
EndOfDeclarationMarker = 330,
SyntheticReferenceExpression = 331,
Count = 332,
FirstAssignment = 62,
LastAssignment = 74,
FirstCompoundAssignment = 63,
@@ -418,7 +419,7 @@ declare namespace ts {
FirstFutureReservedWord = 113,
LastFutureReservedWord = 121,
FirstTypeNode = 168,
LastTypeNode = 188,
LastTypeNode = 189,
FirstPunctuation = 18,
LastPunctuation = 74,
FirstToken = 0,
@@ -431,13 +432,13 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 74,
FirstStatement = 225,
LastStatement = 241,
FirstStatement = 226,
LastStatement = 242,
FirstNode = 153,
FirstJSDocNode = 294,
LastJSDocNode = 323,
FirstJSDocTagNode = 306,
LastJSDocTagNode = 323,
FirstJSDocNode = 295,
LastJSDocNode = 324,
FirstJSDocTagNode = 307,
LastJSDocTagNode = 324,
}
export enum NodeFlags {
None = 0,
@@ -508,7 +509,7 @@ declare namespace ts {
}
export interface JSDocContainer {
}
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken;
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
@@ -809,7 +810,14 @@ declare namespace ts {
}
export interface TupleTypeNode extends TypeNode {
kind: SyntaxKind.TupleType;
elementTypes: NodeArray<TypeNode>;
elements: NodeArray<TypeNode | NamedTupleMember>;
}
export interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
kind: SyntaxKind.NamedTupleMember;
dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
name: Identifier;
questionToken?: Token<SyntaxKind.QuestionToken>;
type: TypeNode;
}
export interface OptionalTypeNode extends TypeNode {
kind: SyntaxKind.OptionalType;
@@ -947,6 +955,7 @@ declare namespace ts {
kind: SyntaxKind.SyntheticExpression;
isSpread: boolean;
type: Type;
tupleNameSource?: ParameterDeclaration | NamedTupleMember;
}
export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken;
export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken;
@@ -1578,6 +1587,7 @@ declare namespace ts {
text: string;
pos: -1;
end: -1;
hasLeadingNewline?: boolean;
}
export interface JSDocTypeExpression extends TypeNode {
kind: SyntaxKind.JSDocTypeExpression;
@@ -1743,21 +1753,11 @@ declare namespace ts {
Label = 12,
Condition = 96
}
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation;
export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
export interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
export interface FlowLock {
locked?: boolean;
}
export interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
export interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
export interface FlowStart extends FlowNodeBase {
node?: FunctionExpression | ArrowFunction | MethodDeclaration;
}
@@ -2476,7 +2476,7 @@ declare namespace ts {
minLength: number;
hasRestElement: boolean;
readonly: boolean;
associatedNames?: __String[];
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
export interface TupleTypeReference extends TypeReference {
target: TupleType;
@@ -3233,7 +3233,8 @@ declare namespace ts {
HeritageClauses = 512,
SingleLineTypeLiteralMembers = 768,
MultiLineTypeLiteralMembers = 32897,
TupleTypeElements = 528,
SingleLineTupleTypeElements = 528,
MultiLineTupleTypeElements = 657,
UnionTypeConstituents = 516,
IntersectionTypeConstituents = 520,
ObjectBindingPatternElements = 525136,
@@ -4053,8 +4054,8 @@ declare namespace ts {
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode;
function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode;
function createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
function updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
function createOptionalTypeNode(type: TypeNode): OptionalTypeNode;
function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode;
function createRestTypeNode(type: TypeNode): RestTypeNode;
@@ -4072,6 +4073,8 @@ declare namespace ts {
function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
function createNamedTupleMember(dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode): NamedTupleMember;
function updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode): NamedTupleMember;
function createThisTypeNode(): ThisTypeNode;
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
+171 -168
View File
@@ -263,150 +263,151 @@ declare namespace ts {
IndexedAccessType = 185,
MappedType = 186,
LiteralType = 187,
ImportType = 188,
ObjectBindingPattern = 189,
ArrayBindingPattern = 190,
BindingElement = 191,
ArrayLiteralExpression = 192,
ObjectLiteralExpression = 193,
PropertyAccessExpression = 194,
ElementAccessExpression = 195,
CallExpression = 196,
NewExpression = 197,
TaggedTemplateExpression = 198,
TypeAssertionExpression = 199,
ParenthesizedExpression = 200,
FunctionExpression = 201,
ArrowFunction = 202,
DeleteExpression = 203,
TypeOfExpression = 204,
VoidExpression = 205,
AwaitExpression = 206,
PrefixUnaryExpression = 207,
PostfixUnaryExpression = 208,
BinaryExpression = 209,
ConditionalExpression = 210,
TemplateExpression = 211,
YieldExpression = 212,
SpreadElement = 213,
ClassExpression = 214,
OmittedExpression = 215,
ExpressionWithTypeArguments = 216,
AsExpression = 217,
NonNullExpression = 218,
MetaProperty = 219,
SyntheticExpression = 220,
TemplateSpan = 221,
SemicolonClassElement = 222,
Block = 223,
EmptyStatement = 224,
VariableStatement = 225,
ExpressionStatement = 226,
IfStatement = 227,
DoStatement = 228,
WhileStatement = 229,
ForStatement = 230,
ForInStatement = 231,
ForOfStatement = 232,
ContinueStatement = 233,
BreakStatement = 234,
ReturnStatement = 235,
WithStatement = 236,
SwitchStatement = 237,
LabeledStatement = 238,
ThrowStatement = 239,
TryStatement = 240,
DebuggerStatement = 241,
VariableDeclaration = 242,
VariableDeclarationList = 243,
FunctionDeclaration = 244,
ClassDeclaration = 245,
InterfaceDeclaration = 246,
TypeAliasDeclaration = 247,
EnumDeclaration = 248,
ModuleDeclaration = 249,
ModuleBlock = 250,
CaseBlock = 251,
NamespaceExportDeclaration = 252,
ImportEqualsDeclaration = 253,
ImportDeclaration = 254,
ImportClause = 255,
NamespaceImport = 256,
NamedImports = 257,
ImportSpecifier = 258,
ExportAssignment = 259,
ExportDeclaration = 260,
NamedExports = 261,
NamespaceExport = 262,
ExportSpecifier = 263,
MissingDeclaration = 264,
ExternalModuleReference = 265,
JsxElement = 266,
JsxSelfClosingElement = 267,
JsxOpeningElement = 268,
JsxClosingElement = 269,
JsxFragment = 270,
JsxOpeningFragment = 271,
JsxClosingFragment = 272,
JsxAttribute = 273,
JsxAttributes = 274,
JsxSpreadAttribute = 275,
JsxExpression = 276,
CaseClause = 277,
DefaultClause = 278,
HeritageClause = 279,
CatchClause = 280,
PropertyAssignment = 281,
ShorthandPropertyAssignment = 282,
SpreadAssignment = 283,
EnumMember = 284,
UnparsedPrologue = 285,
UnparsedPrepend = 286,
UnparsedText = 287,
UnparsedInternalText = 288,
UnparsedSyntheticReference = 289,
SourceFile = 290,
Bundle = 291,
UnparsedSource = 292,
InputFiles = 293,
JSDocTypeExpression = 294,
JSDocAllType = 295,
JSDocUnknownType = 296,
JSDocNullableType = 297,
JSDocNonNullableType = 298,
JSDocOptionalType = 299,
JSDocFunctionType = 300,
JSDocVariadicType = 301,
JSDocNamepathType = 302,
JSDocComment = 303,
JSDocTypeLiteral = 304,
JSDocSignature = 305,
JSDocTag = 306,
JSDocAugmentsTag = 307,
JSDocImplementsTag = 308,
JSDocAuthorTag = 309,
JSDocClassTag = 310,
JSDocPublicTag = 311,
JSDocPrivateTag = 312,
JSDocProtectedTag = 313,
JSDocReadonlyTag = 314,
JSDocCallbackTag = 315,
JSDocEnumTag = 316,
JSDocParameterTag = 317,
JSDocReturnTag = 318,
JSDocThisTag = 319,
JSDocTypeTag = 320,
JSDocTemplateTag = 321,
JSDocTypedefTag = 322,
JSDocPropertyTag = 323,
SyntaxList = 324,
NotEmittedStatement = 325,
PartiallyEmittedExpression = 326,
CommaListExpression = 327,
MergeDeclarationMarker = 328,
EndOfDeclarationMarker = 329,
SyntheticReferenceExpression = 330,
Count = 331,
NamedTupleMember = 188,
ImportType = 189,
ObjectBindingPattern = 190,
ArrayBindingPattern = 191,
BindingElement = 192,
ArrayLiteralExpression = 193,
ObjectLiteralExpression = 194,
PropertyAccessExpression = 195,
ElementAccessExpression = 196,
CallExpression = 197,
NewExpression = 198,
TaggedTemplateExpression = 199,
TypeAssertionExpression = 200,
ParenthesizedExpression = 201,
FunctionExpression = 202,
ArrowFunction = 203,
DeleteExpression = 204,
TypeOfExpression = 205,
VoidExpression = 206,
AwaitExpression = 207,
PrefixUnaryExpression = 208,
PostfixUnaryExpression = 209,
BinaryExpression = 210,
ConditionalExpression = 211,
TemplateExpression = 212,
YieldExpression = 213,
SpreadElement = 214,
ClassExpression = 215,
OmittedExpression = 216,
ExpressionWithTypeArguments = 217,
AsExpression = 218,
NonNullExpression = 219,
MetaProperty = 220,
SyntheticExpression = 221,
TemplateSpan = 222,
SemicolonClassElement = 223,
Block = 224,
EmptyStatement = 225,
VariableStatement = 226,
ExpressionStatement = 227,
IfStatement = 228,
DoStatement = 229,
WhileStatement = 230,
ForStatement = 231,
ForInStatement = 232,
ForOfStatement = 233,
ContinueStatement = 234,
BreakStatement = 235,
ReturnStatement = 236,
WithStatement = 237,
SwitchStatement = 238,
LabeledStatement = 239,
ThrowStatement = 240,
TryStatement = 241,
DebuggerStatement = 242,
VariableDeclaration = 243,
VariableDeclarationList = 244,
FunctionDeclaration = 245,
ClassDeclaration = 246,
InterfaceDeclaration = 247,
TypeAliasDeclaration = 248,
EnumDeclaration = 249,
ModuleDeclaration = 250,
ModuleBlock = 251,
CaseBlock = 252,
NamespaceExportDeclaration = 253,
ImportEqualsDeclaration = 254,
ImportDeclaration = 255,
ImportClause = 256,
NamespaceImport = 257,
NamedImports = 258,
ImportSpecifier = 259,
ExportAssignment = 260,
ExportDeclaration = 261,
NamedExports = 262,
NamespaceExport = 263,
ExportSpecifier = 264,
MissingDeclaration = 265,
ExternalModuleReference = 266,
JsxElement = 267,
JsxSelfClosingElement = 268,
JsxOpeningElement = 269,
JsxClosingElement = 270,
JsxFragment = 271,
JsxOpeningFragment = 272,
JsxClosingFragment = 273,
JsxAttribute = 274,
JsxAttributes = 275,
JsxSpreadAttribute = 276,
JsxExpression = 277,
CaseClause = 278,
DefaultClause = 279,
HeritageClause = 280,
CatchClause = 281,
PropertyAssignment = 282,
ShorthandPropertyAssignment = 283,
SpreadAssignment = 284,
EnumMember = 285,
UnparsedPrologue = 286,
UnparsedPrepend = 287,
UnparsedText = 288,
UnparsedInternalText = 289,
UnparsedSyntheticReference = 290,
SourceFile = 291,
Bundle = 292,
UnparsedSource = 293,
InputFiles = 294,
JSDocTypeExpression = 295,
JSDocAllType = 296,
JSDocUnknownType = 297,
JSDocNullableType = 298,
JSDocNonNullableType = 299,
JSDocOptionalType = 300,
JSDocFunctionType = 301,
JSDocVariadicType = 302,
JSDocNamepathType = 303,
JSDocComment = 304,
JSDocTypeLiteral = 305,
JSDocSignature = 306,
JSDocTag = 307,
JSDocAugmentsTag = 308,
JSDocImplementsTag = 309,
JSDocAuthorTag = 310,
JSDocClassTag = 311,
JSDocPublicTag = 312,
JSDocPrivateTag = 313,
JSDocProtectedTag = 314,
JSDocReadonlyTag = 315,
JSDocCallbackTag = 316,
JSDocEnumTag = 317,
JSDocParameterTag = 318,
JSDocReturnTag = 319,
JSDocThisTag = 320,
JSDocTypeTag = 321,
JSDocTemplateTag = 322,
JSDocTypedefTag = 323,
JSDocPropertyTag = 324,
SyntaxList = 325,
NotEmittedStatement = 326,
PartiallyEmittedExpression = 327,
CommaListExpression = 328,
MergeDeclarationMarker = 329,
EndOfDeclarationMarker = 330,
SyntheticReferenceExpression = 331,
Count = 332,
FirstAssignment = 62,
LastAssignment = 74,
FirstCompoundAssignment = 63,
@@ -418,7 +419,7 @@ declare namespace ts {
FirstFutureReservedWord = 113,
LastFutureReservedWord = 121,
FirstTypeNode = 168,
LastTypeNode = 188,
LastTypeNode = 189,
FirstPunctuation = 18,
LastPunctuation = 74,
FirstToken = 0,
@@ -431,13 +432,13 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 74,
FirstStatement = 225,
LastStatement = 241,
FirstStatement = 226,
LastStatement = 242,
FirstNode = 153,
FirstJSDocNode = 294,
LastJSDocNode = 323,
FirstJSDocTagNode = 306,
LastJSDocTagNode = 323,
FirstJSDocNode = 295,
LastJSDocNode = 324,
FirstJSDocTagNode = 307,
LastJSDocTagNode = 324,
}
export enum NodeFlags {
None = 0,
@@ -508,7 +509,7 @@ declare namespace ts {
}
export interface JSDocContainer {
}
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken;
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
@@ -809,7 +810,14 @@ declare namespace ts {
}
export interface TupleTypeNode extends TypeNode {
kind: SyntaxKind.TupleType;
elementTypes: NodeArray<TypeNode>;
elements: NodeArray<TypeNode | NamedTupleMember>;
}
export interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
kind: SyntaxKind.NamedTupleMember;
dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
name: Identifier;
questionToken?: Token<SyntaxKind.QuestionToken>;
type: TypeNode;
}
export interface OptionalTypeNode extends TypeNode {
kind: SyntaxKind.OptionalType;
@@ -947,6 +955,7 @@ declare namespace ts {
kind: SyntaxKind.SyntheticExpression;
isSpread: boolean;
type: Type;
tupleNameSource?: ParameterDeclaration | NamedTupleMember;
}
export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken;
export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken;
@@ -1578,6 +1587,7 @@ declare namespace ts {
text: string;
pos: -1;
end: -1;
hasLeadingNewline?: boolean;
}
export interface JSDocTypeExpression extends TypeNode {
kind: SyntaxKind.JSDocTypeExpression;
@@ -1743,21 +1753,11 @@ declare namespace ts {
Label = 12,
Condition = 96
}
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation;
export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
export interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
export interface FlowLock {
locked?: boolean;
}
export interface AfterFinallyFlow extends FlowNodeBase, FlowLock {
antecedent: FlowNode;
}
export interface PreFinallyFlow extends FlowNodeBase {
antecedent: FlowNode;
lock: FlowLock;
}
export interface FlowStart extends FlowNodeBase {
node?: FunctionExpression | ArrowFunction | MethodDeclaration;
}
@@ -2476,7 +2476,7 @@ declare namespace ts {
minLength: number;
hasRestElement: boolean;
readonly: boolean;
associatedNames?: __String[];
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
export interface TupleTypeReference extends TypeReference {
target: TupleType;
@@ -3233,7 +3233,8 @@ declare namespace ts {
HeritageClauses = 512,
SingleLineTypeLiteralMembers = 768,
MultiLineTypeLiteralMembers = 32897,
TupleTypeElements = 528,
SingleLineTupleTypeElements = 528,
MultiLineTupleTypeElements = 657,
UnionTypeConstituents = 516,
IntersectionTypeConstituents = 520,
ObjectBindingPatternElements = 525136,
@@ -4053,8 +4054,8 @@ declare namespace ts {
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode;
function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode;
function createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
function updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
function createOptionalTypeNode(type: TypeNode): OptionalTypeNode;
function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode;
function createRestTypeNode(type: TypeNode): RestTypeNode;
@@ -4072,6 +4073,8 @@ declare namespace ts {
function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
function createNamedTupleMember(dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode): NamedTupleMember;
function updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode): NamedTupleMember;
function createThisTypeNode(): ThisTypeNode;
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
@@ -1,17 +0,0 @@
tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts(9,24): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
==== tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts (1 errors) ====
class A {
constructor(f: () => string) {
}
public blah(): string { return ""; }
}
class B extends A {
constructor() {
super(() => { return super.blah(); })
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
}
}
@@ -0,0 +1,123 @@
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(7,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(8,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(9,18): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(20,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(21,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(22,22): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(30,30): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(39,22): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(43,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(44,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(45,18): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(59,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
==== tests/cases/compiler/checkSuperCallBeforeThisAccess.ts (13 errors) ====
class A {
x = 1;
}
class C1 extends A {
constructor(n: number) {
let a1 = this; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let a2 = this.x; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let a3 = super.x; // Error
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
let a4 = () => this;
let a5 = () => this.x;
let a6 = () => super.x;
if (!!true) {
super();
let b1 = this;
let b2 = this.x;
let b3 = super.x;
}
else {
let c1 = this; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let c2 = this.x; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let c3 = super.x; // Error
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
}
if (!!true) {
switch (n) {
case 1:
super();
let d1 = this.x;
case 2:
let d2 = this.x; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
default:
super();
let d3 = this.x;
}
let d4 = this.x;
}
if (!!true) {
let e1 = { w: !!true ? super() : 0 };
let e2 = this.x; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let e3 = { w: !!true ? super() : super() };
let e4 = this.x;
}
let f1 = this; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let f2 = this.x; // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
let f3 = super.x; // Error
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
}
}
// Repro from #38512
export class Foo {
constructor(value: number) {
}
}
export class BarCorrectlyFails extends Foo {
constructor(something: boolean) {
if (!something) {
const value = this.bar(); // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
super(value);
}
else {
super(1337);
}
}
bar(): number { return 4; }
}
export class BarIncorrectlyWorks extends Foo {
constructor(something: boolean) {
if (something) {
super(1337);
}
else {
const value = this.bar(); // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
super(value);
}
}
bar(): number { return 4; }
}
@@ -0,0 +1,161 @@
//// [checkSuperCallBeforeThisAccess.ts]
class A {
x = 1;
}
class C1 extends A {
constructor(n: number) {
let a1 = this; // Error
let a2 = this.x; // Error
let a3 = super.x; // Error
let a4 = () => this;
let a5 = () => this.x;
let a6 = () => super.x;
if (!!true) {
super();
let b1 = this;
let b2 = this.x;
let b3 = super.x;
}
else {
let c1 = this; // Error
let c2 = this.x; // Error
let c3 = super.x; // Error
}
if (!!true) {
switch (n) {
case 1:
super();
let d1 = this.x;
case 2:
let d2 = this.x; // Error
default:
super();
let d3 = this.x;
}
let d4 = this.x;
}
if (!!true) {
let e1 = { w: !!true ? super() : 0 };
let e2 = this.x; // Error
let e3 = { w: !!true ? super() : super() };
let e4 = this.x;
}
let f1 = this; // Error
let f2 = this.x; // Error
let f3 = super.x; // Error
}
}
// Repro from #38512
export class Foo {
constructor(value: number) {
}
}
export class BarCorrectlyFails extends Foo {
constructor(something: boolean) {
if (!something) {
const value = this.bar(); // Error
super(value);
}
else {
super(1337);
}
}
bar(): number { return 4; }
}
export class BarIncorrectlyWorks extends Foo {
constructor(something: boolean) {
if (something) {
super(1337);
}
else {
const value = this.bar(); // Error
super(value);
}
}
bar(): number { return 4; }
}
//// [checkSuperCallBeforeThisAccess.js]
class A {
constructor() {
this.x = 1;
}
}
class C1 extends A {
constructor(n) {
let a1 = this; // Error
let a2 = this.x; // Error
let a3 = super.x; // Error
let a4 = () => this;
let a5 = () => this.x;
let a6 = () => super.x;
if (!!true) {
super();
let b1 = this;
let b2 = this.x;
let b3 = super.x;
}
else {
let c1 = this; // Error
let c2 = this.x; // Error
let c3 = super.x; // Error
}
if (!!true) {
switch (n) {
case 1:
super();
let d1 = this.x;
case 2:
let d2 = this.x; // Error
default:
super();
let d3 = this.x;
}
let d4 = this.x;
}
if (!!true) {
let e1 = { w: !!true ? super() : 0 };
let e2 = this.x; // Error
let e3 = { w: !!true ? super() : super() };
let e4 = this.x;
}
let f1 = this; // Error
let f2 = this.x; // Error
let f3 = super.x; // Error
}
}
// Repro from #38512
export class Foo {
constructor(value) {
}
}
export class BarCorrectlyFails extends Foo {
constructor(something) {
if (!something) {
const value = this.bar(); // Error
super(value);
}
else {
super(1337);
}
}
bar() { return 4; }
}
export class BarIncorrectlyWorks extends Foo {
constructor(something) {
if (something) {
super(1337);
}
else {
const value = this.bar(); // Error
super(value);
}
}
bar() { return 4; }
}
@@ -0,0 +1,231 @@
=== tests/cases/compiler/checkSuperCallBeforeThisAccess.ts ===
class A {
>A : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
x = 1;
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
class C1 extends A {
>C1 : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>A : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
constructor(n: number) {
>n : Symbol(n, Decl(checkSuperCallBeforeThisAccess.ts, 5, 16))
let a1 = this; // Error
>a1 : Symbol(a1, Decl(checkSuperCallBeforeThisAccess.ts, 6, 11))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
let a2 = this.x; // Error
>a2 : Symbol(a2, Decl(checkSuperCallBeforeThisAccess.ts, 7, 11))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let a3 = super.x; // Error
>a3 : Symbol(a3, Decl(checkSuperCallBeforeThisAccess.ts, 8, 11))
>super.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let a4 = () => this;
>a4 : Symbol(a4, Decl(checkSuperCallBeforeThisAccess.ts, 9, 11))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
let a5 = () => this.x;
>a5 : Symbol(a5, Decl(checkSuperCallBeforeThisAccess.ts, 10, 11))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let a6 = () => super.x;
>a6 : Symbol(a6, Decl(checkSuperCallBeforeThisAccess.ts, 11, 11))
>super.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
if (!!true) {
super();
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
let b1 = this;
>b1 : Symbol(b1, Decl(checkSuperCallBeforeThisAccess.ts, 14, 15))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
let b2 = this.x;
>b2 : Symbol(b2, Decl(checkSuperCallBeforeThisAccess.ts, 15, 15))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let b3 = super.x;
>b3 : Symbol(b3, Decl(checkSuperCallBeforeThisAccess.ts, 16, 15))
>super.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
else {
let c1 = this; // Error
>c1 : Symbol(c1, Decl(checkSuperCallBeforeThisAccess.ts, 19, 15))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
let c2 = this.x; // Error
>c2 : Symbol(c2, Decl(checkSuperCallBeforeThisAccess.ts, 20, 15))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let c3 = super.x; // Error
>c3 : Symbol(c3, Decl(checkSuperCallBeforeThisAccess.ts, 21, 15))
>super.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
if (!!true) {
switch (n) {
>n : Symbol(n, Decl(checkSuperCallBeforeThisAccess.ts, 5, 16))
case 1:
super();
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
let d1 = this.x;
>d1 : Symbol(d1, Decl(checkSuperCallBeforeThisAccess.ts, 27, 23))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
case 2:
let d2 = this.x; // Error
>d2 : Symbol(d2, Decl(checkSuperCallBeforeThisAccess.ts, 29, 23))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
default:
super();
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
let d3 = this.x;
>d3 : Symbol(d3, Decl(checkSuperCallBeforeThisAccess.ts, 32, 23))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
let d4 = this.x;
>d4 : Symbol(d4, Decl(checkSuperCallBeforeThisAccess.ts, 34, 15))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
if (!!true) {
let e1 = { w: !!true ? super() : 0 };
>e1 : Symbol(e1, Decl(checkSuperCallBeforeThisAccess.ts, 37, 15))
>w : Symbol(w, Decl(checkSuperCallBeforeThisAccess.ts, 37, 22))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
let e2 = this.x; // Error
>e2 : Symbol(e2, Decl(checkSuperCallBeforeThisAccess.ts, 38, 15))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let e3 = { w: !!true ? super() : super() };
>e3 : Symbol(e3, Decl(checkSuperCallBeforeThisAccess.ts, 39, 15))
>w : Symbol(w, Decl(checkSuperCallBeforeThisAccess.ts, 39, 22))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
let e4 = this.x;
>e4 : Symbol(e4, Decl(checkSuperCallBeforeThisAccess.ts, 40, 15))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
let f1 = this; // Error
>f1 : Symbol(f1, Decl(checkSuperCallBeforeThisAccess.ts, 42, 11))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
let f2 = this.x; // Error
>f2 : Symbol(f2, Decl(checkSuperCallBeforeThisAccess.ts, 43, 11))
>this.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>this : Symbol(C1, Decl(checkSuperCallBeforeThisAccess.ts, 2, 1))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
let f3 = super.x; // Error
>f3 : Symbol(f3, Decl(checkSuperCallBeforeThisAccess.ts, 44, 11))
>super.x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
>super : Symbol(A, Decl(checkSuperCallBeforeThisAccess.ts, 0, 0))
>x : Symbol(A.x, Decl(checkSuperCallBeforeThisAccess.ts, 0, 9))
}
}
// Repro from #38512
export class Foo {
>Foo : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
constructor(value: number) {
>value : Symbol(value, Decl(checkSuperCallBeforeThisAccess.ts, 51, 16))
}
}
export class BarCorrectlyFails extends Foo {
>BarCorrectlyFails : Symbol(BarCorrectlyFails, Decl(checkSuperCallBeforeThisAccess.ts, 53, 1))
>Foo : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
constructor(something: boolean) {
>something : Symbol(something, Decl(checkSuperCallBeforeThisAccess.ts, 56, 16))
if (!something) {
>something : Symbol(something, Decl(checkSuperCallBeforeThisAccess.ts, 56, 16))
const value = this.bar(); // Error
>value : Symbol(value, Decl(checkSuperCallBeforeThisAccess.ts, 58, 17))
>this.bar : Symbol(BarCorrectlyFails.bar, Decl(checkSuperCallBeforeThisAccess.ts, 64, 5))
>this : Symbol(BarCorrectlyFails, Decl(checkSuperCallBeforeThisAccess.ts, 53, 1))
>bar : Symbol(BarCorrectlyFails.bar, Decl(checkSuperCallBeforeThisAccess.ts, 64, 5))
super(value);
>super : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
>value : Symbol(value, Decl(checkSuperCallBeforeThisAccess.ts, 58, 17))
}
else {
super(1337);
>super : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
}
}
bar(): number { return 4; }
>bar : Symbol(BarCorrectlyFails.bar, Decl(checkSuperCallBeforeThisAccess.ts, 64, 5))
}
export class BarIncorrectlyWorks extends Foo {
>BarIncorrectlyWorks : Symbol(BarIncorrectlyWorks, Decl(checkSuperCallBeforeThisAccess.ts, 66, 1))
>Foo : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
constructor(something: boolean) {
>something : Symbol(something, Decl(checkSuperCallBeforeThisAccess.ts, 69, 16))
if (something) {
>something : Symbol(something, Decl(checkSuperCallBeforeThisAccess.ts, 69, 16))
super(1337);
>super : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
}
else {
const value = this.bar(); // Error
>value : Symbol(value, Decl(checkSuperCallBeforeThisAccess.ts, 74, 17))
>this.bar : Symbol(BarIncorrectlyWorks.bar, Decl(checkSuperCallBeforeThisAccess.ts, 77, 5))
>this : Symbol(BarIncorrectlyWorks, Decl(checkSuperCallBeforeThisAccess.ts, 66, 1))
>bar : Symbol(BarIncorrectlyWorks.bar, Decl(checkSuperCallBeforeThisAccess.ts, 77, 5))
super(value);
>super : Symbol(Foo, Decl(checkSuperCallBeforeThisAccess.ts, 46, 1))
>value : Symbol(value, Decl(checkSuperCallBeforeThisAccess.ts, 74, 17))
}
}
bar(): number { return 4; }
>bar : Symbol(BarIncorrectlyWorks.bar, Decl(checkSuperCallBeforeThisAccess.ts, 77, 5))
}
@@ -0,0 +1,279 @@
=== tests/cases/compiler/checkSuperCallBeforeThisAccess.ts ===
class A {
>A : A
x = 1;
>x : number
>1 : 1
}
class C1 extends A {
>C1 : C1
>A : A
constructor(n: number) {
>n : number
let a1 = this; // Error
>a1 : this
>this : this
let a2 = this.x; // Error
>a2 : number
>this.x : number
>this : this
>x : number
let a3 = super.x; // Error
>a3 : number
>super.x : number
>super : A
>x : number
let a4 = () => this;
>a4 : () => this
>() => this : () => this
>this : this
let a5 = () => this.x;
>a5 : () => number
>() => this.x : () => number
>this.x : number
>this : this
>x : number
let a6 = () => super.x;
>a6 : () => number
>() => super.x : () => number
>super.x : number
>super : A
>x : number
if (!!true) {
>!!true : true
>!true : false
>true : true
super();
>super() : void
>super : typeof A
let b1 = this;
>b1 : this
>this : this
let b2 = this.x;
>b2 : number
>this.x : number
>this : this
>x : number
let b3 = super.x;
>b3 : number
>super.x : number
>super : A
>x : number
}
else {
let c1 = this; // Error
>c1 : this
>this : this
let c2 = this.x; // Error
>c2 : number
>this.x : number
>this : this
>x : number
let c3 = super.x; // Error
>c3 : number
>super.x : number
>super : A
>x : number
}
if (!!true) {
>!!true : true
>!true : false
>true : true
switch (n) {
>n : number
case 1:
>1 : 1
super();
>super() : void
>super : typeof A
let d1 = this.x;
>d1 : number
>this.x : number
>this : this
>x : number
case 2:
>2 : 2
let d2 = this.x; // Error
>d2 : number
>this.x : number
>this : this
>x : number
default:
super();
>super() : void
>super : typeof A
let d3 = this.x;
>d3 : number
>this.x : number
>this : this
>x : number
}
let d4 = this.x;
>d4 : number
>this.x : number
>this : this
>x : number
}
if (!!true) {
>!!true : true
>!true : false
>true : true
let e1 = { w: !!true ? super() : 0 };
>e1 : { w: number | void; }
>{ w: !!true ? super() : 0 } : { w: number | void; }
>w : number | void
>!!true ? super() : 0 : void | 0
>!!true : true
>!true : false
>true : true
>super() : void
>super : typeof A
>0 : 0
let e2 = this.x; // Error
>e2 : number
>this.x : number
>this : this
>x : number
let e3 = { w: !!true ? super() : super() };
>e3 : { w: void; }
>{ w: !!true ? super() : super() } : { w: void; }
>w : void
>!!true ? super() : super() : void
>!!true : true
>!true : false
>true : true
>super() : void
>super : typeof A
>super() : void
>super : typeof A
let e4 = this.x;
>e4 : number
>this.x : number
>this : this
>x : number
}
let f1 = this; // Error
>f1 : this
>this : this
let f2 = this.x; // Error
>f2 : number
>this.x : number
>this : this
>x : number
let f3 = super.x; // Error
>f3 : number
>super.x : number
>super : A
>x : number
}
}
// Repro from #38512
export class Foo {
>Foo : Foo
constructor(value: number) {
>value : number
}
}
export class BarCorrectlyFails extends Foo {
>BarCorrectlyFails : BarCorrectlyFails
>Foo : Foo
constructor(something: boolean) {
>something : boolean
if (!something) {
>!something : boolean
>something : boolean
const value = this.bar(); // Error
>value : number
>this.bar() : number
>this.bar : () => number
>this : this
>bar : () => number
super(value);
>super(value) : void
>super : typeof Foo
>value : number
}
else {
super(1337);
>super(1337) : void
>super : typeof Foo
>1337 : 1337
}
}
bar(): number { return 4; }
>bar : () => number
>4 : 4
}
export class BarIncorrectlyWorks extends Foo {
>BarIncorrectlyWorks : BarIncorrectlyWorks
>Foo : Foo
constructor(something: boolean) {
>something : boolean
if (something) {
>something : boolean
super(1337);
>super(1337) : void
>super : typeof Foo
>1337 : 1337
}
else {
const value = this.bar(); // Error
>value : number
>this.bar() : number
>this.bar : () => number
>this : this
>bar : () => number
super(value);
>super(value) : void
>super : typeof Foo
>value : number
}
}
bar(): number { return 4; }
>bar : () => number
>4 : 4
}
@@ -0,0 +1,32 @@
//// [circularContextualMappedType.ts]
type Func<T> = () => T;
type Mapped<T> = { [K in keyof T]: Func<T[K]> };
declare function reproduce(options: number): void;
declare function reproduce<T>(options: Mapped<T>): T
reproduce({
name: () => { return 123 }
});
reproduce({
name() { return 123 }
});
reproduce({
name: function () { return 123 }
});
//// [circularContextualMappedType.js]
"use strict";
reproduce({
name: function () { return 123; }
});
reproduce({
name: function () { return 123; }
});
reproduce({
name: function () { return 123; }
});
@@ -0,0 +1,51 @@
=== tests/cases/compiler/circularContextualMappedType.ts ===
type Func<T> = () => T;
>Func : Symbol(Func, Decl(circularContextualMappedType.ts, 0, 0))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 0, 10))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 0, 10))
type Mapped<T> = { [K in keyof T]: Func<T[K]> };
>Mapped : Symbol(Mapped, Decl(circularContextualMappedType.ts, 0, 23))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12))
>K : Symbol(K, Decl(circularContextualMappedType.ts, 2, 20))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12))
>Func : Symbol(Func, Decl(circularContextualMappedType.ts, 0, 0))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12))
>K : Symbol(K, Decl(circularContextualMappedType.ts, 2, 20))
declare function reproduce(options: number): void;
>reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50))
>options : Symbol(options, Decl(circularContextualMappedType.ts, 4, 27))
declare function reproduce<T>(options: Mapped<T>): T
>reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27))
>options : Symbol(options, Decl(circularContextualMappedType.ts, 5, 30))
>Mapped : Symbol(Mapped, Decl(circularContextualMappedType.ts, 0, 23))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27))
>T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27))
reproduce({
>reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50))
name: () => { return 123 }
>name : Symbol(name, Decl(circularContextualMappedType.ts, 7, 11))
});
reproduce({
>reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50))
name() { return 123 }
>name : Symbol(name, Decl(circularContextualMappedType.ts, 11, 11))
});
reproduce({
>reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50))
name: function () { return 123 }
>name : Symbol(name, Decl(circularContextualMappedType.ts, 15, 11))
});
@@ -0,0 +1,50 @@
=== tests/cases/compiler/circularContextualMappedType.ts ===
type Func<T> = () => T;
>Func : Func<T>
type Mapped<T> = { [K in keyof T]: Func<T[K]> };
>Mapped : Mapped<T>
declare function reproduce(options: number): void;
>reproduce : { (options: number): void; <T>(options: Mapped<T>): T; }
>options : number
declare function reproduce<T>(options: Mapped<T>): T
>reproduce : { (options: number): void; <T>(options: Mapped<T>): T; }
>options : Mapped<T>
reproduce({
>reproduce({ name: () => { return 123 }}) : { name: number; }
>reproduce : { (options: number): void; <T>(options: Mapped<T>): T; }
>{ name: () => { return 123 }} : { name: () => number; }
name: () => { return 123 }
>name : () => number
>() => { return 123 } : () => number
>123 : 123
});
reproduce({
>reproduce({ name() { return 123 }}) : { name: number; }
>reproduce : { (options: number): void; <T>(options: Mapped<T>): T; }
>{ name() { return 123 }} : { name(): number; }
name() { return 123 }
>name : () => number
>123 : 123
});
reproduce({
>reproduce({ name: function () { return 123 }}) : { name: number; }
>reproduce : { (options: number): void; <T>(options: Mapped<T>): T; }
>{ name: function () { return 123 }} : { name: () => number; }
name: function () { return 123 }
>name : () => number
>function () { return 123 } : () => number
>123 : 123
});
@@ -665,7 +665,7 @@ const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: nu
>1 : 1
type T01 = Parameters<(x: number, y: string, z: boolean) => void>;
>T01 : [number, string, boolean]
>T01 : [x: number, y: string, z: boolean]
>x : number
>y : string
>z : boolean
@@ -675,7 +675,7 @@ type T02 = Parameters<(...args: [number, string, boolean]) => void>;
>args : [number, string, boolean]
type T03 = ConstructorParameters<new (x: number, y: string, z: boolean) => void>;
>T03 : [number, string, boolean]
>T03 : [x: number, y: string, z: boolean]
>x : number
>y : string
>z : boolean
@@ -417,7 +417,7 @@ f20(42, "hello", ...t2, true);
>true : true
type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>;
>T01 : [number, string, ...boolean[]]
>T01 : [x: number, y: string, ...z: boolean[]]
>x : number
>y : string
>z : boolean[]
@@ -427,7 +427,7 @@ type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>;
>args : [number, string, ...boolean[]]
type T03 = ConstructorParameters<new (x: number, y: string, ...z: boolean[]) => void>;
>T03 : [number, string, ...boolean[]]
>T03 : [x: number, y: string, ...z: boolean[]]
>x : number
>y : string
>z : boolean[]
@@ -452,7 +452,7 @@ type P1<T extends Function> = T extends (head: infer A, ...tail: infer B) => any
>tail : B
type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>;
>T10 : { head: number; tail: [string, ...boolean[]]; }
>T10 : { head: number; tail: [y: string, ...z: boolean[]]; }
>x : number
>y : string
>z : boolean[]
@@ -462,7 +462,7 @@ type T11 = P1<(...z: number[]) => void>;
>z : number[]
type T12 = P1<(x: number, y: number) => void>;
>T12 : { head: number; tail: [number]; }
>T12 : { head: number; tail: [y: number]; }
>x : number
>y : number
@@ -6,20 +6,20 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(18,1): error TS2345
tests/cases/conformance/types/rest/genericRestParameters3.ts(22,1): error TS2322: Type '(x: string, ...args: [string] | [number, boolean]) => void' is not assignable to type '(...args: [string, string] | [string, number, boolean]) => void'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(23,1): error TS2322: Type '(x: string, y: string) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
Types of parameters 'y' and 'args' are incompatible.
Type '[string] | [number, boolean]' is not assignable to type '[string]'.
Type '[number, boolean]' is not assignable to type '[string]'.
Type '[string] | [number, boolean]' is not assignable to type '[y: string]'.
Type '[number, boolean]' is not assignable to type '[y: string]'.
Types of property '0' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(24,1): error TS2322: Type '(x: string, y: number, z: boolean) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
Types of parameters 'y' and 'args' are incompatible.
Type '[string] | [number, boolean]' is not assignable to type '[number, boolean]'.
Property '1' is missing in type '[string]' but required in type '[number, boolean]'.
Type '[string] | [number, boolean]' is not assignable to type '[y: number, z: boolean]'.
Property '1' is missing in type '[string]' but required in type '[y: number, z: boolean]'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(25,1): error TS2322: Type '(...args: [string, string] | [string, number, boolean]) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(35,1): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/types/rest/genericRestParameters3.ts(36,21): error TS2345: Argument of type '100' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(37,21): error TS2345: Argument of type '<T extends any[]>(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
Types of parameters 'cb' and 'args' are incompatible.
Property '0' is missing in type 'CoolArray<any>' but required in type '[(...args: any[]) => void]'.
Property '0' is missing in type 'CoolArray<any>' but required in type '[cb: (...args: any[]) => void]'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(44,32): error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray<number>'.
Property 'hello' is missing in type '[10, 20]' but required in type 'CoolArray<number>'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(49,1): error TS2345: Argument of type '[]' is not assignable to parameter of type 'CoolArray<unknown>'.
@@ -70,16 +70,16 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(59,5): error TS2345
~~
!!! error TS2322: Type '(x: string, y: string) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
!!! error TS2322: Types of parameters 'y' and 'args' are incompatible.
!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[string]'.
!!! error TS2322: Type '[number, boolean]' is not assignable to type '[string]'.
!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[y: string]'.
!!! error TS2322: Type '[number, boolean]' is not assignable to type '[y: string]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
f1 = f3; // Error
~~
!!! error TS2322: Type '(x: string, y: number, z: boolean) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
!!! error TS2322: Types of parameters 'y' and 'args' are incompatible.
!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[number, boolean]'.
!!! error TS2322: Property '1' is missing in type '[string]' but required in type '[number, boolean]'.
!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[y: number, z: boolean]'.
!!! error TS2322: Property '1' is missing in type '[string]' but required in type '[y: number, z: boolean]'.
f1 = f4; // Error, misaligned complex rest types
~~
!!! error TS2322: Type '(...args: [string, string] | [string, number, boolean]) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
@@ -103,7 +103,7 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(59,5): error TS2345
~~~
!!! error TS2345: Argument of type '<T extends any[]>(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
!!! error TS2345: Types of parameters 'cb' and 'args' are incompatible.
!!! error TS2345: Property '0' is missing in type 'CoolArray<any>' but required in type '[(...args: any[]) => void]'.
!!! error TS2345: Property '0' is missing in type 'CoolArray<any>' but required in type '[cb: (...args: any[]) => void]'.
function bar<T extends any[]>(...args: T): T {
return args;
@@ -1,7 +1,7 @@
tests/cases/compiler/genericRestTypes.ts(21,11): error TS2322: Type '(cb: (x: string, ...rest: T) => void) => void' is not assignable to type '(cb: (...args: never) => void) => void'.
Types of parameters 'cb' and 'cb' are incompatible.
Types of parameters 'args' and 'x' are incompatible.
Type '[string, ...T[number][]]' is not assignable to type 'never'.
Type '[x: string, ...rest: T[number][]]' is not assignable to type 'never'.
==== tests/cases/compiler/genericRestTypes.ts (1 errors) ====
@@ -30,7 +30,7 @@ tests/cases/compiler/genericRestTypes.ts(21,11): error TS2322: Type '(cb: (x: st
!!! error TS2322: Type '(cb: (x: string, ...rest: T) => void) => void' is not assignable to type '(cb: (...args: never) => void) => void'.
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
!!! error TS2322: Types of parameters 'args' and 'x' are incompatible.
!!! error TS2322: Type '[string, ...T[number][]]' is not assignable to type 'never'.
!!! error TS2322: Type '[x: string, ...rest: T[number][]]' is not assignable to type 'never'.
}
function assignmentWithComplexRest3<T extends any[]>() {
@@ -16,7 +16,7 @@ type MyFunctionType = (foo: number, bar: string) => boolean;
type Explicit = (...args: Tail<Parameters<MyFunctionType>>) => ReturnType<MyFunctionType>; // (bar: string) => boolean
>Explicit : Explicit
>args : [string]
>args : [bar: string]
type Bind1<T extends (head: any, ...tail: any[]) => any> = (...args: Tail<Parameters<T>>) => ReturnType<T>;
>Bind1 : Bind1<T>
@@ -23,7 +23,7 @@ declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock
cases(fn(opts => { }));
>cases(fn(opts => { })) : void
>cases : (tester: Tester) => void
>fn(opts => { }) : Mock<[any]>
>fn(opts => { }) : Mock<[opts: any]>
>fn : <Y extends any[]>(implementation?: ((...args: Y) => any) | undefined) => Mock<Y>
>opts => { } : (opts: any) => void
>opts : any
@@ -444,5 +444,5 @@ assignPartial(obj, { foo(...args) {} }); // args has type [string]
>obj : { foo(bar: string): void; }
>{ foo(...args) {} } : { foo(bar: string): void; }
>foo : (bar: string) => void
>args : [string]
>args : [bar: string]
@@ -0,0 +1,10 @@
tests/cases/conformance/jsdoc/declarations/index.js(4,3): error TS2339: Property 'prototype' does not exist on type '{}'.
==== tests/cases/conformance/jsdoc/declarations/index.js (1 errors) ====
// https://github.com/microsoft/TypeScript/issues/35801
let A;
A = {};
A.prototype.b = {};
~~~~~~~~~
!!! error TS2339: Property 'prototype' does not exist on type '{}'.
@@ -0,0 +1,18 @@
//// [index.js]
// https://github.com/microsoft/TypeScript/issues/35801
let A;
A = {};
A.prototype.b = {};
//// [index.js]
// https://github.com/microsoft/TypeScript/issues/35801
var A;
A = {};
A.prototype.b = {};
//// [index.d.ts]
declare class A {
private constructor();
b: {};
}
@@ -0,0 +1,13 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// https://github.com/microsoft/TypeScript/issues/35801
let A;
>A : Symbol(A, Decl(index.js, 1, 3))
A = {};
>A : Symbol(A, Decl(index.js, 1, 3))
A.prototype.b = {};
>A.prototype : Symbol(A.b, Decl(index.js, 2, 7))
>A : Symbol(A, Decl(index.js, 1, 3))
>b : Symbol(A.b, Decl(index.js, 2, 7))
@@ -0,0 +1,19 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
// https://github.com/microsoft/TypeScript/issues/35801
let A;
>A : any
A = {};
>A = {} : {}
>A : any
>{} : {}
A.prototype.b = {};
>A.prototype.b = {} : {}
>A.prototype.b : any
>A.prototype : any
>A : {}
>prototype : any
>b : any
>{} : {}
@@ -33,7 +33,7 @@ function consumeClass(c: GenericClass<[string, boolean]>) { }
consumeClass(createClass(str => console.log(str.length)));
>consumeClass(createClass(str => console.log(str.length))) : void
>consumeClass : (c: GenericClass<[string, boolean]>) => void
>createClass(str => console.log(str.length)) : GenericClass<[string]>
>createClass(str => console.log(str.length)) : GenericClass<[str: string]>
>createClass : <T extends MyTuple>(f: GenericFunction<T>) => GenericClass<T>
>str => console.log(str.length) : (str: string) => void
>str : string
@@ -49,7 +49,7 @@ consumeClass(createClass(str => console.log(str.length)));
consumeClass(createClass((str, _unused_num) => console.log(str.length)));
>consumeClass(createClass((str, _unused_num) => console.log(str.length))) : void
>consumeClass : (c: GenericClass<[string, boolean]>) => void
>createClass((str, _unused_num) => console.log(str.length)) : GenericClass<[string, boolean]>
>createClass((str, _unused_num) => console.log(str.length)) : GenericClass<[str: string, _unused_num: boolean]>
>createClass : <T extends MyTuple>(f: GenericFunction<T>) => GenericClass<T>
>(str, _unused_num) => console.log(str.length) : (str: string, _unused_num: boolean) => void
>str : string
@@ -0,0 +1,140 @@
//// [namedTupleMembers.ts]
export type Segment = [length: number, count: number];
export type SegmentAnnotated = [
/**
* Size of message buffer segment handles
*/
length: number,
/**
* Number of segments handled at once
*/
count: number
];
declare var a: Segment;
declare var b: SegmentAnnotated;
declare var c: [number, number];
declare var d: [a: number, b: number];
a = b;
a = c;
a = d;
b = a;
b = c;
b = d;
c = a;
c = b;
c = d;
d = a;
d = b;
d = c;
export type WithOptAndRest = [first: number, second?: number, ...rest: string[]];
export type Func<T extends any[]> = (...x: T) => void;
export const func = null as any as Func<SegmentAnnotated>;
export function useState<T>(initial: T): [value: T, setter: (T) => void] {
return null as any;
}
export type Iter = Func<[step: number, iterations: number]>;
export function readSegment([length, count]: [number, number]) {}
// documenting binding pattern behavior (currently does _not_ generate tuple names)
export const val = null as any as Parameters<typeof readSegment>[0];
export type RecursiveTupleA = [initial: string, next: RecursiveTupleA];
export type RecursiveTupleB = [first: string, ptr: RecursiveTupleB];
declare var q: RecursiveTupleA;
declare var r: RecursiveTupleB;
q = r;
r = q;
export type RecusiveRest = [first: string, ...rest: RecusiveRest[]];
export type RecusiveRest2 = [string, ...RecusiveRest2[]];
declare var x: RecusiveRest;
declare var y: RecusiveRest2;
x = y;
y = x;
declare function f<T extends any[]>(...x: T): T;
declare function g(elem: object, index: number): object;
declare function getArgsForInjection<T extends (...args: any[]) => any>(x: T): Parameters<T>;
export const argumentsOfGAsFirstArgument = f(getArgsForInjection(g)); // one tuple with captures arguments as first member
export const argumentsOfG = f(...getArgsForInjection(g)); // captured arguments list re-spread
//// [namedTupleMembers.js]
"use strict";
exports.__esModule = true;
exports.argumentsOfG = exports.argumentsOfGAsFirstArgument = exports.val = exports.readSegment = exports.useState = exports.func = void 0;
a = b;
a = c;
a = d;
b = a;
b = c;
b = d;
c = a;
c = b;
c = d;
d = a;
d = b;
d = c;
exports.func = null;
function useState(initial) {
return null;
}
exports.useState = useState;
function readSegment(_a) {
var length = _a[0], count = _a[1];
}
exports.readSegment = readSegment;
// documenting binding pattern behavior (currently does _not_ generate tuple names)
exports.val = null;
q = r;
r = q;
x = y;
y = x;
exports.argumentsOfGAsFirstArgument = f(getArgsForInjection(g)); // one tuple with captures arguments as first member
exports.argumentsOfG = f.apply(void 0, getArgsForInjection(g)); // captured arguments list re-spread
//// [namedTupleMembers.d.ts]
export declare type Segment = [length: number, count: number];
export declare type SegmentAnnotated = [
/**
* Size of message buffer segment handles
*/
length: number,
/**
* Number of segments handled at once
*/
count: number
];
export declare type WithOptAndRest = [first: number, second?: number, ...rest: string[]];
export declare type Func<T extends any[]> = (...x: T) => void;
export declare const func: Func<SegmentAnnotated>;
export declare function useState<T>(initial: T): [value: T, setter: (T: any) => void];
export declare type Iter = Func<[step: number, iterations: number]>;
export declare function readSegment([length, count]: [number, number]): void;
export declare const val: [number, number];
export declare type RecursiveTupleA = [initial: string, next: RecursiveTupleA];
export declare type RecursiveTupleB = [first: string, ptr: RecursiveTupleB];
export declare type RecusiveRest = [first: string, ...rest: RecusiveRest[]];
export declare type RecusiveRest2 = [string, ...RecusiveRest2[]];
export declare const argumentsOfGAsFirstArgument: [[elem: object, index: number]];
export declare const argumentsOfG: [elem: object, index: number];
@@ -0,0 +1,201 @@
=== tests/cases/conformance/types/tuple/named/namedTupleMembers.ts ===
export type Segment = [length: number, count: number];
>Segment : Symbol(Segment, Decl(namedTupleMembers.ts, 0, 0))
export type SegmentAnnotated = [
>SegmentAnnotated : Symbol(SegmentAnnotated, Decl(namedTupleMembers.ts, 0, 54))
/**
* Size of message buffer segment handles
*/
length: number,
/**
* Number of segments handled at once
*/
count: number
];
declare var a: Segment;
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
>Segment : Symbol(Segment, Decl(namedTupleMembers.ts, 0, 0))
declare var b: SegmentAnnotated;
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
>SegmentAnnotated : Symbol(SegmentAnnotated, Decl(namedTupleMembers.ts, 0, 54))
declare var c: [number, number];
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
declare var d: [a: number, b: number];
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
a = b;
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
a = c;
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
a = d;
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
b = a;
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
b = c;
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
b = d;
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
c = a;
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
c = b;
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
c = d;
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
d = a;
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
>a : Symbol(a, Decl(namedTupleMembers.ts, 13, 11))
d = b;
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
>b : Symbol(b, Decl(namedTupleMembers.ts, 14, 11))
d = c;
>d : Symbol(d, Decl(namedTupleMembers.ts, 16, 11))
>c : Symbol(c, Decl(namedTupleMembers.ts, 15, 11))
export type WithOptAndRest = [first: number, second?: number, ...rest: string[]];
>WithOptAndRest : Symbol(WithOptAndRest, Decl(namedTupleMembers.ts, 32, 6))
export type Func<T extends any[]> = (...x: T) => void;
>Func : Symbol(Func, Decl(namedTupleMembers.ts, 34, 81))
>T : Symbol(T, Decl(namedTupleMembers.ts, 36, 17))
>x : Symbol(x, Decl(namedTupleMembers.ts, 36, 37))
>T : Symbol(T, Decl(namedTupleMembers.ts, 36, 17))
export const func = null as any as Func<SegmentAnnotated>;
>func : Symbol(func, Decl(namedTupleMembers.ts, 38, 12))
>Func : Symbol(Func, Decl(namedTupleMembers.ts, 34, 81))
>SegmentAnnotated : Symbol(SegmentAnnotated, Decl(namedTupleMembers.ts, 0, 54))
export function useState<T>(initial: T): [value: T, setter: (T) => void] {
>useState : Symbol(useState, Decl(namedTupleMembers.ts, 38, 58))
>T : Symbol(T, Decl(namedTupleMembers.ts, 40, 25))
>initial : Symbol(initial, Decl(namedTupleMembers.ts, 40, 28))
>T : Symbol(T, Decl(namedTupleMembers.ts, 40, 25))
>T : Symbol(T, Decl(namedTupleMembers.ts, 40, 25))
>T : Symbol(T, Decl(namedTupleMembers.ts, 40, 61))
return null as any;
}
export type Iter = Func<[step: number, iterations: number]>;
>Iter : Symbol(Iter, Decl(namedTupleMembers.ts, 42, 1))
>Func : Symbol(Func, Decl(namedTupleMembers.ts, 34, 81))
export function readSegment([length, count]: [number, number]) {}
>readSegment : Symbol(readSegment, Decl(namedTupleMembers.ts, 45, 60))
>length : Symbol(length, Decl(namedTupleMembers.ts, 47, 29))
>count : Symbol(count, Decl(namedTupleMembers.ts, 47, 36))
// documenting binding pattern behavior (currently does _not_ generate tuple names)
export const val = null as any as Parameters<typeof readSegment>[0];
>val : Symbol(val, Decl(namedTupleMembers.ts, 50, 12))
>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --))
>readSegment : Symbol(readSegment, Decl(namedTupleMembers.ts, 45, 60))
export type RecursiveTupleA = [initial: string, next: RecursiveTupleA];
>RecursiveTupleA : Symbol(RecursiveTupleA, Decl(namedTupleMembers.ts, 50, 68))
>RecursiveTupleA : Symbol(RecursiveTupleA, Decl(namedTupleMembers.ts, 50, 68))
export type RecursiveTupleB = [first: string, ptr: RecursiveTupleB];
>RecursiveTupleB : Symbol(RecursiveTupleB, Decl(namedTupleMembers.ts, 52, 71))
>RecursiveTupleB : Symbol(RecursiveTupleB, Decl(namedTupleMembers.ts, 52, 71))
declare var q: RecursiveTupleA;
>q : Symbol(q, Decl(namedTupleMembers.ts, 56, 11))
>RecursiveTupleA : Symbol(RecursiveTupleA, Decl(namedTupleMembers.ts, 50, 68))
declare var r: RecursiveTupleB;
>r : Symbol(r, Decl(namedTupleMembers.ts, 57, 11))
>RecursiveTupleB : Symbol(RecursiveTupleB, Decl(namedTupleMembers.ts, 52, 71))
q = r;
>q : Symbol(q, Decl(namedTupleMembers.ts, 56, 11))
>r : Symbol(r, Decl(namedTupleMembers.ts, 57, 11))
r = q;
>r : Symbol(r, Decl(namedTupleMembers.ts, 57, 11))
>q : Symbol(q, Decl(namedTupleMembers.ts, 56, 11))
export type RecusiveRest = [first: string, ...rest: RecusiveRest[]];
>RecusiveRest : Symbol(RecusiveRest, Decl(namedTupleMembers.ts, 60, 6))
>RecusiveRest : Symbol(RecusiveRest, Decl(namedTupleMembers.ts, 60, 6))
export type RecusiveRest2 = [string, ...RecusiveRest2[]];
>RecusiveRest2 : Symbol(RecusiveRest2, Decl(namedTupleMembers.ts, 62, 68))
>RecusiveRest2 : Symbol(RecusiveRest2, Decl(namedTupleMembers.ts, 62, 68))
declare var x: RecusiveRest;
>x : Symbol(x, Decl(namedTupleMembers.ts, 65, 11))
>RecusiveRest : Symbol(RecusiveRest, Decl(namedTupleMembers.ts, 60, 6))
declare var y: RecusiveRest2;
>y : Symbol(y, Decl(namedTupleMembers.ts, 66, 11))
>RecusiveRest2 : Symbol(RecusiveRest2, Decl(namedTupleMembers.ts, 62, 68))
x = y;
>x : Symbol(x, Decl(namedTupleMembers.ts, 65, 11))
>y : Symbol(y, Decl(namedTupleMembers.ts, 66, 11))
y = x;
>y : Symbol(y, Decl(namedTupleMembers.ts, 66, 11))
>x : Symbol(x, Decl(namedTupleMembers.ts, 65, 11))
declare function f<T extends any[]>(...x: T): T;
>f : Symbol(f, Decl(namedTupleMembers.ts, 69, 6))
>T : Symbol(T, Decl(namedTupleMembers.ts, 71, 19))
>x : Symbol(x, Decl(namedTupleMembers.ts, 71, 36))
>T : Symbol(T, Decl(namedTupleMembers.ts, 71, 19))
>T : Symbol(T, Decl(namedTupleMembers.ts, 71, 19))
declare function g(elem: object, index: number): object;
>g : Symbol(g, Decl(namedTupleMembers.ts, 71, 48))
>elem : Symbol(elem, Decl(namedTupleMembers.ts, 72, 19))
>index : Symbol(index, Decl(namedTupleMembers.ts, 72, 32))
declare function getArgsForInjection<T extends (...args: any[]) => any>(x: T): Parameters<T>;
>getArgsForInjection : Symbol(getArgsForInjection, Decl(namedTupleMembers.ts, 72, 56))
>T : Symbol(T, Decl(namedTupleMembers.ts, 73, 37))
>args : Symbol(args, Decl(namedTupleMembers.ts, 73, 48))
>x : Symbol(x, Decl(namedTupleMembers.ts, 73, 72))
>T : Symbol(T, Decl(namedTupleMembers.ts, 73, 37))
>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(namedTupleMembers.ts, 73, 37))
export const argumentsOfGAsFirstArgument = f(getArgsForInjection(g)); // one tuple with captures arguments as first member
>argumentsOfGAsFirstArgument : Symbol(argumentsOfGAsFirstArgument, Decl(namedTupleMembers.ts, 75, 12))
>f : Symbol(f, Decl(namedTupleMembers.ts, 69, 6))
>getArgsForInjection : Symbol(getArgsForInjection, Decl(namedTupleMembers.ts, 72, 56))
>g : Symbol(g, Decl(namedTupleMembers.ts, 71, 48))
export const argumentsOfG = f(...getArgsForInjection(g)); // captured arguments list re-spread
>argumentsOfG : Symbol(argumentsOfG, Decl(namedTupleMembers.ts, 76, 12))
>f : Symbol(f, Decl(namedTupleMembers.ts, 69, 6))
>getArgsForInjection : Symbol(getArgsForInjection, Decl(namedTupleMembers.ts, 72, 56))
>g : Symbol(g, Decl(namedTupleMembers.ts, 71, 48))
@@ -0,0 +1,204 @@
=== tests/cases/conformance/types/tuple/named/namedTupleMembers.ts ===
export type Segment = [length: number, count: number];
>Segment : Segment
export type SegmentAnnotated = [
>SegmentAnnotated : SegmentAnnotated
/**
* Size of message buffer segment handles
*/
length: number,
/**
* Number of segments handled at once
*/
count: number
];
declare var a: Segment;
>a : Segment
declare var b: SegmentAnnotated;
>b : SegmentAnnotated
declare var c: [number, number];
>c : [number, number]
declare var d: [a: number, b: number];
>d : [a: number, b: number]
a = b;
>a = b : SegmentAnnotated
>a : Segment
>b : SegmentAnnotated
a = c;
>a = c : [number, number]
>a : Segment
>c : [number, number]
a = d;
>a = d : [a: number, b: number]
>a : Segment
>d : [a: number, b: number]
b = a;
>b = a : Segment
>b : SegmentAnnotated
>a : Segment
b = c;
>b = c : [number, number]
>b : SegmentAnnotated
>c : [number, number]
b = d;
>b = d : [a: number, b: number]
>b : SegmentAnnotated
>d : [a: number, b: number]
c = a;
>c = a : Segment
>c : [number, number]
>a : Segment
c = b;
>c = b : SegmentAnnotated
>c : [number, number]
>b : SegmentAnnotated
c = d;
>c = d : [a: number, b: number]
>c : [number, number]
>d : [a: number, b: number]
d = a;
>d = a : Segment
>d : [a: number, b: number]
>a : Segment
d = b;
>d = b : SegmentAnnotated
>d : [a: number, b: number]
>b : SegmentAnnotated
d = c;
>d = c : [number, number]
>d : [a: number, b: number]
>c : [number, number]
export type WithOptAndRest = [first: number, second?: number, ...rest: string[]];
>WithOptAndRest : WithOptAndRest
export type Func<T extends any[]> = (...x: T) => void;
>Func : Func<T>
>x : T
export const func = null as any as Func<SegmentAnnotated>;
>func : Func<SegmentAnnotated>
>null as any as Func<SegmentAnnotated> : Func<SegmentAnnotated>
>null as any : any
>null : null
export function useState<T>(initial: T): [value: T, setter: (T) => void] {
>useState : <T>(initial: T) => [value: T, setter: (T: any) => void]
>initial : T
>T : any
return null as any;
>null as any : any
>null : null
}
export type Iter = Func<[step: number, iterations: number]>;
>Iter : Func<[step: number, iterations: number]>
export function readSegment([length, count]: [number, number]) {}
>readSegment : ([length, count]: [number, number]) => void
>length : number
>count : number
// documenting binding pattern behavior (currently does _not_ generate tuple names)
export const val = null as any as Parameters<typeof readSegment>[0];
>val : [number, number]
>null as any as Parameters<typeof readSegment>[0] : [number, number]
>null as any : any
>null : null
>readSegment : ([length, count]: [number, number]) => void
export type RecursiveTupleA = [initial: string, next: RecursiveTupleA];
>RecursiveTupleA : RecursiveTupleA
export type RecursiveTupleB = [first: string, ptr: RecursiveTupleB];
>RecursiveTupleB : RecursiveTupleB
declare var q: RecursiveTupleA;
>q : RecursiveTupleA
declare var r: RecursiveTupleB;
>r : RecursiveTupleB
q = r;
>q = r : RecursiveTupleB
>q : RecursiveTupleA
>r : RecursiveTupleB
r = q;
>r = q : RecursiveTupleA
>r : RecursiveTupleB
>q : RecursiveTupleA
export type RecusiveRest = [first: string, ...rest: RecusiveRest[]];
>RecusiveRest : RecusiveRest
export type RecusiveRest2 = [string, ...RecusiveRest2[]];
>RecusiveRest2 : RecusiveRest2
declare var x: RecusiveRest;
>x : RecusiveRest
declare var y: RecusiveRest2;
>y : RecusiveRest2
x = y;
>x = y : RecusiveRest2
>x : RecusiveRest
>y : RecusiveRest2
y = x;
>y = x : RecusiveRest
>y : RecusiveRest2
>x : RecusiveRest
declare function f<T extends any[]>(...x: T): T;
>f : <T extends any[]>(...x: T) => T
>x : T
declare function g(elem: object, index: number): object;
>g : (elem: object, index: number) => object
>elem : object
>index : number
declare function getArgsForInjection<T extends (...args: any[]) => any>(x: T): Parameters<T>;
>getArgsForInjection : <T extends (...args: any[]) => any>(x: T) => Parameters<T>
>args : any[]
>x : T
export const argumentsOfGAsFirstArgument = f(getArgsForInjection(g)); // one tuple with captures arguments as first member
>argumentsOfGAsFirstArgument : [[elem: object, index: number]]
>f(getArgsForInjection(g)) : [[elem: object, index: number]]
>f : <T extends any[]>(...x: T) => T
>getArgsForInjection(g) : [elem: object, index: number]
>getArgsForInjection : <T extends (...args: any[]) => any>(x: T) => Parameters<T>
>g : (elem: object, index: number) => object
export const argumentsOfG = f(...getArgsForInjection(g)); // captured arguments list re-spread
>argumentsOfG : [elem: object, index: number]
>f(...getArgsForInjection(g)) : [elem: object, index: number]
>f : <T extends any[]>(...x: T) => T
>...getArgsForInjection(g) : number | object
>getArgsForInjection(g) : [elem: object, index: number]
>getArgsForInjection : <T extends (...args: any[]) => any>(x: T) => Parameters<T>
>g : (elem: object, index: number) => object
@@ -0,0 +1,55 @@
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(1,41): error TS5084: Tuple members must all have names or all not have names.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(3,32): error TS5084: Tuple members must all have names or all not have names.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(5,32): error TS5084: Tuple members must all have names or all not have names.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(7,29): error TS5086: A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(9,46): error TS5087: A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(11,49): error TS5087: A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(11,52): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(13,39): error TS5085: A tuple member cannot be both optional and rest.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(15,44): error TS2574: A rest element type must be an array type.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(17,46): error TS2574: A rest element type must be an array type.
tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts(18,44): error TS2574: A rest element type must be an array type.
==== tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts (11 errors) ====
export type Segment1 = [length: number, number]; // partially named, disallowed
~~~~~~
!!! error TS5084: Tuple members must all have names or all not have names.
export type List = [item: any, ...any]; // partially named, disallowed
~~~~~~
!!! error TS5084: Tuple members must all have names or all not have names.
export type Pair = [item: any, any?]; // partially named, disallowed
~~~~
!!! error TS5084: Tuple members must all have names or all not have names.
export type Opt = [element: string?]; // question mark on element disallowed
~~~~~~~
!!! error TS5086: A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.
export type Trailing = [first: string, rest: ...string[]]; // dots on element disallowed
~~~~~~~~~~~
!!! error TS5087: A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.
export type OptTrailing = [first: string, rest: ...string[]?]; // dots+question on element disallowed
~~~~~~~~~~~~
!!! error TS5087: A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.
~~~~~~~~~
!!! error TS8020: JSDoc types can only be used inside documentation comments.
export type OptRest = [first: string, ...rest?: string[]]; // rest+optional disallowed
~~~~~~~~~~~~~~~~~~
!!! error TS5085: A tuple member cannot be both optional and rest.
export type NonArrayRest = [first: string, ...rest: number]; // non-arraylike rest, disallowed
~~~~~~~~~~~~~~~
!!! error TS2574: A rest element type must be an array type.
export type RecusiveRestUnlabeled = [string, ...RecusiveRestUnlabeled];
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2574: A rest element type must be an array type.
export type RecusiveRest = [first: string, ...rest: RecusiveRest]; // marked as incorrect, same as above
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2574: A rest element type must be an array type.
@@ -0,0 +1,37 @@
//// [namedTupleMembersErrors.ts]
export type Segment1 = [length: number, number]; // partially named, disallowed
export type List = [item: any, ...any]; // partially named, disallowed
export type Pair = [item: any, any?]; // partially named, disallowed
export type Opt = [element: string?]; // question mark on element disallowed
export type Trailing = [first: string, rest: ...string[]]; // dots on element disallowed
export type OptTrailing = [first: string, rest: ...string[]?]; // dots+question on element disallowed
export type OptRest = [first: string, ...rest?: string[]]; // rest+optional disallowed
export type NonArrayRest = [first: string, ...rest: number]; // non-arraylike rest, disallowed
export type RecusiveRestUnlabeled = [string, ...RecusiveRestUnlabeled];
export type RecusiveRest = [first: string, ...rest: RecusiveRest]; // marked as incorrect, same as above
//// [namedTupleMembersErrors.js]
"use strict";
exports.__esModule = true;
//// [namedTupleMembersErrors.d.ts]
export declare type Segment1 = [length: number, number];
export declare type List = [item: any, ...any];
export declare type Pair = [item: any, any?];
export declare type Opt = [element: string?];
export declare type Trailing = [first: string, rest: ...string[]];
export declare type OptTrailing = [first: string, rest: ...?string[]];
export declare type OptRest = [first: string, ...rest?: string[]];
export declare type NonArrayRest = [first: string, ...rest: number];
export declare type RecusiveRestUnlabeled = [string, ...RecusiveRestUnlabeled];
export declare type RecusiveRest = [first: string, ...rest: RecusiveRest];
@@ -0,0 +1,33 @@
=== tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts ===
export type Segment1 = [length: number, number]; // partially named, disallowed
>Segment1 : Symbol(Segment1, Decl(namedTupleMembersErrors.ts, 0, 0))
export type List = [item: any, ...any]; // partially named, disallowed
>List : Symbol(List, Decl(namedTupleMembersErrors.ts, 0, 48))
export type Pair = [item: any, any?]; // partially named, disallowed
>Pair : Symbol(Pair, Decl(namedTupleMembersErrors.ts, 2, 39))
export type Opt = [element: string?]; // question mark on element disallowed
>Opt : Symbol(Opt, Decl(namedTupleMembersErrors.ts, 4, 37))
export type Trailing = [first: string, rest: ...string[]]; // dots on element disallowed
>Trailing : Symbol(Trailing, Decl(namedTupleMembersErrors.ts, 6, 37))
export type OptTrailing = [first: string, rest: ...string[]?]; // dots+question on element disallowed
>OptTrailing : Symbol(OptTrailing, Decl(namedTupleMembersErrors.ts, 8, 58))
export type OptRest = [first: string, ...rest?: string[]]; // rest+optional disallowed
>OptRest : Symbol(OptRest, Decl(namedTupleMembersErrors.ts, 10, 62))
export type NonArrayRest = [first: string, ...rest: number]; // non-arraylike rest, disallowed
>NonArrayRest : Symbol(NonArrayRest, Decl(namedTupleMembersErrors.ts, 12, 58))
export type RecusiveRestUnlabeled = [string, ...RecusiveRestUnlabeled];
>RecusiveRestUnlabeled : Symbol(RecusiveRestUnlabeled, Decl(namedTupleMembersErrors.ts, 14, 60))
>RecusiveRestUnlabeled : Symbol(RecusiveRestUnlabeled, Decl(namedTupleMembersErrors.ts, 14, 60))
export type RecusiveRest = [first: string, ...rest: RecusiveRest]; // marked as incorrect, same as above
>RecusiveRest : Symbol(RecusiveRest, Decl(namedTupleMembersErrors.ts, 16, 71))
>RecusiveRest : Symbol(RecusiveRest, Decl(namedTupleMembersErrors.ts, 16, 71))
@@ -0,0 +1,31 @@
=== tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts ===
export type Segment1 = [length: number, number]; // partially named, disallowed
>Segment1 : Segment1
export type List = [item: any, ...any]; // partially named, disallowed
>List : List
export type Pair = [item: any, any?]; // partially named, disallowed
>Pair : Pair
export type Opt = [element: string?]; // question mark on element disallowed
>Opt : Opt
export type Trailing = [first: string, rest: ...string[]]; // dots on element disallowed
>Trailing : Trailing
export type OptTrailing = [first: string, rest: ...string[]?]; // dots+question on element disallowed
>OptTrailing : OptTrailing
export type OptRest = [first: string, ...rest?: string[]]; // rest+optional disallowed
>OptRest : OptRest
export type NonArrayRest = [first: string, ...rest: number]; // non-arraylike rest, disallowed
>NonArrayRest : NonArrayRest
export type RecusiveRestUnlabeled = [string, ...RecusiveRestUnlabeled];
>RecusiveRestUnlabeled : RecusiveRestUnlabeled
export type RecusiveRest = [first: string, ...rest: RecusiveRest]; // marked as incorrect, same as above
>RecusiveRest : RecusiveRest
@@ -0,0 +1,17 @@
// ==ORIGINAL==
// Header
import "lib3";
// Comment2
import "lib2";
// Comment1
import "lib1";
// ==ORGANIZED==
// Header
// Comment1
import "lib1";
// Comment2
import "lib2";
import "lib3";
@@ -8,7 +8,7 @@ function foo(a: number, b: string) {
>true : true
}
type Foops = Parameters<typeof foo>;
>Foops : [number, string]
>Foops : [a: number, b: string]
>foo : (a: number, b: string) => boolean
const x = (a: number) => 5;
@@ -18,17 +18,17 @@ const x = (a: number) => 5;
>5 : 5
type Xps = Parameters<typeof x>;
>Xps : [number]
>Xps : [a: number]
>x : (a: number) => number
const a: Xps = ['should-not-work']; // works, but shouldn't
>a : [number]
>a : [a: number]
>['should-not-work'] : [string]
>'should-not-work' : "should-not-work"
function t(...args: Xps) {} // should work
>t : (a: number) => void
>args : [number]
>args : [a: number]
class C {
>C : C
@@ -44,7 +44,7 @@ type Cps = Parameters<typeof C>; // should not work
>C : typeof C
type Ccps = ConstructorParameters<typeof C>; // should be [number, string]
>Ccps : [number, string]
>Ccps : [a: number, b: string]
>C : typeof C
class D {
@@ -56,6 +56,6 @@ class D {
}
}
type Dcps = ConstructorParameters<typeof D>; // should be [number, ...string[]]
>Dcps : [number, ...string[]]
>Dcps : [a: number, ...rest: string[]]
>D : typeof D
@@ -105,7 +105,7 @@ testRest((t2: D, ...t3) => {})
>testRest : <T extends C>(a: (t: T, t1: T, ...ts: T[]) => void) => T
>(t2: D, ...t3) => {} : (t2: D, t1: D, ...ts: D[]) => void
>t2 : D
>t3 : [D, ...D[]]
>t3 : [t1: D, ...ts: D[]]
testRest((t2, ...t3: D[]) => {})
>testRest((t2, ...t3: D[]) => {}) : C
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'.
Types of parameters 'b' and 'args' are incompatible.
Type 'T' is not assignable to type '[T[0], ...T[number][]]'.
Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'.
Type 'T' is not assignable to type '[b: T[0], ...x: T[number][]]'.
Property '0' is missing in type 'any[]' but required in type '[b: T[0], ...x: T[number][]]'.
==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ====
@@ -64,8 +64,8 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error
~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'.
!!! error TS2345: Types of parameters 'b' and 'args' are incompatible.
!!! error TS2345: Type 'T' is not assignable to type '[T[0], ...T[number][]]'.
!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'.
!!! error TS2345: Type 'T' is not assignable to type '[b: T[0], ...x: T[number][]]'.
!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[b: T[0], ...x: T[number][]]'.
}
declare function f5<T extends any[], U>(f: (...args: T) => U): (...args: T) => U;
@@ -67,20 +67,20 @@ f1((a, b, c) => {})
f1((...x) => {})
>f1((...x) => {}) : void
>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void
>(...x) => {} : (args_0: number, args_1: boolean, args_2: string) => void
>(...x) => {} : (x_0: number, x_1: boolean, x_2: string) => void
>x : [number, boolean, string]
f1((a, ...x) => {})
>f1((a, ...x) => {}) : void
>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void
>(a, ...x) => {} : (a: number, args_1: boolean, args_2: string) => void
>(a, ...x) => {} : (a: number, x_0: boolean, x_1: string) => void
>a : number
>x : [boolean, string]
f1((a, b, ...x) => {})
>f1((a, b, ...x) => {}) : void
>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void
>(a, b, ...x) => {} : (a: number, b: boolean, args_2: string) => void
>(a, b, ...x) => {} : (a: number, b: boolean, x_0: string) => void
>a : number
>b : boolean
>x : [string]
@@ -162,13 +162,13 @@ f2((a, b, c) => {})
f2((...x) => {})
>f2((...x) => {}) : void
>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void
>(...x) => {} : (args_0: number, args_1: boolean, ...args_2: string[]) => void
>(...x) => {} : (x_0: number, x_1: boolean, ...x_2: string[]) => void
>x : [number, boolean, ...string[]]
f2((a, ...x) => {})
>f2((a, ...x) => {}) : void
>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void
>(a, ...x) => {} : (a: number, args_1: boolean, ...args_2: string[]) => void
>(a, ...x) => {} : (a: number, x_0: boolean, ...x_1: string[]) => void
>a : number
>x : [boolean, ...string[]]
@@ -263,13 +263,13 @@ f3((a, b, c) => {})
f3((...x) => {})
>f3((...x) => {}) : void
>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void
>(...x) => {} : (x: number, args_0: boolean, ...args_1: string[]) => void
>(...x) => {} : (x_0: number, x_1: boolean, ...x_2: string[]) => void
>x : [number, boolean, ...string[]]
f3((a, ...x) => {})
>f3((a, ...x) => {}) : void
>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void
>(a, ...x) => {} : (a: number, args_0: boolean, ...args_1: string[]) => void
>(a, ...x) => {} : (a: number, x_0: boolean, ...x_1: string[]) => void
>a : number
>x : [boolean, ...string[]]
@@ -333,7 +333,7 @@ function f4<T extends any[]>(t: T) {
>f((...x) => {}) : void
>f : (cb: (x: number, ...args: T) => void) => void
>(...x) => {} : (x: number, ...args: T[number][]) => void
>x : [number, ...T[number][]]
>x : [x: number, ...args: T[number][]]
f((a, ...x) => {});
>f((a, ...x) => {}) : void
@@ -496,7 +496,7 @@ take(function(...rest){});
>take(function(...rest){}) : void
>take : (cb: (a: number, b: string) => void) => void
>function(...rest){} : (a: number, b: string) => void
>rest : [number, string]
>rest : [a: number, b: string]
// Repro from #29833
@@ -9,10 +9,10 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(11,11): error TS2769:
tests/cases/conformance/functions/strictBindCallApply1.ts(17,15): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(18,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(19,44): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(22,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
Property '1' is missing in type '[number]' but required in type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(22,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(23,37): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(24,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(24,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
Types of property 'length' are incompatible.
Type '3' is not assignable to type '2'.
tests/cases/conformance/functions/strictBindCallApply1.ts(41,11): error TS2769: No overload matches this call.
@@ -35,9 +35,12 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(48,17): error TS2554:
tests/cases/conformance/functions/strictBindCallApply1.ts(49,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(50,38): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(51,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(54,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(54,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(55,31): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(56,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(56,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
Types of property 'length' are incompatible.
Type '3' is not assignable to type '2'.
tests/cases/conformance/functions/strictBindCallApply1.ts(57,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(62,11): error TS2769: No overload matches this call.
Overload 1 of 6, '(this: new (arg0: 10, arg1: string) => C, thisArg: any, arg0: 10, arg1: string): new () => C', gave the following error.
@@ -50,9 +53,12 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(62,11): error TS2769:
tests/cases/conformance/functions/strictBindCallApply1.ts(65,3): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(66,15): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(67,24): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(70,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(70,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(71,17): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
Types of property 'length' are incompatible.
Type '3' is not assignable to type '2'.
==== tests/cases/conformance/functions/strictBindCallApply1.ts (24 errors) ====
@@ -94,14 +100,14 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345:
let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Property '1' is missing in type '[number]' but required in type '[number, string]'.
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
let a02 = foo.apply(undefined, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type '3' is not assignable to type '2'.
@@ -161,13 +167,16 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345:
let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
let a12 = c.foo.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type '3' is not assignable to type '2'.
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
@@ -200,11 +209,14 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345:
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Property '1' is missing in type '[number]' but required in type '[a: number, b: string]'.
C.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
C.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type '3' is not assignable to type '2'.
@@ -7,7 +7,6 @@ tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be follo
tests/cases/compiler/superAccess2.ts(11,40): error TS2336: 'super' cannot be referenced in constructor arguments.
tests/cases/compiler/superAccess2.ts(11,40): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/superAccess2.ts(11,45): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superAccess2.ts(11,59): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/superAccess2.ts(11,64): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superAccess2.ts(15,19): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superAccess2.ts(17,15): error TS2576: Property 'y' is a static member of type 'P'
@@ -15,7 +14,7 @@ tests/cases/compiler/superAccess2.ts(20,26): error TS1034: 'super' must be follo
tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not exist on type 'typeof P'.
==== tests/cases/compiler/superAccess2.ts (15 errors) ====
==== tests/cases/compiler/superAccess2.ts (14 errors) ====
class P {
x() { }
static y() { }
@@ -45,8 +44,6 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
~~~~~
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
super();
@@ -0,0 +1,41 @@
//// [taggedTemplateStringsWithCurriedFunction.ts]
// Originated from #38558
const f = _ => (..._) => "";
f({ ...{ x: 0 } })``;
f({ ...{ x: 0 } })`x`;
f({ ...{ x: 0 } })`x${f}x`;
f({ ...{ x: 0 }, y: (() => 1)() })``;
f({ x: (() => 1)(), ...{ y: 1 } })``;
//// [taggedTemplateStringsWithCurriedFunction.js]
// Originated from #38558
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var f = function (_) { return function () {
var _ = [];
for (var _i = 0; _i < arguments.length; _i++) {
_[_i] = arguments[_i];
}
return "";
}; };
f(__assign({ x: 0 }))(__makeTemplateObject([""], [""]));
f(__assign({ x: 0 }))(__makeTemplateObject(["x"], ["x"]));
f(__assign({ x: 0 }))(__makeTemplateObject(["x", "x"], ["x", "x"]), f);
f(__assign({ x: 0 }, { y: (function () { return 1; })() }))(__makeTemplateObject([""], [""]));
f(__assign({ x: (function () { return 1; })() }, { y: 1 }))(__makeTemplateObject([""], [""]));

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