mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 19:27:35 -06:00
Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38463
This commit is contained in:
commit
528d82afd1
419
CONTRIBUTING.md
419
CONTRIBUTING.md
@ -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).
|
||||
|
||||
@ -50,7 +50,7 @@ namespace ts {
|
||||
// 3. non-exported import declarations
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
if (!(hasModifier(node, ModifierFlags.Export))) {
|
||||
if (!(hasSyntacticModifier(node, ModifierFlags.Export))) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
break;
|
||||
@ -413,7 +413,7 @@ namespace ts {
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol | undefined, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags, isReplaceableByMethod?: boolean): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
const isDefaultExport = hasModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";
|
||||
const isDefaultExport = hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";
|
||||
|
||||
// The exported symbol for an export default function/class node is always named "default"
|
||||
const name = isDefaultExport && parent ? InternalSymbolName.Default : getDeclarationName(node);
|
||||
@ -508,7 +508,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const relatedInformation: DiagnosticRelatedInformation[] = [];
|
||||
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
|
||||
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
|
||||
// export type T; - may have meant export type { T }?
|
||||
relatedInformation.push(createDiagnosticForNode(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`));
|
||||
}
|
||||
@ -572,7 +572,7 @@ namespace ts {
|
||||
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
|
||||
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
|
||||
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
|
||||
if (!container.locals || (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
|
||||
if (!container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
|
||||
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
|
||||
}
|
||||
const exportKind = symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0;
|
||||
@ -637,7 +637,7 @@ namespace ts {
|
||||
const saveExceptionTarget = currentExceptionTarget;
|
||||
const saveActiveLabelList = activeLabelList;
|
||||
const saveHasExplicitReturn = hasExplicitReturn;
|
||||
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) &&
|
||||
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasSyntacticModifier(node, ModifierFlags.Async) &&
|
||||
!(<FunctionLikeDeclaration>node).asteriskToken && !!getImmediatelyInvokedFunctionExpression(node);
|
||||
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
|
||||
// similarly to break statements that exit to a label just past the statement body.
|
||||
@ -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) {
|
||||
@ -1906,7 +1909,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
return hasModifier(node, ModifierFlags.Static)
|
||||
return hasSyntacticModifier(node, ModifierFlags.Static)
|
||||
? declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes)
|
||||
: declareSymbol(container.symbol.members!, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
@ -1936,7 +1939,7 @@ namespace ts {
|
||||
function bindModuleDeclaration(node: ModuleDeclaration) {
|
||||
setExportContextFlag(node);
|
||||
if (isAmbientModule(node)) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
|
||||
}
|
||||
if (isModuleAugmentationExternal(node)) {
|
||||
@ -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:
|
||||
@ -2869,7 +2875,7 @@ namespace ts {
|
||||
// this.foo assignment in a JavaScript class
|
||||
// Bind this property to the containing class
|
||||
const containingClass = thisContainer.parent;
|
||||
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
|
||||
const symbolTable = hasSyntacticModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
|
||||
if (hasDynamicName(node)) {
|
||||
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
|
||||
}
|
||||
@ -2977,15 +2983,13 @@ namespace ts {
|
||||
// util.property = function ...
|
||||
bindExportsPropertyAssignment(node as BindableStaticPropertyAssignmentExpression);
|
||||
}
|
||||
else if (hasDynamicName(node)) {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Property | SymbolFlags.Assignment, InternalSymbolName.Computed);
|
||||
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
|
||||
addLateBoundAssignmentDeclarationToSymbol(node, sym);
|
||||
}
|
||||
else {
|
||||
if (hasDynamicName(node)) {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Property | SymbolFlags.Assignment, InternalSymbolName.Computed);
|
||||
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
|
||||
addLateBoundAssignmentDeclarationToSymbol(node, sym);
|
||||
}
|
||||
else {
|
||||
bindStaticPropertyAssignment(cast(node.left, isBindableStaticAccessExpression));
|
||||
}
|
||||
bindStaticPropertyAssignment(cast(node.left, isBindableStaticNameExpression));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2993,7 +2997,8 @@ namespace ts {
|
||||
* For nodes like `x.y = z`, declare a member 'y' on 'x' if x is a function (or IIFE) or class or {}, or not declared.
|
||||
* Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y;
|
||||
*/
|
||||
function bindStaticPropertyAssignment(node: BindableStaticAccessExpression) {
|
||||
function bindStaticPropertyAssignment(node: BindableStaticNameExpression) {
|
||||
Debug.assert(!isIdentifier(node));
|
||||
node.expression.parent = node;
|
||||
bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
|
||||
}
|
||||
@ -3403,7 +3408,7 @@ namespace ts {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return hasModifier(s, ModifierFlags.Const);
|
||||
return hasSyntacticModifier(s, ModifierFlags.Const);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -3637,7 +3642,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// If a parameter has an accessibility modifier, then it is TypeScript syntax.
|
||||
if (hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsTypeScriptClassSyntax;
|
||||
}
|
||||
|
||||
@ -3676,7 +3681,7 @@ namespace ts {
|
||||
function computeClassDeclaration(node: ClassDeclaration, subtreeFlags: TransformFlags) {
|
||||
let transformFlags: TransformFlags;
|
||||
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
|
||||
// An ambient declaration is TypeScript syntax.
|
||||
transformFlags = TransformFlags.AssertTypeScript;
|
||||
}
|
||||
@ -3767,7 +3772,7 @@ namespace ts {
|
||||
let transformFlags = subtreeFlags;
|
||||
|
||||
// TypeScript-specific modifiers and overloads are TypeScript syntax
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| !node.body) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
@ -3788,7 +3793,7 @@ namespace ts {
|
||||
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
|
||||
// overloads are TypeScript syntax.
|
||||
if (node.decorators
|
||||
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type
|
||||
|| !node.body
|
||||
@ -3802,7 +3807,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// An async method declaration is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
@ -3820,7 +3825,7 @@ namespace ts {
|
||||
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
|
||||
// TypeScript syntax.
|
||||
if (node.decorators
|
||||
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.type
|
||||
|| !node.body) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
@ -3839,7 +3844,7 @@ namespace ts {
|
||||
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
|
||||
|
||||
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
|
||||
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
|
||||
if (some(node.decorators) || hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@ -3854,7 +3859,7 @@ namespace ts {
|
||||
|
||||
function computeFunctionDeclaration(node: FunctionDeclaration, subtreeFlags: TransformFlags) {
|
||||
let transformFlags: TransformFlags;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const modifierFlags = getSyntacticModifierFlags(node);
|
||||
const body = node.body;
|
||||
|
||||
if (!body || (modifierFlags & ModifierFlags.Ambient)) {
|
||||
@ -3902,14 +3907,14 @@ namespace ts {
|
||||
|
||||
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
|
||||
// syntax.
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async function expression is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
@ -3935,14 +3940,14 @@ namespace ts {
|
||||
|
||||
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
|
||||
// syntax.
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async arrow function is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
@ -4016,7 +4021,7 @@ namespace ts {
|
||||
const declarationListTransformFlags = node.declarationList.transformFlags;
|
||||
|
||||
// An ambient declaration is TypeScript syntax.
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
|
||||
transformFlags = TransformFlags.AssertTypeScript;
|
||||
}
|
||||
else {
|
||||
@ -4064,7 +4069,7 @@ namespace ts {
|
||||
|
||||
function computeModuleDeclaration(node: ModuleDeclaration, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = TransformFlags.AssertTypeScript;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const modifierFlags = getSyntacticModifierFlags(node);
|
||||
|
||||
if ((modifierFlags & ModifierFlags.Ambient) === 0) {
|
||||
transformFlags |= subtreeFlags;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -129,12 +129,28 @@ namespace ts {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new array with `element` interspersed in between each element of `input`
|
||||
* if there is more than 1 value in `input`. Otherwise, returns the existing array.
|
||||
*/
|
||||
export function intersperse<T>(input: T[], element: T): T[] {
|
||||
if (input.length <= 1) {
|
||||
return input;
|
||||
}
|
||||
const result: T[] = [];
|
||||
for (let i = 0, n = input.length; i < n; i++) {
|
||||
if (i) result.push(element);
|
||||
result.push(input[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
||||
* 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)) {
|
||||
|
||||
@ -376,7 +376,7 @@ namespace ts {
|
||||
Object.defineProperties(ctor.prototype, {
|
||||
__debugKind: { get(this: Node) { return formatSyntaxKind(this.kind); } },
|
||||
__debugNodeFlags: { get(this: Node) { return formatNodeFlags(this.flags); } },
|
||||
__debugModifierFlags: { get(this: Node) { return formatModifierFlags(getModifierFlagsNoCache(this)); } },
|
||||
__debugModifierFlags: { get(this: Node) { return formatModifierFlags(getEffectiveModifierFlagsNoCache(this)); } },
|
||||
__debugTransformFlags: { get(this: Node) { return formatTransformFlags(this.transformFlags); } },
|
||||
__debugIsParseTreeNode: { get(this: Node) { return isParseTreeNode(this); } },
|
||||
__debugEmitFlags: { get(this: Node) { return formatEmitFlags(getEmitFlags(this)); } },
|
||||
|
||||
@ -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",
|
||||
@ -4911,6 +4927,14 @@
|
||||
"category": "Error",
|
||||
"code": 8032
|
||||
},
|
||||
"A JSDoc '@typedef' comment may not contain multiple '@type' tags.": {
|
||||
"category": "Error",
|
||||
"code": 8033
|
||||
},
|
||||
"The tag was first specified here.": {
|
||||
"category": "Error",
|
||||
"code": 8034
|
||||
},
|
||||
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
@ -5649,7 +5673,7 @@
|
||||
"category": "Message",
|
||||
"code": 95111
|
||||
},
|
||||
"Remove block body braces": {
|
||||
"Remove braces from arrow function body": {
|
||||
"category": "Message",
|
||||
"code": 95112
|
||||
},
|
||||
@ -5661,7 +5685,7 @@
|
||||
"category": "Message",
|
||||
"code": 95114
|
||||
},
|
||||
"Remove all incorrect body block braces": {
|
||||
"Remove braces from all arrow function bodies with relevant issues": {
|
||||
"category": "Message",
|
||||
"code": 95115
|
||||
},
|
||||
@ -5669,7 +5693,15 @@
|
||||
"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",
|
||||
"code": 18004
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -751,7 +751,7 @@ namespace ts {
|
||||
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
||||
*/
|
||||
export function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression {
|
||||
if (ns && hasModifier(node, ModifierFlags.Export)) {
|
||||
if (ns && hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
|
||||
}
|
||||
return getExportName(node, allowComments, allowSourceMaps);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -7483,6 +7512,14 @@ namespace ts {
|
||||
}
|
||||
if (child.kind === SyntaxKind.JSDocTypeTag) {
|
||||
if (childTypeTag) {
|
||||
parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
|
||||
const lastError = lastOrUndefined(parseDiagnostics);
|
||||
if (lastError) {
|
||||
addRelatedInfo(
|
||||
lastError,
|
||||
createDiagnosticForNode(sourceFile, Diagnostics.The_tag_was_first_specified_here)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -2145,7 +2145,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (isModuleDeclaration(node)) {
|
||||
if (isAmbientModule(node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
|
||||
if (isAmbientModule(node) && (inAmbientModule || hasSyntacticModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
|
||||
const nameText = getTextOfIdentifierOrLiteral(node.name);
|
||||
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
||||
// This will happen in two cases:
|
||||
|
||||
@ -487,7 +487,7 @@ namespace ts {
|
||||
| PropertySignature;
|
||||
|
||||
function ensureType(node: HasInferredType, type: TypeNode | undefined, ignorePrivate?: boolean): TypeNode | undefined {
|
||||
if (!ignorePrivate && hasModifier(node, ModifierFlags.Private)) {
|
||||
if (!ignorePrivate && hasEffectiveModifier(node, ModifierFlags.Private)) {
|
||||
// Private nodes emit no types (except private parameter properties, whose parameter types are actually visible)
|
||||
return;
|
||||
}
|
||||
@ -571,7 +571,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function updateParamsList(node: Node, params: NodeArray<ParameterDeclaration>, modifierMask?: ModifierFlags) {
|
||||
if (hasModifier(node, ModifierFlags.Private)) {
|
||||
if (hasEffectiveModifier(node, ModifierFlags.Private)) {
|
||||
return undefined!; // TODO: GH#18217
|
||||
}
|
||||
const newParams = map(params, p => ensureParameter(p, modifierMask));
|
||||
@ -612,7 +612,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function ensureTypeParams(node: Node, params: NodeArray<TypeParameterDeclaration> | undefined) {
|
||||
return hasModifier(node, ModifierFlags.Private) ? undefined : visitNodes(params, visitDeclarationSubtree);
|
||||
return hasEffectiveModifier(node, ModifierFlags.Private) ? undefined : visitNodes(params, visitDeclarationSubtree);
|
||||
}
|
||||
|
||||
function isEnclosingDeclaration(node: Node) {
|
||||
@ -825,7 +825,7 @@ namespace ts {
|
||||
|
||||
// Emit methods which are private as properties with no type information
|
||||
if (isMethodDeclaration(input) || isMethodSignature(input)) {
|
||||
if (hasModifier(input, ModifierFlags.Private)) {
|
||||
if (hasEffectiveModifier(input, ModifierFlags.Private)) {
|
||||
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload
|
||||
return cleanup(createProperty(/*decorators*/undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
}
|
||||
@ -901,7 +901,7 @@ namespace ts {
|
||||
/*decorators*/ undefined,
|
||||
ensureModifiers(input),
|
||||
input.name,
|
||||
updateAccessorParamsList(input, hasModifier(input, ModifierFlags.Private)),
|
||||
updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)),
|
||||
ensureType(input, accessorType),
|
||||
/*body*/ undefined));
|
||||
}
|
||||
@ -914,7 +914,7 @@ namespace ts {
|
||||
/*decorators*/ undefined,
|
||||
ensureModifiers(input),
|
||||
input.name,
|
||||
updateAccessorParamsList(input, hasModifier(input, ModifierFlags.Private)),
|
||||
updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)),
|
||||
/*body*/ undefined));
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
@ -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 {
|
||||
@ -1041,7 +1045,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isPrivateMethodTypeParameter(node: TypeParameterDeclaration) {
|
||||
return node.parent.kind === SyntaxKind.MethodDeclaration && hasModifier(node.parent, ModifierFlags.Private);
|
||||
return node.parent.kind === SyntaxKind.MethodDeclaration && hasEffectiveModifier(node.parent, ModifierFlags.Private);
|
||||
}
|
||||
|
||||
function visitDeclarationStatements(input: Node): VisitResult<Node> {
|
||||
@ -1096,13 +1100,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function stripExportModifiers(statement: Statement): Statement {
|
||||
if (isImportEqualsDeclaration(statement) || hasModifier(statement, ModifierFlags.Default)) {
|
||||
if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, ModifierFlags.Default)) {
|
||||
// `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace
|
||||
// Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too
|
||||
return statement;
|
||||
}
|
||||
const clone = getMutableClone(statement);
|
||||
const modifiers = createModifiersFromModifierFlags(getModifierFlags(statement) & (ModifierFlags.All ^ ModifierFlags.Export));
|
||||
const modifiers = createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (ModifierFlags.All ^ ModifierFlags.Export));
|
||||
clone.modifiers = modifiers.length ? createNodeArray(modifiers) : undefined;
|
||||
return clone;
|
||||
}
|
||||
@ -1188,11 +1192,11 @@ namespace ts {
|
||||
});
|
||||
const namespaceDecl = createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name!, createModuleBlock(declarations), NodeFlags.Namespace);
|
||||
|
||||
if (!hasModifier(clean, ModifierFlags.Default)) {
|
||||
if (!hasEffectiveModifier(clean, ModifierFlags.Default)) {
|
||||
return [clean, namespaceDecl];
|
||||
}
|
||||
|
||||
const modifiers = createModifiersFromModifierFlags((getModifierFlags(clean) & ~ModifierFlags.ExportDefault) | ModifierFlags.Ambient);
|
||||
const modifiers = createModifiersFromModifierFlags((getEffectiveModifierFlags(clean) & ~ModifierFlags.ExportDefault) | ModifierFlags.Ambient);
|
||||
const cleanDeclaration = updateFunctionDeclaration(
|
||||
clean,
|
||||
/*decorators*/ undefined,
|
||||
@ -1295,7 +1299,7 @@ namespace ts {
|
||||
if (ctor) {
|
||||
const oldDiag = getSymbolAccessibilityDiagnostic;
|
||||
parameterProperties = compact(flatMap(ctor.parameters, (param) => {
|
||||
if (!hasModifier(param, ModifierFlags.ParameterPropertyModifier) || shouldStripInternal(param)) return;
|
||||
if (!hasSyntacticModifier(param, ModifierFlags.ParameterPropertyModifier) || shouldStripInternal(param)) return;
|
||||
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param);
|
||||
if (param.name.kind === SyntaxKind.Identifier) {
|
||||
return preserveJsDoc(createProperty(
|
||||
@ -1482,7 +1486,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function ensureModifiers(node: Node): readonly Modifier[] | undefined {
|
||||
const currentFlags = getModifierFlags(node);
|
||||
const currentFlags = getEffectiveModifierFlags(node);
|
||||
const newFlags = ensureModifierFlags(node);
|
||||
if (currentFlags === newFlags) {
|
||||
return node.modifiers;
|
||||
@ -1536,7 +1540,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function maskModifierFlags(node: Node, modifierMask: ModifierFlags = ModifierFlags.All ^ ModifierFlags.Public, modifierAdditions: ModifierFlags = ModifierFlags.None): ModifierFlags {
|
||||
let flags = (getModifierFlags(node) & modifierMask) | modifierAdditions;
|
||||
let flags = (getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions;
|
||||
if (flags & ModifierFlags.Default && !(flags & ModifierFlags.Export)) {
|
||||
// A non-exported default is a nonsequitor - we usually try to remove all export modifiers
|
||||
// from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid
|
||||
@ -1563,7 +1567,7 @@ namespace ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return !hasModifier(node, ModifierFlags.Private);
|
||||
return !hasEffectiveModifier(node, ModifierFlags.Private);
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return true;
|
||||
|
||||
@ -71,7 +71,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@ -102,7 +102,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@ -135,7 +135,7 @@ namespace ts {
|
||||
return getReturnTypeVisibilityError;
|
||||
}
|
||||
else if (isParameter(node)) {
|
||||
if (isParameterPropertyDeclaration(node, node.parent) && hasModifier(node.parent, ModifierFlags.Private)) {
|
||||
if (isParameterPropertyDeclaration(node, node.parent) && hasSyntacticModifier(node.parent, ModifierFlags.Private)) {
|
||||
return getVariableDeclarationTypeVisibilityError;
|
||||
}
|
||||
return getParameterDeclarationTypeVisibilityError;
|
||||
@ -167,9 +167,9 @@ namespace ts {
|
||||
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
|
||||
// The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all.
|
||||
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) {
|
||||
(node.kind === SyntaxKind.Parameter && hasSyntacticModifier(node.parent, ModifierFlags.Private))) {
|
||||
// TODO(jfreeman): Deal with computed properties in error reporting.
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@ -206,7 +206,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.SetAccessor) {
|
||||
// Getters can infer the return type from the returned expression, but setters cannot, so the
|
||||
// "_from_external_module_1_but_cannot_be_named" case cannot occur.
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
|
||||
@ -218,7 +218,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@ -266,7 +266,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
|
||||
@ -345,7 +345,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node.parent, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@ -413,7 +413,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(node.parent, ModifierFlags.Static)) {
|
||||
diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
|
||||
}
|
||||
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
|
||||
@ -681,8 +681,8 @@ namespace ts {
|
||||
statements.push(statement);
|
||||
|
||||
// Add an `export default` statement for default exports (for `--target es5 --module es6`)
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
const exportStatement = hasModifier(node, ModifierFlags.Default)
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
const exportStatement = hasSyntacticModifier(node, ModifierFlags.Default)
|
||||
? createExportDefault(getLocalName(node))
|
||||
: createExternalModuleExport(getLocalName(node));
|
||||
|
||||
@ -1804,7 +1804,7 @@ namespace ts {
|
||||
function transformFunctionLikeToExpression(node: FunctionLikeDeclaration, location: TextRange | undefined, name: Identifier | undefined, container: Node | undefined): FunctionExpression {
|
||||
const savedConvertedLoopState = convertedLoopState;
|
||||
convertedLoopState = undefined;
|
||||
const ancestorFacts = container && isClassLike(container) && !hasModifier(node, ModifierFlags.Static)
|
||||
const ancestorFacts = container && isClassLike(container) && !hasSyntacticModifier(node, ModifierFlags.Static)
|
||||
? enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes | HierarchyFacts.NonStaticClassElement)
|
||||
: enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes);
|
||||
const parameters = visitParameterList(node.parameters, visitor, context);
|
||||
@ -2011,7 +2011,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitVariableStatement(node: VariableStatement): Statement | undefined {
|
||||
const ancestorFacts = enterSubtree(HierarchyFacts.None, hasModifier(node, ModifierFlags.Export) ? HierarchyFacts.ExportedVariableStatement : HierarchyFacts.None);
|
||||
const ancestorFacts = enterSubtree(HierarchyFacts.None, hasSyntacticModifier(node, ModifierFlags.Export) ? HierarchyFacts.ExportedVariableStatement : HierarchyFacts.None);
|
||||
let updated: Statement | undefined;
|
||||
if (convertedLoopState && (node.declarationList.flags & NodeFlags.BlockScoped) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
|
||||
// we are inside a converted loop - hoist variable declarations
|
||||
@ -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;
|
||||
}
|
||||
@ -4257,7 +4257,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
return hasModifier(member, ModifierFlags.Static)
|
||||
return hasSyntacticModifier(member, ModifierFlags.Static)
|
||||
? getInternalName(node)
|
||||
: createPropertyAccess(getInternalName(node), "prototype");
|
||||
}
|
||||
|
||||
@ -486,7 +486,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitVariableStatement(node: VariableStatement): VisitResult<VariableStatement> {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
const savedExportedVariableStatement = exportedVariableStatement;
|
||||
exportedVariableStatement = true;
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
|
||||
@ -895,7 +895,7 @@ namespace ts {
|
||||
|
||||
let statements: Statement[] | undefined;
|
||||
if (moduleKind !== ModuleKind.AMD) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
statements = append(statements,
|
||||
setOriginalNode(
|
||||
setTextRange(
|
||||
@ -934,7 +934,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
statements = append(statements,
|
||||
setOriginalNode(
|
||||
setTextRange(
|
||||
@ -1095,7 +1095,7 @@ namespace ts {
|
||||
*/
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult<Statement> {
|
||||
let statements: Statement[] | undefined;
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
statements = append(statements,
|
||||
setOriginalNode(
|
||||
setTextRange(
|
||||
@ -1138,7 +1138,7 @@ namespace ts {
|
||||
*/
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
let statements: Statement[] | undefined;
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
statements = append(statements,
|
||||
setOriginalNode(
|
||||
setTextRange(
|
||||
@ -1182,7 +1182,7 @@ namespace ts {
|
||||
let variables: VariableDeclaration[] | undefined;
|
||||
let expressions: Expression[] | undefined;
|
||||
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
let modifiers: NodeArray<Modifier> | undefined;
|
||||
|
||||
// If we're exporting these variables, then these just become assignments to 'exports.x'.
|
||||
@ -1442,8 +1442,8 @@ namespace ts {
|
||||
return statements;
|
||||
}
|
||||
|
||||
if (hasModifier(decl, ModifierFlags.Export)) {
|
||||
const exportName = hasModifier(decl, ModifierFlags.Default) ? createIdentifier("default") : getDeclarationName(decl);
|
||||
if (hasSyntacticModifier(decl, ModifierFlags.Export)) {
|
||||
const exportName = hasSyntacticModifier(decl, ModifierFlags.Default) ? createIdentifier("default") : getDeclarationName(decl);
|
||||
statements = appendExportStatement(statements, exportName, getLocalName(decl), /*location*/ decl);
|
||||
}
|
||||
|
||||
@ -1887,7 +1887,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
text: `
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
}`
|
||||
};`
|
||||
};
|
||||
|
||||
function createExportStarHelper(context: TransformationContext, module: Expression) {
|
||||
|
||||
@ -693,7 +693,7 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult<Statement> {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
hoistedStatements = append(hoistedStatements,
|
||||
updateFunctionDeclaration(
|
||||
node,
|
||||
@ -780,7 +780,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let expressions: Expression[] | undefined;
|
||||
const isExportedDeclaration = hasModifier(node, ModifierFlags.Export);
|
||||
const isExportedDeclaration = hasSyntacticModifier(node, ModifierFlags.Export);
|
||||
const isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
|
||||
for (const variable of node.declarationList.declarations) {
|
||||
if (variable.initializer) {
|
||||
@ -911,7 +911,7 @@ namespace ts {
|
||||
// statement until we visit this declaration's `EndOfDeclarationMarker`.
|
||||
if (hasAssociatedEndOfDeclarationMarker(node) && node.original!.kind === SyntaxKind.VariableStatement) {
|
||||
const id = getOriginalNodeId(node);
|
||||
const isExportedDeclaration = hasModifier(node.original!, ModifierFlags.Export);
|
||||
const isExportedDeclaration = hasSyntacticModifier(node.original!, ModifierFlags.Export);
|
||||
deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], <VariableStatement>node.original, isExportedDeclaration);
|
||||
}
|
||||
|
||||
@ -1087,8 +1087,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
let excludeName: string | undefined;
|
||||
if (hasModifier(decl, ModifierFlags.Export)) {
|
||||
const exportName = hasModifier(decl, ModifierFlags.Default) ? createLiteral("default") : decl.name!;
|
||||
if (hasSyntacticModifier(decl, ModifierFlags.Export)) {
|
||||
const exportName = hasSyntacticModifier(decl, ModifierFlags.Default) ? createLiteral("default") : decl.name!;
|
||||
statements = appendExportStatement(statements, exportName, getLocalName(decl));
|
||||
excludeName = getTextOfIdentifierOrLiteral(exportName);
|
||||
}
|
||||
|
||||
@ -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));
|
||||
@ -63,7 +65,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createTemplateCooked(template: TemplateHead | TemplateMiddle | TemplateTail | NoSubstitutionTemplateLiteral) {
|
||||
return template.templateFlags ? createIdentifier("undefined") : createLiteral(template.text);
|
||||
return template.templateFlags ? createVoidZero() : createLiteral(template.text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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
|
||||
|
||||
@ -166,7 +166,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
if (hasModifier(node, ModifierFlags.Ambient)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ namespace ts {
|
||||
// These nodes should always have names unless they are default-exports;
|
||||
// however, class declaration parsing allows for undefined names, so syntactically invalid
|
||||
// programs may also have an undefined name.
|
||||
Debug.assert(node.kind === SyntaxKind.ClassDeclaration || hasModifier(node, ModifierFlags.Default));
|
||||
Debug.assert(node.kind === SyntaxKind.ClassDeclaration || hasSyntacticModifier(node, ModifierFlags.Default));
|
||||
}
|
||||
if (isClassDeclaration(node)) {
|
||||
// XXX: should probably also cover interfaces and type aliases that can have type variables?
|
||||
@ -287,7 +287,7 @@ namespace ts {
|
||||
// do not emit ES6 imports and exports since they are illegal inside a namespace
|
||||
return undefined;
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsTypeScript || hasModifier(node, ModifierFlags.Export)) {
|
||||
else if (node.transformFlags & TransformFlags.ContainsTypeScript || hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
return visitTypeScript(node);
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitTypeScript(node: Node): VisitResult<Node> {
|
||||
if (isStatement(node) && hasModifier(node, ModifierFlags.Ambient)) {
|
||||
if (isStatement(node) && hasSyntacticModifier(node, ModifierFlags.Ambient)) {
|
||||
// TypeScript ambient declarations are elided, but some comments may be preserved.
|
||||
// See the implementation of `getLeadingComments` in comments.ts for more details.
|
||||
return createNotEmittedStatement(node);
|
||||
@ -610,7 +610,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && hasModifier(node, ModifierFlags.Export))) {
|
||||
if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && hasSyntacticModifier(node, ModifierFlags.Export))) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
@ -966,7 +966,7 @@ namespace ts {
|
||||
*/
|
||||
function isDecoratedClassElement(member: ClassElement, isStatic: boolean, parent: ClassLikeDeclaration) {
|
||||
return nodeOrChildIsDecorated(member, parent)
|
||||
&& isStatic === hasModifier(member, ModifierFlags.Static);
|
||||
&& isStatic === hasSyntacticModifier(member, ModifierFlags.Static);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2045,7 +2045,7 @@ namespace ts {
|
||||
* @param node The declaration node.
|
||||
*/
|
||||
function shouldEmitAccessorDeclaration(node: AccessorDeclaration) {
|
||||
return !(nodeIsMissing(node.body) && hasModifier(node, ModifierFlags.Abstract));
|
||||
return !(nodeIsMissing(node.body) && hasSyntacticModifier(node, ModifierFlags.Abstract));
|
||||
}
|
||||
|
||||
function visitGetAccessor(node: GetAccessorDeclaration) {
|
||||
@ -2352,7 +2352,7 @@ namespace ts {
|
||||
const containerName = getNamespaceContainerName(node);
|
||||
|
||||
// `exportName` is the expression used within this node's container for any exported references.
|
||||
const exportName = hasModifier(node, ModifierFlags.Export)
|
||||
const exportName = hasSyntacticModifier(node, ModifierFlags.Export)
|
||||
? getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true)
|
||||
: getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
|
||||
@ -2653,7 +2653,7 @@ namespace ts {
|
||||
const containerName = getNamespaceContainerName(node);
|
||||
|
||||
// `exportName` is the expression used within this node's container for any exported references.
|
||||
const exportName = hasModifier(node, ModifierFlags.Export)
|
||||
const exportName = hasSyntacticModifier(node, ModifierFlags.Export)
|
||||
? getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true)
|
||||
: getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
|
||||
@ -3039,7 +3039,7 @@ namespace ts {
|
||||
* @param node The node to test.
|
||||
*/
|
||||
function isExportOfNamespace(node: Node) {
|
||||
return currentNamespace !== undefined && hasModifier(node, ModifierFlags.Export);
|
||||
return currentNamespace !== undefined && hasSyntacticModifier(node, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3048,7 +3048,7 @@ namespace ts {
|
||||
* @param node The node to test.
|
||||
*/
|
||||
function isExternalModuleExport(node: Node) {
|
||||
return currentNamespace === undefined && hasModifier(node, ModifierFlags.Export);
|
||||
return currentNamespace === undefined && hasSyntacticModifier(node, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3058,7 +3058,7 @@ namespace ts {
|
||||
*/
|
||||
function isNamedExternalModuleExport(node: Node) {
|
||||
return isExternalModuleExport(node)
|
||||
&& !hasModifier(node, ModifierFlags.Default);
|
||||
&& !hasSyntacticModifier(node, ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3068,7 +3068,7 @@ namespace ts {
|
||||
*/
|
||||
function isDefaultExternalModuleExport(node: Node) {
|
||||
return isExternalModuleExport(node)
|
||||
&& hasModifier(node, ModifierFlags.Default);
|
||||
&& hasSyntacticModifier(node, ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3147,7 +3147,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
return hasModifier(member, ModifierFlags.Static)
|
||||
return hasSyntacticModifier(member, ModifierFlags.Static)
|
||||
? getDeclarationName(node)
|
||||
: getClassPrototype(node);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.VariableStatement:
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
for (const decl of (<VariableStatement>node).declarationList.declarations) {
|
||||
exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
|
||||
}
|
||||
@ -151,8 +151,8 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Default)) {
|
||||
// export default function() { }
|
||||
if (!hasExportDefault) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(<FunctionDeclaration>node));
|
||||
@ -172,8 +172,8 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
if (hasModifier(node, ModifierFlags.Default)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Default)) {
|
||||
// export default class { }
|
||||
if (!hasExportDefault) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(<ClassDeclaration>node));
|
||||
|
||||
@ -328,6 +328,7 @@ namespace ts {
|
||||
IndexedAccessType,
|
||||
MappedType,
|
||||
LiteralType,
|
||||
NamedTupleMember,
|
||||
ImportType,
|
||||
// Binding patterns
|
||||
ObjectBindingPattern,
|
||||
@ -609,6 +610,7 @@ namespace ts {
|
||||
Async = 1 << 8, // Property/Method/Function
|
||||
Default = 1 << 9, // Function/Class (export default declaration)
|
||||
Const = 1 << 11, // Const enum
|
||||
HasComputedJSDocModifiers = 1 << 12, // Indicates the computed modifier flags include modifiers from JSDoc.
|
||||
HasComputedFlags = 1 << 29, // Modifier flags have been computed
|
||||
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
@ -699,6 +701,7 @@ namespace ts {
|
||||
| ConstructorTypeNode
|
||||
| JSDocFunctionType
|
||||
| ExportDeclaration
|
||||
| NamedTupleMember
|
||||
| EndOfFileToken;
|
||||
|
||||
export type HasType =
|
||||
@ -1273,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 {
|
||||
@ -1477,6 +1488,7 @@ namespace ts {
|
||||
kind: SyntaxKind.SyntheticExpression;
|
||||
isSpread: boolean;
|
||||
type: Type;
|
||||
tupleNameSource?: ParameterDeclaration | NamedTupleMember;
|
||||
}
|
||||
|
||||
// see: https://tc39.github.io/ecma262/#prod-ExponentiationExpression
|
||||
@ -2589,6 +2601,7 @@ namespace ts {
|
||||
text: string;
|
||||
pos: -1;
|
||||
end: -1;
|
||||
hasLeadingNewline?: boolean;
|
||||
}
|
||||
|
||||
// represents a top level: { type } expression in a JSDoc comment.
|
||||
@ -2790,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).
|
||||
@ -3507,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;
|
||||
@ -4160,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 */
|
||||
@ -4315,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
|
||||
@ -4632,7 +4631,7 @@ namespace ts {
|
||||
minLength: number;
|
||||
hasRestElement: boolean;
|
||||
readonly: boolean;
|
||||
associatedNames?: __String[];
|
||||
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
|
||||
}
|
||||
|
||||
export interface TupleTypeReference extends TypeReference {
|
||||
@ -6573,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,
|
||||
|
||||
@ -1370,8 +1370,8 @@ namespace ts {
|
||||
|
||||
export function isValidESSymbolDeclaration(node: Node): node is VariableDeclaration | PropertyDeclaration | SignatureDeclaration {
|
||||
return isVariableDeclaration(node) ? isVarConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
||||
isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
|
||||
isPropertySignature(node) && hasReadonlyModifier(node);
|
||||
isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
|
||||
isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
|
||||
}
|
||||
|
||||
export function introducesArgumentsExoticObject(node: Node) {
|
||||
@ -2471,7 +2471,7 @@ namespace ts {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[] {
|
||||
export function getJSDocCommentsAndTags(hostNode: Node, noCache?: boolean): readonly (JSDoc | JSDocTag)[] {
|
||||
let result: (JSDoc | JSDocTag)[] | undefined;
|
||||
// Pull parameter comments from declaring function as well
|
||||
if (isVariableLike(hostNode) && hasInitializer(hostNode) && hasJSDocNodes(hostNode.initializer!)) {
|
||||
@ -2485,11 +2485,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration));
|
||||
result = addRange(result, (noCache ? getJSDocParameterTagsNoCache : getJSDocParameterTags)(node as ParameterDeclaration));
|
||||
break;
|
||||
}
|
||||
if (node.kind === SyntaxKind.TypeParameter) {
|
||||
result = addRange(result, getJSDocTypeParameterTags(node as TypeParameterDeclaration));
|
||||
result = addRange(result, (noCache ? getJSDocTypeParameterTagsNoCache : getJSDocTypeParameterTags)(node as TypeParameterDeclaration));
|
||||
break;
|
||||
}
|
||||
node = getNextJSDocCommentLocation(node);
|
||||
@ -3007,7 +3007,7 @@ namespace ts {
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
|
||||
flags |= FunctionFlags.Async;
|
||||
}
|
||||
break;
|
||||
@ -3028,7 +3028,7 @@ namespace ts {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return (<FunctionLikeDeclaration>node).body !== undefined
|
||||
&& (<FunctionLikeDeclaration>node).asteriskToken === undefined
|
||||
&& hasModifier(node, ModifierFlags.Async);
|
||||
&& hasSyntacticModifier(node, ModifierFlags.Async);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -4017,7 +4017,7 @@ namespace ts {
|
||||
else {
|
||||
forEach(declarations, member => {
|
||||
if (isAccessor(member)
|
||||
&& hasModifier(member, ModifierFlags.Static) === hasModifier(accessor, ModifierFlags.Static)) {
|
||||
&& hasSyntacticModifier(member, ModifierFlags.Static) === hasSyntacticModifier(accessor, ModifierFlags.Static)) {
|
||||
const memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
@ -4312,61 +4312,112 @@ namespace ts {
|
||||
return currentLineIndent;
|
||||
}
|
||||
|
||||
export function hasModifiers(node: Node) {
|
||||
return getModifierFlags(node) !== ModifierFlags.None;
|
||||
export function hasEffectiveModifiers(node: Node) {
|
||||
return getEffectiveModifierFlags(node) !== ModifierFlags.None;
|
||||
}
|
||||
|
||||
export function hasModifier(node: Node, flags: ModifierFlags): boolean {
|
||||
return !!getSelectedModifierFlags(node, flags);
|
||||
export function hasSyntacticModifiers(node: Node) {
|
||||
return getSyntacticModifierFlags(node) !== ModifierFlags.None;
|
||||
}
|
||||
|
||||
export function hasEffectiveModifier(node: Node, flags: ModifierFlags): boolean {
|
||||
return !!getSelectedEffectiveModifierFlags(node, flags);
|
||||
}
|
||||
|
||||
export function hasSyntacticModifier(node: Node, flags: ModifierFlags): boolean {
|
||||
return !!getSelectedSyntacticModifierFlags(node, flags);
|
||||
}
|
||||
|
||||
export function hasStaticModifier(node: Node): boolean {
|
||||
return hasModifier(node, ModifierFlags.Static);
|
||||
return hasSyntacticModifier(node, ModifierFlags.Static);
|
||||
}
|
||||
|
||||
export function hasReadonlyModifier(node: Node): boolean {
|
||||
return hasModifier(node, ModifierFlags.Readonly);
|
||||
export function hasEffectiveReadonlyModifier(node: Node): boolean {
|
||||
return hasEffectiveModifier(node, ModifierFlags.Readonly);
|
||||
}
|
||||
|
||||
export function getSelectedModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags {
|
||||
return getModifierFlags(node) & flags;
|
||||
export function getSelectedEffectiveModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags {
|
||||
return getEffectiveModifierFlags(node) & flags;
|
||||
}
|
||||
|
||||
export function getModifierFlags(node: Node): ModifierFlags {
|
||||
export function getSelectedSyntacticModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags {
|
||||
return getSyntacticModifierFlags(node) & flags;
|
||||
}
|
||||
|
||||
function getModifierFlagsWorker(node: Node, includeJSDoc: boolean): ModifierFlags {
|
||||
if (node.kind >= SyntaxKind.FirstToken && node.kind <= SyntaxKind.LastToken) {
|
||||
return ModifierFlags.None;
|
||||
}
|
||||
if (node.modifierFlagsCache & ModifierFlags.HasComputedFlags) {
|
||||
return node.modifierFlagsCache & ~ModifierFlags.HasComputedFlags;
|
||||
|
||||
if (!(node.modifierFlagsCache & ModifierFlags.HasComputedFlags)) {
|
||||
node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | ModifierFlags.HasComputedFlags;
|
||||
}
|
||||
|
||||
const flags = getModifierFlagsNoCache(node);
|
||||
node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags;
|
||||
if (includeJSDoc && !(node.modifierFlagsCache & ModifierFlags.HasComputedJSDocModifiers) && isInJSFile(node) && node.parent) {
|
||||
node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | ModifierFlags.HasComputedJSDocModifiers;
|
||||
}
|
||||
|
||||
return node.modifierFlagsCache & ~(ModifierFlags.HasComputedFlags | ModifierFlags.HasComputedJSDocModifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance.
|
||||
*
|
||||
* NOTE: This function may use `parent` pointers.
|
||||
*/
|
||||
export function getEffectiveModifierFlags(node: Node): ModifierFlags {
|
||||
return getModifierFlagsWorker(node, /*includeJSDoc*/ true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ModifierFlags for syntactic modifiers on the provided node. The modifiers will be cached on the node to improve performance.
|
||||
*
|
||||
* NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc.
|
||||
*/
|
||||
export function getSyntacticModifierFlags(node: Node): ModifierFlags {
|
||||
return getModifierFlagsWorker(node, /*includeJSDoc*/ false);
|
||||
}
|
||||
|
||||
function getJSDocModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
let flags = ModifierFlags.None;
|
||||
if (isInJSFile(node) && !!node.parent && !isParameter(node)) {
|
||||
if (getJSDocPublicTagNoCache(node)) flags |= ModifierFlags.Public;
|
||||
if (getJSDocPrivateTagNoCache(node)) flags |= ModifierFlags.Private;
|
||||
if (getJSDocProtectedTagNoCache(node)) flags |= ModifierFlags.Protected;
|
||||
if (getJSDocReadonlyTagNoCache(node)) flags |= ModifierFlags.Readonly;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
export function getModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
let flags = ModifierFlags.None;
|
||||
if (node.modifiers) {
|
||||
for (const modifier of node.modifiers) {
|
||||
flags |= modifierToFlag(modifier.kind);
|
||||
}
|
||||
}
|
||||
|
||||
if (isInJSFile(node) && !!node.parent) {
|
||||
// getModifierFlagsNoCache should only be called when parent pointers are set,
|
||||
// or when !(node.flags & NodeFlags.Synthesized) && node.kind !== SyntaxKind.SourceFile)
|
||||
const tags = (getJSDocPublicTag(node) ? ModifierFlags.Public : ModifierFlags.None)
|
||||
| (getJSDocPrivateTag(node) ? ModifierFlags.Private : ModifierFlags.None)
|
||||
| (getJSDocProtectedTag(node) ? ModifierFlags.Protected : ModifierFlags.None)
|
||||
| (getJSDocReadonlyTag(node) ? ModifierFlags.Readonly : ModifierFlags.None);
|
||||
flags |= tags;
|
||||
}
|
||||
/**
|
||||
* Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifier flags cache on the node is ignored.
|
||||
*
|
||||
* NOTE: This function may use `parent` pointers.
|
||||
*/
|
||||
export function getEffectiveModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ModifierFlags for syntactic modifiers on the provided node. The modifier flags cache on the node is ignored.
|
||||
*
|
||||
* NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc.
|
||||
*/
|
||||
export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
let flags = modifiersToFlags(node.modifiers);
|
||||
if (node.flags & NodeFlags.NestedNamespace || (node.kind === SyntaxKind.Identifier && (<Identifier>node).isInJSDocNamespace)) {
|
||||
flags |= ModifierFlags.Export;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
export function modifiersToFlags(modifiers: NodeArray<Modifier> | undefined) {
|
||||
let flags = ModifierFlags.None;
|
||||
if (modifiers) {
|
||||
for (const modifier of modifiers) {
|
||||
flags |= modifierToFlag(modifier.kind);
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -4507,7 +4558,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isExportDefaultSymbol(symbol: Symbol): boolean {
|
||||
return symbol && length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], ModifierFlags.Default);
|
||||
return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
||||
@ -5055,7 +5106,7 @@ namespace ts {
|
||||
export function isAbstractConstructorSymbol(symbol: Symbol): boolean {
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const declaration = getClassLikeDeclarationOfSymbol(symbol);
|
||||
return !!declaration && hasModifier(declaration, ModifierFlags.Abstract);
|
||||
return !!declaration && hasSyntacticModifier(declaration, ModifierFlags.Abstract);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -6365,7 +6416,7 @@ namespace ts {
|
||||
if (node.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
return false;
|
||||
}
|
||||
if (hasModifier(node.parent, ModifierFlags.Abstract)) {
|
||||
if (hasSyntacticModifier(node.parent, ModifierFlags.Abstract)) {
|
||||
return true;
|
||||
}
|
||||
const containerKind = node.parent.parent.kind;
|
||||
|
||||
@ -255,7 +255,7 @@ namespace ts {
|
||||
|
||||
export type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration, name: Identifier };
|
||||
export function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration {
|
||||
return hasModifier(node, ModifierFlags.ParameterPropertyModifier) && parent.kind === SyntaxKind.Constructor;
|
||||
return hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier) && parent.kind === SyntaxKind.Constructor;
|
||||
}
|
||||
|
||||
export function isEmptyBindingPattern(node: BindingName): node is BindingPattern {
|
||||
@ -299,7 +299,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getCombinedModifierFlags(node: Declaration): ModifierFlags {
|
||||
return getCombinedFlags(node, getModifierFlags);
|
||||
return getCombinedFlags(node, getEffectiveModifierFlags);
|
||||
}
|
||||
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
@ -609,6 +609,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getJSDocParameterTagsWorker(param: ParameterDeclaration, noCache?: boolean): readonly JSDocParameterTag[] {
|
||||
if (param.name) {
|
||||
if (isIdentifier(param.name)) {
|
||||
const name = param.name.escapedText;
|
||||
return getJSDocTagsWorker(param.parent, noCache).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name);
|
||||
}
|
||||
else {
|
||||
const i = param.parent.parameters.indexOf(param);
|
||||
Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
|
||||
const paramTags = getJSDocTagsWorker(param.parent, noCache).filter(isJSDocParameterTag);
|
||||
if (i < paramTags.length) {
|
||||
return [paramTags[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
// return empty array for: out-of-order binding patterns and JSDoc function syntax, which has un-named parameters
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JSDoc parameter tags for the node if present.
|
||||
*
|
||||
@ -622,22 +641,18 @@ namespace ts {
|
||||
* For binding patterns, parameter tags are matched by position.
|
||||
*/
|
||||
export function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[] {
|
||||
if (param.name) {
|
||||
if (isIdentifier(param.name)) {
|
||||
const name = param.name.escapedText;
|
||||
return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name);
|
||||
}
|
||||
else {
|
||||
const i = param.parent.parameters.indexOf(param);
|
||||
Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
|
||||
const paramTags = getJSDocTags(param.parent).filter(isJSDocParameterTag);
|
||||
if (i < paramTags.length) {
|
||||
return [paramTags[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
// return empty array for: out-of-order binding patterns and JSDoc function syntax, which has un-named parameters
|
||||
return emptyArray;
|
||||
return getJSDocParameterTagsWorker(param, /*noCache*/ false);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getJSDocParameterTagsNoCache(param: ParameterDeclaration): readonly JSDocParameterTag[] {
|
||||
return getJSDocParameterTagsWorker(param, /*noCache*/ true);
|
||||
}
|
||||
|
||||
function getJSDocTypeParameterTagsWorker(param: TypeParameterDeclaration, noCache?: boolean): readonly JSDocTemplateTag[] {
|
||||
const name = param.name.escapedText;
|
||||
return getJSDocTagsWorker(param.parent, noCache).filter((tag): tag is JSDocTemplateTag =>
|
||||
isJSDocTemplateTag(tag) && tag.typeParameters.some(tp => tp.name.escapedText === name));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -651,9 +666,12 @@ namespace ts {
|
||||
* tag on the containing function expression would be first.
|
||||
*/
|
||||
export function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[] {
|
||||
const name = param.name.escapedText;
|
||||
return getJSDocTags(param.parent).filter((tag): tag is JSDocTemplateTag =>
|
||||
isJSDocTemplateTag(tag) && tag.typeParameters.some(tp => tp.name.escapedText === name));
|
||||
return getJSDocTypeParameterTagsWorker(param, /*noCache*/ false);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getJSDocTypeParameterTagsNoCache(param: TypeParameterDeclaration): readonly JSDocTemplateTag[] {
|
||||
return getJSDocTypeParameterTagsWorker(param, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -686,21 +704,41 @@ namespace ts {
|
||||
return getFirstJSDocTag(node, isJSDocPublicTag);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getJSDocPublicTagNoCache(node: Node): JSDocPublicTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocPublicTag, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Gets the JSDoc private tag for the node if present */
|
||||
export function getJSDocPrivateTag(node: Node): JSDocPrivateTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocPrivateTag);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getJSDocPrivateTagNoCache(node: Node): JSDocPrivateTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocPrivateTag, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Gets the JSDoc protected tag for the node if present */
|
||||
export function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocProtectedTag);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getJSDocProtectedTagNoCache(node: Node): JSDocProtectedTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocProtectedTag, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Gets the JSDoc protected tag for the node if present */
|
||||
export function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocReadonlyTag);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getJSDocReadonlyTagNoCache(node: Node): JSDocReadonlyTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocReadonlyTag, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Gets the JSDoc enum tag for the node if present */
|
||||
export function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined {
|
||||
return getFirstJSDocTag(node, isJSDocEnumTag);
|
||||
@ -775,21 +813,33 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
export function getJSDocTags(node: Node): readonly JSDocTag[] {
|
||||
function getJSDocTagsWorker(node: Node, noCache?: boolean): readonly JSDocTag[] {
|
||||
let tags = (node as JSDocContainer).jsDocCache;
|
||||
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
|
||||
if (tags === undefined) {
|
||||
const comments = getJSDocCommentsAndTags(node);
|
||||
if (tags === undefined || noCache) {
|
||||
const comments = getJSDocCommentsAndTags(node, noCache);
|
||||
Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
|
||||
(node as JSDocContainer).jsDocCache = tags = flatMap(comments, j => isJSDoc(j) ? j.tags : j);
|
||||
tags = flatMap(comments, j => isJSDoc(j) ? j.tags : j);
|
||||
if (!noCache) {
|
||||
(node as JSDocContainer).jsDocCache = tags;
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
export function getJSDocTags(node: Node): readonly JSDocTag[] {
|
||||
return getJSDocTagsWorker(node, /*noCache*/ false);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getJSDocTagsNoCache(node: Node): readonly JSDocTag[] {
|
||||
return getJSDocTagsWorker(node, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Get the first JSDoc tag of a specified kind, or undefined if not present. */
|
||||
function getFirstJSDocTag<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T): T | undefined {
|
||||
return find(getJSDocTags(node), predicate);
|
||||
function getFirstJSDocTag<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T, noCache?: boolean): T | undefined {
|
||||
return find(getJSDocTagsWorker(node, noCache), predicate);
|
||||
}
|
||||
|
||||
/** Gets all JSDoc tags that match a specified predicate */
|
||||
@ -2235,13 +2285,13 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function needsScopeMarker(result: Statement) {
|
||||
return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result);
|
||||
return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, ModifierFlags.Export) && !isAmbientModule(result);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isExternalModuleIndicator(result: Statement) {
|
||||
// Exported top-level member indicates moduleness
|
||||
return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export);
|
||||
return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@ -684,7 +684,7 @@ namespace ts {
|
||||
function aggregateTransformFlagsForSubtree(node: Node): TransformFlags {
|
||||
// We do not transform ambient declarations or types, so there is no need to
|
||||
// recursively aggregate transform flags.
|
||||
if (hasModifier(node, ModifierFlags.Ambient) || (isTypeNode(node) && node.kind !== SyntaxKind.ExpressionWithTypeArguments)) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Ambient) || (isTypeNode(node) && node.kind !== SyntaxKind.ExpressionWithTypeArguments)) {
|
||||
return TransformFlags.None;
|
||||
}
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -560,6 +560,10 @@ namespace FourSlashInterface {
|
||||
public noMoveToNewFile(): void {
|
||||
this.state.noMoveToNewFile();
|
||||
}
|
||||
|
||||
public organizeImports(newContent: string) {
|
||||
this.state.verifyOrganizeImports(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
export class Edit {
|
||||
|
||||
@ -649,14 +649,14 @@ namespace vfs {
|
||||
*
|
||||
* NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
|
||||
*/
|
||||
public readFileSync(path: string, encoding: string): string;
|
||||
public readFileSync(path: string, encoding: BufferEncoding): string;
|
||||
/**
|
||||
* Read from a file.
|
||||
*
|
||||
* NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module.
|
||||
*/
|
||||
public readFileSync(path: string, encoding?: string | null): string | Buffer;
|
||||
public readFileSync(path: string, encoding: string | null = null) { // eslint-disable-line no-null/no-null
|
||||
public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer;
|
||||
public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-null/no-null
|
||||
const { node } = this._walk(this._resolve(path));
|
||||
if (!node) throw createIOError("ENOENT");
|
||||
if (isDirectory(node)) throw createIOError("EISDIR");
|
||||
|
||||
@ -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>
|
||||
@ -3710,6 +3719,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[Zadeklaruj metodę prywatną „{0}”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@ -8597,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>
|
||||
@ -8633,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" />
|
||||
@ -8651,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>
|
||||
@ -10376,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>
|
||||
@ -3710,6 +3719,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[Declarar método privado '{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>
|
||||
@ -7194,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" />
|
||||
@ -8594,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>
|
||||
@ -8630,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" />
|
||||
@ -8648,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>
|
||||
@ -10373,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>
|
||||
|
||||
@ -1743,7 +1743,9 @@ namespace ts.server {
|
||||
|
||||
return project?.isSolution() ?
|
||||
project.getDefaultChildProjectFromSolution(info) :
|
||||
project;
|
||||
project && projectContainsInfoDirectly(project, info) ?
|
||||
project :
|
||||
undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -392,7 +392,7 @@ namespace ts.BreakpointResolver {
|
||||
// Breakpoint is possible in variableDeclaration only if there is initialization
|
||||
// or its declaration from 'for of'
|
||||
if (variableDeclaration.initializer ||
|
||||
hasModifier(variableDeclaration, ModifierFlags.Export) ||
|
||||
hasSyntacticModifier(variableDeclaration, ModifierFlags.Export) ||
|
||||
parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
return textSpanFromVariableDeclaration(variableDeclaration);
|
||||
}
|
||||
@ -410,7 +410,7 @@ namespace ts.BreakpointResolver {
|
||||
function canHaveSpanInParameterDeclaration(parameter: ParameterDeclaration): boolean {
|
||||
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
|
||||
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
|
||||
hasModifier(parameter, ModifierFlags.Public | ModifierFlags.Private);
|
||||
hasSyntacticModifier(parameter, ModifierFlags.Public | ModifierFlags.Private);
|
||||
}
|
||||
|
||||
function spanInParameterDeclaration(parameter: ParameterDeclaration): TextSpan | undefined {
|
||||
@ -437,7 +437,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration: FunctionLikeDeclaration) {
|
||||
return hasModifier(functionDeclaration, ModifierFlags.Export) ||
|
||||
return hasSyntacticModifier(functionDeclaration, ModifierFlags.Export) ||
|
||||
(functionDeclaration.parent.kind === SyntaxKind.ClassDeclaration && functionDeclaration.kind !== SyntaxKind.Constructor);
|
||||
}
|
||||
|
||||
|
||||
@ -410,7 +410,7 @@ namespace ts.CallHierarchy {
|
||||
}
|
||||
|
||||
function collectCallSitesOfModuleDeclaration(node: ModuleDeclaration, collect: (node: Node | undefined) => void) {
|
||||
if (!hasModifier(node, ModifierFlags.Ambient) && node.body && isModuleBlock(node.body)) {
|
||||
if (!hasSyntacticModifier(node, ModifierFlags.Ambient) && node.body && isModuleBlock(node.body)) {
|
||||
forEach(node.body.statements, collect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ namespace ts.codefix {
|
||||
}
|
||||
fixedDeclarations?.set(getNodeId(insertionSite).toString(), true);
|
||||
const cloneWithModifier = getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true);
|
||||
cloneWithModifier.modifiers = createNodeArray(createModifiersFromModifierFlags(getModifierFlags(insertionSite) | ModifierFlags.Async));
|
||||
cloneWithModifier.modifiers = createNodeArray(createModifiersFromModifierFlags(getSyntacticModifierFlags(insertionSite) | ModifierFlags.Async));
|
||||
cloneWithModifier.modifierFlagsCache = 0;
|
||||
changeTracker.replaceNode(
|
||||
sourceFile,
|
||||
|
||||
@ -148,7 +148,7 @@ namespace ts.codefix {
|
||||
declaration.type ||
|
||||
!declaration.initializer ||
|
||||
variableStatement.getSourceFile() !== sourceFile ||
|
||||
hasModifier(variableStatement, ModifierFlags.Export) ||
|
||||
hasSyntacticModifier(variableStatement, ModifierFlags.Export) ||
|
||||
!variableName ||
|
||||
!isInsideAwaitableBody(declaration.initializer)) {
|
||||
isCompleteFix = false;
|
||||
|
||||
@ -42,7 +42,7 @@ namespace ts.codefix {
|
||||
const parameter = first(indexSignature.parameters);
|
||||
const mappedTypeParameter = createTypeParameterDeclaration(cast(parameter.name, isIdentifier), parameter.type);
|
||||
const mappedIntersectionType = createMappedTypeNode(
|
||||
hasReadonlyModifier(indexSignature) ? createModifier(SyntaxKind.ReadonlyKeyword) : undefined,
|
||||
hasEffectiveReadonlyModifier(indexSignature) ? createModifier(SyntaxKind.ReadonlyKeyword) : undefined,
|
||||
mappedTypeParameter,
|
||||
indexSignature.questionToken,
|
||||
indexSignature.type);
|
||||
|
||||
@ -49,7 +49,7 @@ namespace ts.codefix {
|
||||
function symbolPointsToNonPrivateAndAbstractMember(symbol: Symbol): boolean {
|
||||
// See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files
|
||||
// (now named `codeFixClassExtendAbstractPrivateProperty.ts`)
|
||||
const flags = getModifierFlags(first(symbol.getDeclarations()!));
|
||||
const flags = getSyntacticModifierFlags(first(symbol.getDeclarations()!));
|
||||
return !(flags & ModifierFlags.Private) && !!(flags & ModifierFlags.Abstract);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function symbolPointsToNonPrivateMember(symbol: Symbol) {
|
||||
return !symbol.valueDeclaration || !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private);
|
||||
return !symbol.valueDeclaration || !(getEffectiveModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private);
|
||||
}
|
||||
|
||||
function addMissingDeclarations(
|
||||
|
||||
52
src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
Normal file
52
src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace ts.codefix {
|
||||
}
|
||||
else if (type.isClass()) {
|
||||
const classDeclaration = getClassLikeDeclarationOfSymbol(type.symbol);
|
||||
if (!classDeclaration || hasModifier(classDeclaration, ModifierFlags.Abstract)) return undefined;
|
||||
if (!classDeclaration || hasSyntacticModifier(classDeclaration, ModifierFlags.Abstract)) return undefined;
|
||||
|
||||
const constructorDeclaration = getFirstConstructorWithBody(classDeclaration);
|
||||
if (constructorDeclaration && constructorDeclaration.parameters.length) return undefined;
|
||||
|
||||
@ -40,7 +40,7 @@ namespace ts.codefix {
|
||||
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
||||
const declaration = declarations[0];
|
||||
const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName;
|
||||
const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration));
|
||||
const visibilityModifier = createVisibilityModifier(getEffectiveModifierFlags(declaration));
|
||||
const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined;
|
||||
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
||||
const optional = !!(symbol.flags & SymbolFlags.Optional);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
namespace ts.codefix {
|
||||
const fixId = "returnValueCorrect";
|
||||
const fixIdAddReturnStatement = "fixAddReturnStatement";
|
||||
const fixIdRemoveBlockBodyBrace = "fixRemoveBlockBodyBrace";
|
||||
const fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
||||
const fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
||||
const errorCodes = [
|
||||
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
||||
@ -35,7 +35,7 @@ namespace ts.codefix {
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
fixIds: [fixIdAddReturnStatement, fixIdRemoveBlockBodyBrace, fixIdWrapTheBlockWithParen],
|
||||
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
||||
getCodeActions: context => {
|
||||
const { program, sourceFile, span: { start }, errorCode } = context;
|
||||
const info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode);
|
||||
@ -44,7 +44,7 @@ namespace ts.codefix {
|
||||
if (info.kind === ProblemKind.MissingReturnStatement) {
|
||||
return append(
|
||||
[getActionForfixAddReturnStatement(context, info.expression, info.statement)],
|
||||
isArrowFunction(info.declaration) ? getActionForfixRemoveBlockBodyBrace(context, info.declaration, info.expression, info.commentSource): undefined);
|
||||
isArrowFunction(info.declaration) ? getActionForFixRemoveBracesFromArrowFunctionBody(context, info.declaration, info.expression, info.commentSource): undefined);
|
||||
}
|
||||
else {
|
||||
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
||||
@ -58,7 +58,7 @@ namespace ts.codefix {
|
||||
case fixIdAddReturnStatement:
|
||||
addReturnStatement(changes, diag.file, info.expression, info.statement);
|
||||
break;
|
||||
case fixIdRemoveBlockBodyBrace:
|
||||
case fixRemoveBracesFromArrowFunctionBody:
|
||||
if (!isArrowFunction(info.declaration)) return undefined;
|
||||
removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /* withParen */ false);
|
||||
break;
|
||||
@ -196,9 +196,9 @@ namespace ts.codefix {
|
||||
return createCodeFixAction(fixId, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
||||
}
|
||||
|
||||
function getActionForfixRemoveBlockBodyBrace(context: CodeFixContext, declaration: ArrowFunction, expression: Expression, commentSource: Node) {
|
||||
function getActionForFixRemoveBracesFromArrowFunctionBody(context: CodeFixContext, declaration: ArrowFunction, expression: Expression, commentSource: Node) {
|
||||
const changes = textChanges.ChangeTracker.with(context, t => removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /* withParen */ false));
|
||||
return createCodeFixAction(fixId, changes, Diagnostics.Remove_block_body_braces, fixIdRemoveBlockBodyBrace, Diagnostics.Remove_all_incorrect_body_block_braces);
|
||||
return createCodeFixAction(fixId, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
||||
}
|
||||
|
||||
function getActionForfixWrapTheBlockWithParen(context: CodeFixContext, declaration: ArrowFunction, expression: Expression) {
|
||||
|
||||
@ -875,7 +875,7 @@ namespace ts.Completions {
|
||||
// * |c|
|
||||
// */
|
||||
const lineStart = getLineStartPositionForPosition(position, sourceFile);
|
||||
if (!(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/))) {
|
||||
if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) {
|
||||
return { kind: CompletionDataKind.JsDocTag };
|
||||
}
|
||||
}
|
||||
@ -1990,7 +1990,7 @@ namespace ts.Completions {
|
||||
if (!isClassLike(decl)) return GlobalsSearch.Success;
|
||||
|
||||
const classElement = contextToken.kind === SyntaxKind.SemicolonToken ? contextToken.parent.parent : contextToken.parent;
|
||||
let classElementModifierFlags = isClassElement(classElement) ? getModifierFlags(classElement) : ModifierFlags.None;
|
||||
let classElementModifierFlags = isClassElement(classElement) ? getEffectiveModifierFlags(classElement) : ModifierFlags.None;
|
||||
// If this is context token is not something we are editing now, consider if this would lead to be modifier
|
||||
if (contextToken.kind === SyntaxKind.Identifier && !isCurrentlyEditingNode(contextToken)) {
|
||||
switch (contextToken.getText()) {
|
||||
@ -2409,12 +2409,12 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
// Dont filter member even if the name matches if it is declared private in the list
|
||||
if (hasModifier(m, ModifierFlags.Private)) {
|
||||
if (hasEffectiveModifier(m, ModifierFlags.Private)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not filter it out if the static presence doesnt match
|
||||
if (hasModifier(m, ModifierFlags.Static) !== !!(currentClassElementModifierFlags & ModifierFlags.Static)) {
|
||||
if (hasEffectiveModifier(m, ModifierFlags.Static) !== !!(currentClassElementModifierFlags & ModifierFlags.Static)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ namespace ts.FindAllReferences {
|
||||
((isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent))
|
||||
&& node.parent.propertyName === node) ||
|
||||
// Is default export
|
||||
(node.kind === SyntaxKind.DefaultKeyword && hasModifier(node.parent, ModifierFlags.ExportDefault))) {
|
||||
(node.kind === SyntaxKind.DefaultKeyword && hasSyntacticModifier(node.parent, ModifierFlags.ExportDefault))) {
|
||||
return getContextNode(node.parent);
|
||||
}
|
||||
|
||||
@ -1146,7 +1146,7 @@ namespace ts.FindAllReferences {
|
||||
|
||||
// If this is private property or method, the scope is the containing class
|
||||
if (flags & (SymbolFlags.Property | SymbolFlags.Method)) {
|
||||
const privateDeclaration = find(declarations, d => hasModifier(d, ModifierFlags.Private) || isPrivateIdentifierPropertyDeclaration(d));
|
||||
const privateDeclaration = find(declarations, d => hasEffectiveModifier(d, ModifierFlags.Private) || isPrivateIdentifierPropertyDeclaration(d));
|
||||
if (privateDeclaration) {
|
||||
return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration);
|
||||
}
|
||||
@ -1561,7 +1561,7 @@ namespace ts.FindAllReferences {
|
||||
Debug.assert(classLike.name === referenceLocation);
|
||||
const addRef = state.referenceAdder(search.symbol);
|
||||
for (const member of classLike.members) {
|
||||
if (!(isMethodOrAccessor(member) && hasModifier(member, ModifierFlags.Static))) {
|
||||
if (!(isMethodOrAccessor(member) && hasSyntacticModifier(member, ModifierFlags.Static))) {
|
||||
continue;
|
||||
}
|
||||
if (member.body) {
|
||||
@ -1776,7 +1776,7 @@ namespace ts.FindAllReferences {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
staticFlag &= getModifierFlags(searchSpaceNode);
|
||||
staticFlag &= getSyntacticModifierFlags(searchSpaceNode);
|
||||
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
|
||||
break;
|
||||
default:
|
||||
@ -1794,7 +1794,7 @@ namespace ts.FindAllReferences {
|
||||
// If we have a 'super' container, we must have an enclosing class.
|
||||
// Now make sure the owning class is the same as the search-space
|
||||
// and has the same static qualifier as the original 'super's owner.
|
||||
return container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
|
||||
return container && (ModifierFlags.Static & getSyntacticModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
|
||||
});
|
||||
|
||||
return [{ definition: { type: DefinitionKind.Symbol, symbol: searchSpaceNode.symbol }, references }];
|
||||
@ -1822,7 +1822,7 @@ namespace ts.FindAllReferences {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
staticFlag &= getModifierFlags(searchSpaceNode);
|
||||
staticFlag &= getSyntacticModifierFlags(searchSpaceNode);
|
||||
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
@ -1857,7 +1857,7 @@ namespace ts.FindAllReferences {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
// Make sure the container belongs to the same class
|
||||
// and has the appropriate static modifier from the original container.
|
||||
return container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag;
|
||||
return container.parent && searchSpaceNode.symbol === container.parent.symbol && (getSyntacticModifierFlags(container) & ModifierFlags.Static) === staticFlag;
|
||||
case SyntaxKind.SourceFile:
|
||||
return container.kind === SyntaxKind.SourceFile && !isExternalModule(<SourceFile>container) && !isParameterName(node);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -103,7 +103,7 @@ namespace ts.FindAllReferences {
|
||||
break; // TODO: GH#23879
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
handleNamespaceImport(direct, direct.name, hasModifier(direct, ModifierFlags.Export), /*alreadyAddedDirect*/ false);
|
||||
handleNamespaceImport(direct, direct.name, hasSyntacticModifier(direct, ModifierFlags.Export), /*alreadyAddedDirect*/ false);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
@ -463,7 +463,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
else {
|
||||
const exportNode = getExportNode(parent, node);
|
||||
if (exportNode && hasModifier(exportNode, ModifierFlags.Export)) {
|
||||
if (exportNode && hasSyntacticModifier(exportNode, ModifierFlags.Export)) {
|
||||
if (isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) {
|
||||
// We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement.
|
||||
if (comingFromExport) {
|
||||
@ -553,7 +553,7 @@ namespace ts.FindAllReferences {
|
||||
|
||||
// Not meant for use with export specifiers or export assignment.
|
||||
function getExportKindForDeclaration(node: Node): ExportKind {
|
||||
return hasModifier(node, ModifierFlags.Default) ? ExportKind.Default : ExportKind.Named;
|
||||
return hasSyntacticModifier(node, ModifierFlags.Default) ? ExportKind.Default : ExportKind.Named;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -89,17 +89,14 @@ namespace ts.JsDoc {
|
||||
// Eg. const a: Array<string> | Array<number>; a.length
|
||||
// The property length will have two declarations of property length coming
|
||||
// from Array<T> - Array<string> and Array<number>
|
||||
const documentationComment: SymbolDisplayPart[] = [];
|
||||
const documentationComment: string[] = [];
|
||||
forEachUnique(declarations, declaration => {
|
||||
for (const { comment } of getCommentHavingNodes(declaration)) {
|
||||
if (comment === undefined) continue;
|
||||
if (documentationComment.length) {
|
||||
documentationComment.push(lineBreakPart());
|
||||
}
|
||||
documentationComment.push(textPart(comment));
|
||||
pushIfUnique(documentationComment, comment);
|
||||
}
|
||||
});
|
||||
return documentationComment;
|
||||
return intersperse(map(documentationComment, textPart), lineBreakPart());
|
||||
}
|
||||
|
||||
function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDocTag)[] {
|
||||
|
||||
@ -307,7 +307,18 @@ namespace ts.NavigationBar {
|
||||
addNodeWithRecursiveChild(node, getInteriorModule(<ModuleDeclaration>node).body);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ExportAssignment: {
|
||||
const expression = (<ExportAssignment>node).expression;
|
||||
if (isObjectLiteralExpression(expression)) {
|
||||
startNode(node);
|
||||
addChildrenRecursively(expression);
|
||||
endNode();
|
||||
}
|
||||
else {
|
||||
addLeafNode(node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.IndexSignature:
|
||||
@ -590,7 +601,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return hasModifier(a, ModifierFlags.Static) === hasModifier(b, ModifierFlags.Static);
|
||||
return hasSyntacticModifier(a, ModifierFlags.Static) === hasSyntacticModifier(b, ModifierFlags.Static);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return areSameModule(<ModuleDeclaration>a, <ModuleDeclaration>b);
|
||||
default:
|
||||
@ -690,7 +701,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
if (getModifierFlags(node) & ModifierFlags.Default) {
|
||||
if (getSyntacticModifierFlags(node) & ModifierFlags.Default) {
|
||||
return "default";
|
||||
}
|
||||
// We may get a string with newlines or other whitespace in the case of an object dereference
|
||||
@ -883,7 +894,7 @@ namespace ts.NavigationBar {
|
||||
return nodeText(parent.name);
|
||||
}
|
||||
// Default exports are named "default"
|
||||
else if (getModifierFlags(node) & ModifierFlags.Default) {
|
||||
else if (getSyntacticModifierFlags(node) & ModifierFlags.Default) {
|
||||
return "default";
|
||||
}
|
||||
else if (isClassLike(node)) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -200,6 +204,7 @@ namespace ts.OutliningElementsCollector {
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return spanForNode(n);
|
||||
case SyntaxKind.TupleType:
|
||||
return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !isTupleTypeNode(n.parent), SyntaxKind.OpenBracketToken);
|
||||
|
||||
@ -38,7 +38,7 @@ namespace ts.refactor {
|
||||
|
||||
const exportingModuleSymbol = isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol;
|
||||
|
||||
const flags = getModifierFlags(exportNode);
|
||||
const flags = getSyntacticModifierFlags(exportNode);
|
||||
const wasDefault = !!(flags & ModifierFlags.Default);
|
||||
// If source file already has a default export, don't offer refactor.
|
||||
if (!(flags & ModifierFlags.Export) || !wasDefault && exportingModuleSymbol.exports!.has(InternalSymbolName.Default)) {
|
||||
|
||||
219
src/services/refactors/convertOverloadListToSingleSignature.ts
Normal file
219
src/services/refactors/convertOverloadListToSingleSignature.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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.
|
||||
@ -309,7 +309,7 @@ namespace ts.refactor.extractSymbol {
|
||||
let current: Node = nodeToCheck;
|
||||
while (current !== containingClass) {
|
||||
if (current.kind === SyntaxKind.PropertyDeclaration) {
|
||||
if (hasModifier(current, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(current, ModifierFlags.Static)) {
|
||||
rangeFacts |= RangeFacts.InStaticRegion;
|
||||
}
|
||||
break;
|
||||
@ -322,7 +322,7 @@ namespace ts.refactor.extractSymbol {
|
||||
break;
|
||||
}
|
||||
else if (current.kind === SyntaxKind.MethodDeclaration) {
|
||||
if (hasModifier(current, ModifierFlags.Static)) {
|
||||
if (hasSyntacticModifier(current, ModifierFlags.Static)) {
|
||||
rangeFacts |= RangeFacts.InStaticRegion;
|
||||
}
|
||||
}
|
||||
@ -375,7 +375,7 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
if (isDeclaration(node)) {
|
||||
const declaringNode = (node.kind === SyntaxKind.VariableDeclaration) ? node.parent.parent : node;
|
||||
if (hasModifier(declaringNode, ModifierFlags.Export)) {
|
||||
if (hasSyntacticModifier(declaringNode, ModifierFlags.Export)) {
|
||||
// TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`)
|
||||
// Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`!
|
||||
// Also TODO: GH#19956
|
||||
@ -405,24 +405,24 @@ namespace ts.refactor.extractSymbol {
|
||||
rangeFacts |= RangeFacts.UsesThis;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
if (isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) {
|
||||
// You cannot extract global declarations
|
||||
(errors || (errors = [] as Diagnostic[])).push(createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope));
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
// do not dive into functions (except arrow functions) or classes
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFunctionLikeDeclaration(node) || isClassLike(node)) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
if (isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) {
|
||||
// You cannot extract global declarations
|
||||
(errors || (errors = [] as Diagnostic[])).push(createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// do not dive into functions or classes
|
||||
return false;
|
||||
}
|
||||
const savedPermittedJumps = permittedJumps;
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.IfStatement:
|
||||
permittedJumps = PermittedJumps.None;
|
||||
@ -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(
|
||||
@ -1584,7 +1595,7 @@ namespace ts.refactor.extractSymbol {
|
||||
hasWrite = true;
|
||||
if (value.symbol.flags & SymbolFlags.ClassMember &&
|
||||
value.symbol.valueDeclaration &&
|
||||
hasModifier(value.symbol.valueDeclaration, ModifierFlags.Readonly)) {
|
||||
hasEffectiveModifier(value.symbol.valueDeclaration, ModifierFlags.Readonly)) {
|
||||
readonlyClassPropertyWrite = value.symbol.valueDeclaration;
|
||||
}
|
||||
}
|
||||
@ -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()) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,6 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
const fieldInfo = getConvertibleFieldAtPosition(context);
|
||||
if (!fieldInfo) return undefined;
|
||||
|
||||
const isJS = isSourceFileJS(file);
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
const { isStatic, isReadonly, fieldName, accessorName, originalName, type, container, declaration, renameAccessor } = fieldInfo;
|
||||
|
||||
@ -50,15 +49,20 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
suppressLeadingAndTrailingTrivia(declaration);
|
||||
suppressLeadingAndTrailingTrivia(container);
|
||||
|
||||
const isInClassLike = isClassLike(container);
|
||||
// avoid Readonly modifier because it will convert to get accessor
|
||||
const modifierFlags = getModifierFlags(declaration) & ~ModifierFlags.Readonly;
|
||||
const accessorModifiers = isInClassLike
|
||||
? !modifierFlags || modifierFlags & ModifierFlags.Private
|
||||
? getModifiers(isJS, isStatic, SyntaxKind.PublicKeyword)
|
||||
: createNodeArray(createModifiersFromModifierFlags(modifierFlags))
|
||||
: undefined;
|
||||
const fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, SyntaxKind.PrivateKeyword) : undefined;
|
||||
let accessorModifiers: ModifiersArray | undefined;
|
||||
let fieldModifiers: ModifiersArray | undefined;
|
||||
if (isClassLike(container)) {
|
||||
const modifierFlags = getEffectiveModifierFlags(declaration);
|
||||
if (isSourceFileJS(file)) {
|
||||
const modifiers = createModifiers(modifierFlags);
|
||||
accessorModifiers = modifiers;
|
||||
fieldModifiers = modifiers;
|
||||
}
|
||||
else {
|
||||
accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags));
|
||||
fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags));
|
||||
}
|
||||
}
|
||||
|
||||
updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers);
|
||||
|
||||
@ -105,12 +109,26 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
return isIdentifier(fieldName) ? createPropertyAccess(leftHead, fieldName) : createElementAccess(leftHead, createLiteral(fieldName));
|
||||
}
|
||||
|
||||
function getModifiers(isJS: boolean, isStatic: boolean, accessModifier: SyntaxKind.PublicKeyword | SyntaxKind.PrivateKeyword): NodeArray<Modifier> | undefined {
|
||||
const modifiers = append<Modifier>(
|
||||
!isJS ? [createToken(accessModifier) as Token<SyntaxKind.PublicKeyword> | Token<SyntaxKind.PrivateKeyword>] : undefined,
|
||||
isStatic ? createToken(SyntaxKind.StaticKeyword) : undefined
|
||||
);
|
||||
return modifiers && createNodeArray(modifiers);
|
||||
function createModifiers(modifierFlags: ModifierFlags): ModifiersArray | undefined {
|
||||
return modifierFlags ? createNodeArray(createModifiersFromModifierFlags(modifierFlags)) : undefined;
|
||||
}
|
||||
|
||||
function prepareModifierFlagsForAccessor(modifierFlags: ModifierFlags): ModifierFlags {
|
||||
modifierFlags &= ~ModifierFlags.Readonly; // avoid Readonly modifier because it will convert to get accessor
|
||||
modifierFlags &= ~ModifierFlags.Private;
|
||||
|
||||
if (!(modifierFlags & ModifierFlags.Protected)) {
|
||||
modifierFlags |= ModifierFlags.Public;
|
||||
}
|
||||
|
||||
return modifierFlags;
|
||||
}
|
||||
|
||||
function prepareModifierFlagsForField(modifierFlags: ModifierFlags): ModifierFlags {
|
||||
modifierFlags &= ~ModifierFlags.Public;
|
||||
modifierFlags &= ~ModifierFlags.Protected;
|
||||
modifierFlags |= ModifierFlags.Private;
|
||||
return modifierFlags;
|
||||
}
|
||||
|
||||
function getConvertibleFieldAtPosition(context: RefactorContext): Info | undefined {
|
||||
@ -121,7 +139,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
|
||||
const meaning = ModifierFlags.AccessibilityModifier | ModifierFlags.Static | ModifierFlags.Readonly;
|
||||
if (!declaration || !nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition!) // TODO: GH#18217
|
||||
|| !isConvertibleName(declaration.name) || (getModifierFlags(declaration) | meaning) !== meaning) return undefined;
|
||||
|| !isConvertibleName(declaration.name) || (getEffectiveModifierFlags(declaration) | meaning) !== meaning) return undefined;
|
||||
|
||||
const name = declaration.name.text;
|
||||
const startWithUnderscore = startsWithUnderscore(name);
|
||||
@ -129,7 +147,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
const accessorName = createPropertyName(startWithUnderscore ? getUniqueName(name.substring(1), file) : name, declaration.name);
|
||||
return {
|
||||
isStatic: hasStaticModifier(declaration),
|
||||
isReadonly: hasReadonlyModifier(declaration),
|
||||
isReadonly: hasEffectiveReadonlyModifier(declaration),
|
||||
type: getTypeAnnotationNode(declaration),
|
||||
container: declaration.kind === SyntaxKind.Parameter ? declaration.parent.parent : declaration.parent,
|
||||
originalName: (<AcceptedNameType>declaration.name).text,
|
||||
|
||||
@ -84,7 +84,7 @@ namespace ts.refactor {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return !hasModifier(node, ModifierFlags.Export);
|
||||
return !hasSyntacticModifier(node, ModifierFlags.Export);
|
||||
case SyntaxKind.VariableStatement:
|
||||
return (node as VariableStatement).declarationList.declarations.every(d => !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true));
|
||||
default:
|
||||
@ -420,7 +420,7 @@ namespace ts.refactor {
|
||||
if (markSeenTop(top)) {
|
||||
addExportToChanges(oldFile, top, changes, useEs6ModuleSyntax);
|
||||
}
|
||||
if (hasModifier(decl, ModifierFlags.Default)) {
|
||||
if (hasSyntacticModifier(decl, ModifierFlags.Default)) {
|
||||
oldFileDefault = name;
|
||||
}
|
||||
else {
|
||||
@ -737,7 +737,7 @@ namespace ts.refactor {
|
||||
|
||||
function isExported(sourceFile: SourceFile, decl: TopLevelDeclarationStatement, useEs6Exports: boolean): boolean {
|
||||
if (useEs6Exports) {
|
||||
return !isExpressionStatement(decl) && hasModifier(decl, ModifierFlags.Export);
|
||||
return !isExpressionStatement(decl) && hasSyntacticModifier(decl, ModifierFlags.Export);
|
||||
}
|
||||
else {
|
||||
return getNamesToExportInCommonJS(decl).some(name => sourceFile.symbol.exports!.has(escapeLeadingUnderscores(name)));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -763,7 +770,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
// Only consider parameter properties
|
||||
if (!hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
|
||||
if (!hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -389,7 +389,7 @@ namespace ts.SymbolDisplay {
|
||||
if (declarationName) {
|
||||
const isExternalModuleDeclaration =
|
||||
isModuleWithStringLiteralName(resolvedNode) &&
|
||||
hasModifier(resolvedNode, ModifierFlags.Ambient);
|
||||
hasSyntacticModifier(resolvedNode, ModifierFlags.Ambient);
|
||||
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
||||
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(
|
||||
typeChecker,
|
||||
@ -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 ||
|
||||
|
||||
@ -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) });
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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.
|
||||
//
|
||||
|
||||
@ -407,7 +407,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
|
||||
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
|
||||
case SyntaxKind.EnumMember: return ScriptElementKind.enumMemberElement;
|
||||
case SyntaxKind.Parameter: return hasModifier(node, ModifierFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.Parameter: return hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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: {
|
||||
|
||||
@ -15,6 +15,13 @@ namespace ts.tscWatch {
|
||||
return ts.createSolutionBuilder(host, rootNames, defaultOptions || {});
|
||||
}
|
||||
|
||||
export function ensureErrorFreeBuild(host: WatchedSystem, rootNames: readonly string[]) {
|
||||
// ts build should succeed
|
||||
const solutionBuilder = createSolutionBuilder(host, rootNames, {});
|
||||
solutionBuilder.build();
|
||||
assert.equal(host.getOutput().length, 0, JSON.stringify(host.getOutput(), /*replacer*/ undefined, " "));
|
||||
}
|
||||
|
||||
type OutputFileStamp = [string, Date | undefined, boolean];
|
||||
function transformOutputToOutputFileStamp(f: string, host: TsBuildWatchSystem): OutputFileStamp {
|
||||
return [f, host.getModifiedTime(f), host.writtenFiles.has(host.toFullPath(f))] as OutputFileStamp;
|
||||
|
||||
@ -1050,6 +1050,64 @@ declare var console: {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("when default configured project does not contain the file", () => {
|
||||
const barConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/bar/tsconfig.json`,
|
||||
content: "{}"
|
||||
};
|
||||
const barIndex: File = {
|
||||
path: `${tscWatch.projectRoot}/bar/index.ts`,
|
||||
content: `import {foo} from "../foo/lib";
|
||||
foo();`
|
||||
};
|
||||
const fooBarConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/foobar/tsconfig.json`,
|
||||
content: barConfig.path
|
||||
};
|
||||
const fooBarIndex: File = {
|
||||
path: `${tscWatch.projectRoot}/foobar/index.ts`,
|
||||
content: barIndex.content
|
||||
};
|
||||
const fooConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/foo/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
include: ["index.ts"],
|
||||
compilerOptions: {
|
||||
declaration: true,
|
||||
outDir: "lib"
|
||||
}
|
||||
})
|
||||
};
|
||||
const fooIndex: File = {
|
||||
path: `${tscWatch.projectRoot}/foo/index.ts`,
|
||||
content: `export function foo() {}`
|
||||
};
|
||||
const host = createServerHost([barConfig, barIndex, fooBarConfig, fooBarIndex, fooConfig, fooIndex, libFile]);
|
||||
tscWatch.ensureErrorFreeBuild(host, [fooConfig.path]);
|
||||
const fooDts = `${tscWatch.projectRoot}/foo/lib/index.d.ts`;
|
||||
assert.isTrue(host.fileExists(fooDts));
|
||||
const session = createSession(host);
|
||||
const service = session.getProjectService();
|
||||
service.openClientFile(barIndex.path);
|
||||
checkProjectActualFiles(service.configuredProjects.get(barConfig.path)!, [barIndex.path, fooDts, libFile.path, barConfig.path]);
|
||||
service.openClientFile(fooBarIndex.path);
|
||||
checkProjectActualFiles(service.configuredProjects.get(fooBarConfig.path)!, [fooBarIndex.path, fooDts, libFile.path, fooBarConfig.path]);
|
||||
service.openClientFile(fooIndex.path);
|
||||
checkProjectActualFiles(service.configuredProjects.get(fooConfig.path)!, [fooIndex.path, libFile.path, fooConfig.path]);
|
||||
service.openClientFile(fooDts);
|
||||
session.executeCommandSeq<protocol.GetApplicableRefactorsRequest>({
|
||||
command: protocol.CommandTypes.GetApplicableRefactors,
|
||||
arguments: {
|
||||
file: fooDts,
|
||||
startLine: 1,
|
||||
startOffset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1
|
||||
}
|
||||
});
|
||||
assert.equal(service.tryGetDefaultProjectForFile(server.toNormalizedPath(fooDts)), service.configuredProjects.get(barConfig.path));
|
||||
});
|
||||
});
|
||||
|
||||
describe("unittests:: tsserver:: ConfiguredProjects:: non-existing directories listed in config file input array", () => {
|
||||
|
||||
@ -469,9 +469,7 @@ ${appendDts}`
|
||||
const host = createServerHost([libFile, tsbaseJson, buttonConfig, buttonSource, siblingConfig, siblingSource], { useCaseSensitiveFileNames: true });
|
||||
|
||||
// ts build should succeed
|
||||
const solutionBuilder = tscWatch.createSolutionBuilder(host, [siblingConfig.path], {});
|
||||
solutionBuilder.build();
|
||||
assert.equal(host.getOutput().length, 0, JSON.stringify(host.getOutput(), /*replacer*/ undefined, " "));
|
||||
tscWatch.ensureErrorFreeBuild(host, [siblingConfig.path]);
|
||||
const sourceJs = changeExtension(siblingSource.path, ".js");
|
||||
const expectedSiblingJs = host.readFile(sourceJs);
|
||||
|
||||
|
||||
@ -2,12 +2,8 @@ namespace ts.projectSystem {
|
||||
describe("unittests:: tsserver:: with project references and tsbuild", () => {
|
||||
function createHost(files: readonly TestFSWithWatch.FileOrFolderOrSymLink[], rootNames: readonly string[]) {
|
||||
const host = createServerHost(files);
|
||||
|
||||
// ts build should succeed
|
||||
const solutionBuilder = tscWatch.createSolutionBuilder(host, rootNames, {});
|
||||
solutionBuilder.build();
|
||||
assert.equal(host.getOutput().length, 0, JSON.stringify(host.getOutput(), /*replacer*/ undefined, " "));
|
||||
|
||||
tscWatch.ensureErrorFreeBuild(host, rootNames);
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -39,7 +39,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
}
|
||||
};
|
||||
exports.__esModule = true;
|
||||
__exportStar(require("jquery"), exports);
|
||||
//// [reExportUser.js]
|
||||
|
||||
340
tests/baselines/reference/api/tsserverlibrary.d.ts
vendored
340
tests/baselines/reference/api/tsserverlibrary.d.ts
vendored
@ -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,
|
||||
@ -482,6 +483,7 @@ declare namespace ts {
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
Const = 2048,
|
||||
HasComputedJSDocModifiers = 4096,
|
||||
HasComputedFlags = 536870912,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 92,
|
||||
@ -507,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;
|
||||
@ -808,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;
|
||||
@ -946,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;
|
||||
@ -1577,6 +1587,7 @@ declare namespace ts {
|
||||
text: string;
|
||||
pos: -1;
|
||||
end: -1;
|
||||
hasLeadingNewline?: boolean;
|
||||
}
|
||||
export interface JSDocTypeExpression extends TypeNode {
|
||||
kind: SyntaxKind.JSDocTypeExpression;
|
||||
@ -1742,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;
|
||||
}
|
||||
@ -2475,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;
|
||||
@ -3232,7 +3233,8 @@ declare namespace ts {
|
||||
HeritageClauses = 512,
|
||||
SingleLineTypeLiteralMembers = 768,
|
||||
MultiLineTypeLiteralMembers = 32897,
|
||||
TupleTypeElements = 528,
|
||||
SingleLineTupleTypeElements = 528,
|
||||
MultiLineTupleTypeElements = 657,
|
||||
UnionTypeConstituents = 516,
|
||||
IntersectionTypeConstituents = 520,
|
||||
ObjectBindingPatternElements = 525136,
|
||||
@ -4052,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;
|
||||
@ -4071,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;
|
||||
|
||||
340
tests/baselines/reference/api/typescript.d.ts
vendored
340
tests/baselines/reference/api/typescript.d.ts
vendored
@ -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,
|
||||
@ -482,6 +483,7 @@ declare namespace ts {
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
Const = 2048,
|
||||
HasComputedJSDocModifiers = 4096,
|
||||
HasComputedFlags = 536870912,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 92,
|
||||
@ -507,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;
|
||||
@ -808,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;
|
||||
@ -946,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;
|
||||
@ -1577,6 +1587,7 @@ declare namespace ts {
|
||||
text: string;
|
||||
pos: -1;
|
||||
end: -1;
|
||||
hasLeadingNewline?: boolean;
|
||||
}
|
||||
export interface JSDocTypeExpression extends TypeNode {
|
||||
kind: SyntaxKind.JSDocTypeExpression;
|
||||
@ -1742,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;
|
||||
}
|
||||
@ -2475,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;
|
||||
@ -3232,7 +3233,8 @@ declare namespace ts {
|
||||
HeritageClauses = 512,
|
||||
SingleLineTypeLiteralMembers = 768,
|
||||
MultiLineTypeLiteralMembers = 32897,
|
||||
TupleTypeElements = 528,
|
||||
SingleLineTupleTypeElements = 528,
|
||||
MultiLineTupleTypeElements = 657,
|
||||
UnionTypeConstituents = 516,
|
||||
IntersectionTypeConstituents = 520,
|
||||
ObjectBindingPatternElements = 525136,
|
||||
@ -4052,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;
|
||||
@ -4071,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; }
|
||||
}
|
||||
|
||||
161
tests/baselines/reference/checkSuperCallBeforeThisAccess.js
Normal file
161
tests/baselines/reference/checkSuperCallBeforeThisAccess.js
Normal file
@ -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; }
|
||||
}
|
||||
231
tests/baselines/reference/checkSuperCallBeforeThisAccess.symbols
Normal file
231
tests/baselines/reference/checkSuperCallBeforeThisAccess.symbols
Normal file
@ -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))
|
||||
}
|
||||
|
||||
279
tests/baselines/reference/checkSuperCallBeforeThisAccess.types
Normal file
279
tests/baselines/reference/checkSuperCallBeforeThisAccess.types
Normal file
@ -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
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user