Skip to content
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

add code fix convert to mapped object type #24286

Merged
5 commits merged into from May 23, 2018

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented May 21, 2018

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
Copy link
Contributor Author

Kingwl commented May 22, 2018

some formatting issue with #24312

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

mhegazy commented May 22, 2018

@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

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?

Copy link
Contributor Author

@Kingwl Kingwl May 23, 2018

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) 😬

Copy link
Contributor Author

@Kingwl Kingwl May 23, 2018

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
Copy link

ghost commented May 23, 2018

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

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
Copy link
Contributor

mhegazy commented May 25, 2018

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.

None yet

3 participants