-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Drop unnecessary type arguments in the isolated declarations quick fix #59665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jakebailey
merged 13 commits into
microsoft:main
from
blickly:dont-suggest-default-generics
Sep 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
dd29423
Create a few (failing) test cases of https://github.com/microsoft/Typ…
blickly 6f8e37d
Add functionality to convert a ReferenceType into a "minimal" TypeNode
blickly b0bc68f
Add a few more test cases of the "negative" cases
blickly de61d6d
First fixes based on code review feedback
blickly b0b1e02
Update src/compiler/types.ts
blickly 943761b
Fix unused import
blickly d53552f
Run dprint to fix formatting
blickly 77ac42f
Use factory methods to create new AST node instead of mutating
blickly 71c092a
Avoid updating nodes when unnecessary
blickly 14deb8e
Add example case with a inferred generator return
blickly a603aa2
Update tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports52-…
blickly 4e21657
Update src/services/codefixes/helpers.ts
blickly cd0cd4e
Fix typo in filename
blickly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add a few more test cases of the "negative" cases
These are the cases where our heuristic makes some compromise that isn't what we would have preferred, but add the unit tests as a way of documenting the current behavior.
- Loading branch information
commit b0bc68fcabd64d09ac7020446d670d56234a97b5
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...s/cases/fourslash/codeFixMissingTypeAnnotationOnExports52-gerenrics-oversimplification.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
|
|
||
| // In the abstract, we might prefer the inferred return type annotation to | ||
| // be identical to the parameter type (with 2 type parameters). | ||
| // Our current heursitic to avoid overly complex types in this case creates | ||
|
blickly marked this conversation as resolved.
Outdated
|
||
| // "overly simple" types, but this tradeoff seems reasonable. | ||
|
sandersn marked this conversation as resolved.
|
||
|
|
||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| ////export interface Foo<T, U = T[]> {} | ||
| ////export function foo(x: Foo<string, string[]>) { | ||
| //// return x; | ||
| ////} | ||
|
|
||
| verify.codeFix({ | ||
| description: "Add return type 'Foo<string>'", | ||
| index: 0, | ||
| newFileContent: | ||
| `export interface Foo<T, U = T[]> {} | ||
| export function foo(x: Foo<string, string[]>): Foo<string> { | ||
| return x; | ||
| }`, | ||
| }); | ||
21 changes: 21 additions & 0 deletions
21
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports53-nested-generic-types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
|
|
||
| // Our current heursitic to avoid overly verbose generic types | ||
| // doesn't handle generic types nested inside other types. | ||
|
|
||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| ////export interface Foo<T, U = T[]> {} | ||
| ////export function foo(x: Map<number, Foo<string>>) { | ||
| //// return x; | ||
| ////} | ||
|
|
||
| verify.codeFix({ | ||
| description: "Add return type 'Map<number, Foo<string, string[]>>'", | ||
| index: 0, | ||
| newFileContent: | ||
| `export interface Foo<T, U = T[]> {} | ||
| export function foo(x: Map<number, Foo<string>>): Map<number, Foo<string, string[]>> { | ||
| return x; | ||
| }`, | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.