Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3f59aa9
stash
Kingwl Aug 10, 2018
7671221
add surmise for return type
Kingwl Aug 14, 2018
0b1e6cc
add support for more case
Kingwl Aug 14, 2018
1f9b9c0
add more test case
Kingwl Aug 16, 2018
aca1722
add more testcase and fix all test
Kingwl Aug 20, 2018
7cfd0fb
Merge branch 'master' into returnValueSurmise
Kingwl Apr 29, 2019
cbe59bb
fix changed diagnosis
Kingwl Apr 30, 2019
48f1cca
Merge branch 'master' into returnValueSurmise
Kingwl May 8, 2019
98d7eba
fix broken test case
Kingwl May 8, 2019
537e806
add more case
Kingwl May 8, 2019
505e299
Merge branch 'master' into returnValueSurmise
Kingwl Jan 9, 2020
6fecf32
rename quickfix
Kingwl Jan 9, 2020
4c0af72
fix conflict
Kingwl Jan 9, 2020
98377f3
fix fix desc
Kingwl Jan 9, 2020
49d21bf
fix semi
Kingwl Jan 9, 2020
a2b15ed
Merge branch 'master' into returnValueSurmise
Kingwl Mar 4, 2020
eabc5a4
Merge branch 'master' into returnValueSurmise
Kingwl Mar 4, 2020
944ddf4
Avoid replace brace with paren
Kingwl Mar 18, 2020
6c88a01
Split fix all action
Kingwl Mar 18, 2020
94f845a
Add return work in same line
Kingwl Mar 18, 2020
a7f37a3
Merge branch 'master' into returnValueSurmise
Kingwl Mar 18, 2020
7fe9a82
fix test cases
Kingwl Mar 18, 2020
af9552e
rename baseline
Kingwl Mar 26, 2020
601fc5e
refactor and handle comment
Kingwl Mar 26, 2020
175cf4e
Support semi
Kingwl Mar 26, 2020
8b332fe
Merge branch 'master' into returnValueSurmise
Kingwl Mar 26, 2020
5d8355c
make helper internal
Kingwl Mar 26, 2020
522cac8
Merge branch 'master' into returnValueSurmise
Kingwl Apr 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix changed diagnosis
  • Loading branch information
Kingwl committed Apr 30, 2019
commit cbe59bb06344958113b3e2a37f33edca95f41653
8 changes: 0 additions & 8 deletions src/services/codefixes/returnValueSurmise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ namespace ts.codefix {
if (!initializer || !isFunctionLikeDeclaration(initializer) || !initializer.body) return undefined;
return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true);
}

if (isDeclarationName(node) && (isVariableLike(node.parent) || isJsxAttribute(node.parent))) {
const initializer = getVariableLikeInitializer(node.parent);
if (!initializer || !isFunctionLikeDeclaration(initializer) || !initializer.body) return undefined;
return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true);
}
return undefined;
}

Expand All @@ -187,8 +181,6 @@ namespace ts.codefix {
case SyntaxKind.JSDocPropertyTag:
case SyntaxKind.JSDocParameterTag:
return undefined;
default:
Debug.fail("unexpected token");
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/cases/fourslash/codeFixSurmiseReturnValue18.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ verify.codeFixAvailable([
{ description: 'Add a return statement' },
{ description: 'Remove block body braces' },
{ description: 'Replace braces with parentheses' },
{ description: `Infer type of 'props' from usage` }
]);
1 change: 1 addition & 0 deletions tests/cases/fourslash/codeFixSurmiseReturnValue19.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

verify.codeFixAvailable([
{ description: 'Wrap this block with parentheses' },
{ description: `Infer type of 'props' from usage` },
{ description: 'Remove unused label' },
]);
1 change: 1 addition & 0 deletions tests/cases/fourslash/codeFixSurmiseReturnValue20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ verify.codeFixAvailable([
{ description: 'Add a return statement' },
{ description: 'Remove block body braces' },
{ description: 'Replace braces with parentheses' },
{ description: `Infer type of 'props' from usage` },
{ description: 'Remove unused label' },
]);
10 changes: 2 additions & 8 deletions tests/cases/fourslash/codeFixSurmiseReturnValue_all1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
//// const baz5: ((() => number) | (() => A)) = () => {
//// bar: '1'
//// }
////
//// const test: { a: A } = { a: () => { bar: '1' } }

verify.codeFixAll({
fixId: "fixAddReturnStatement",
Expand Down Expand Up @@ -113,9 +111,5 @@ const baz4: ((() => number) | (() => A)) = () => {
}
const baz5: ((() => number) | (() => A)) = () => {
return { bar: '1' };
}

const test: { a: A } = { a: () => {
return { bar: '1' };
} }`,
});
}`,
});
6 changes: 1 addition & 5 deletions tests/cases/fourslash/codeFixSurmiseReturnValue_all2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
//// const baz5: ((() => number) | (() => A)) = () => {
//// bar: '1'
//// }
////
//// const test: { a: A } = { a: () => { bar: '1' } }

verify.codeFixAll({
fixId: "fixRemoveBlockBodyBrace",
Expand Down Expand Up @@ -93,7 +91,5 @@ const baz1: () => number = () => 1
const baz2: () => A = () => ({ bar: '1' })
const baz3: () => A = () => ({ bar: '1' })
const baz4: ((() => number) | (() => A)) = () => 1
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })

const test: { a: A } = { a: () => ({ bar: '1' }) }`,
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })`,
});
6 changes: 1 addition & 5 deletions tests/cases/fourslash/codeFixSurmiseReturnValue_all3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
//// const baz5: ((() => number) | (() => A)) = () => {
//// bar: '1'
//// }
////
//// const test: { a: A } = { a: () => { bar: '1' } }

verify.codeFixAll({
fixId: "fixReplaceBraceWithParen",
Expand Down Expand Up @@ -93,7 +91,5 @@ const baz1: () => number = () => (1)
const baz2: () => A = () => ({ bar: '1' })
const baz3: () => A = () => ({ bar: '1' })
const baz4: ((() => number) | (() => A)) = () => (1)
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })

const test: { a: A } = { a: () => ({ bar: '1' }) }`,
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })`,
});
6 changes: 1 addition & 5 deletions tests/cases/fourslash/codeFixSurmiseReturnValue_all4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
//// const baz5: ((() => number) | (() => A)) = () => {
//// bar: '1'
//// }
////
//// const test: { a: A } = { a: () => { bar: '1' } }

verify.codeFixAll({
fixId: "fixWrapTheBlockWithParen",
Expand Down Expand Up @@ -93,7 +91,5 @@ const baz1: () => number = () => (1)
const baz2: () => A = () => ({ bar: '1' })
const baz3: () => A = () => ({ bar: '1' })
const baz4: ((() => number) | (() => A)) = () => (1)
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })

const test: { a: A } = { a: () => ({ bar: '1' }) }`,
const baz5: ((() => number) | (() => A)) = () => ({ bar: '1' })`,
});