Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
dd294236f8e37db0bc68fde61d6db0b1e02943761bd53552f77ac42f71c092a14deb8ea603aa24e21657cd0cd4eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| // @lib: es2015 | ||
| ////let x: Iterator<number>; | ||
| ////export const y = x; | ||
| verify.codeFix({ | ||
| description: "Add annotation of type 'Iterator<number>'", | ||
| index: 0, | ||
| newFileContent: | ||
| `let x: Iterator<number>; | ||
| export const y: Iterator<number> = x;`, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| ////export interface Foo<T, U = T[]> {} | ||
| ////export function foo(x: Foo<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>): Foo<string> { | ||
| return x; | ||
| }`, | ||
| }); |
| 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 heuristic to avoid overly complex types in this case creates | ||
| // "overly simple" types, but this tradeoff seems reasonable. | ||
| // @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; | ||
| }`, | ||
| }); |
| 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; | ||
| }`, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| // @lib: es2015 | ||
| //// export function foo(x: Generator<number>) { | ||
| //// return x; | ||
| //// } | ||
| verify.codeFix({ | ||
| description: "Add return type 'Generator<number>'", | ||
| index: 0, | ||
| newFileContent: | ||
| `export function foo(x: Generator<number>): Generator<number> { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear I was meaning to write ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, OK, added. It's not technically related to the rest of this PR since it gets inferred a precise return that needs all 3 type arguments, but it's a good case to include in the test suite anyway. | ||
| return x; | ||
| }` | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /// <reference path='fourslash.ts'/> | ||
| // @isolatedDeclarations: true | ||
| // @declaration: true | ||
| // @lib: es2015 | ||
| //// export function *foo() { | ||
| //// yield 5; | ||
| //// } | ||
| verify.codeFix({ | ||
| description: "Add return type 'Generator<number, void, unknown>'", | ||
| index: 0, | ||
| newFileContent: | ||
| `export function *foo(): Generator<number, void, unknown> { | ||
| yield 5; | ||
| }` | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.