Skip to content

add code fix convert to mapped object type#24286

Merged
5 commits merged into
microsoft:masterfrom
Kingwl:quick-fix-mapped-object-type
May 23, 2018
Merged

add code fix convert to mapped object type#24286
5 commits merged into
microsoft:masterfrom
Kingwl:quick-fix-mapped-object-type

Conversation

@Kingwl

@Kingwl Kingwl commented May 21, 2018

Copy link
Copy Markdown
Contributor

Fixes #24220

@Kingwl Kingwl changed the title add code fix convert to mapped object type [WIP] add code fix convert to mapped object type May 21, 2018
@Kingwl Kingwl changed the title [WIP] add code fix convert to mapped object type add code fix convert to mapped object type May 22, 2018
@Kingwl

Kingwl commented May 22, 2018

Copy link
Copy Markdown
Contributor Author

some formatting issue with #24312

@mhegazy mhegazy requested a review from a user May 22, 2018 17:09
@mhegazy

mhegazy commented May 22, 2018

Copy link
Copy Markdown
Contributor

@Andy-MS can you please review this change.


function getFixableSignatureAtPosition(sourceFile: SourceFile, pos: number): Info | undefined {
const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
if (!isIndexSignatureParameterName(token)) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that microsoft/vscode#45785 is fixed, might as well just assert these things as you go, which could save you some casts.
The only time this shouldn't be fixable is in a class, right? So in getCodeActions, all we should need to determine whether it's fixable is whether token.parent.parent.parent is a class?

@Kingwl Kingwl May 23, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, in my memory, i have not to use assert or cast (almost) 😬

@Kingwl Kingwl May 23, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after thinking and search, This may exceed my expectations 😢

@Kingwl Kingwl force-pushed the quick-fix-mapped-object-type branch from e6ebb58 to 7f4aeee Compare May 23, 2018 02:05
@ghost

ghost commented May 23, 2018

Copy link
Copy Markdown

Thanks!

@ghost ghost merged commit 4606709 into microsoft:master May 23, 2018
@Kingwl Kingwl deleted the quick-fix-mapped-object-type branch May 23, 2018 23:46
@dannycochran

Copy link
Copy Markdown

Can this be merged into 2.9 or 2.9.1? It'd be nice to have in 2.9 to line up with the current release notes which make me expect that this would be supported.

@mhegazy

mhegazy commented May 25, 2018

Copy link
Copy Markdown
Contributor

No, this will be available in TypeScript 3.0 in two month, or in typescript@next coming out later tonight.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants