Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Breaking: Include type annotation range for Identifiers (fixes #314) #319

Merged
merged 2 commits into from
Jul 10, 2017

Conversation

soda0289
Copy link
Member

@soda0289 soda0289 commented Jun 9, 2017

I changed range of Identifier nodes used in variable declaration and function parameters. Its a simple change but I might have missed something.

@soda0289 soda0289 requested a review from JamesHenry June 9, 2017 04:01
@eslintbot
Copy link

LGTM

@JamesHenry
Copy link
Member

JamesHenry commented Jun 18, 2017

I got chance to dig into this today, and we still have a fundamental difference in how we conclude ranges for typeAnnotations vs how Flow does it for the same source.

Take this example:

let x   :      string;

Flow has the following ranges:
screen shot 2017-06-18 at 18 22 43

Whereas in this PR we currently have:

screen shot 2017-06-18 at 18 30 01

I have a fix for this when it comes to VariableDeclarations (building on this PR) so I'll just push it up for your review @soda0289.

We'll likely be able to turn it into a utility function and apply it to other constructs with typeAnnotations as well

@eslintbot
Copy link

LGTM

@JamesHenry JamesHenry force-pushed the identifier-range-include-type-annotation branch from 2ec1b95 to 92fab2e Compare June 18, 2017 17:44
@eslintbot
Copy link

LGTM

@JamesHenry
Copy link
Member

I rebased against master as it was a little bit behind

@soda0289
Copy link
Member Author

Thanks for looking into this. Just to confirm the change now uses the colon token as the initial start value of the type annotation node.

@JamesHenry
Copy link
Member

@soda0289 Yes, purely based on Flow's precedent of doing that

@JamesHenry
Copy link
Member

Based on a really quick check, it seems like this change will not require any updates to prettier which is a bonus.

@JamesHenry
Copy link
Member

@Andy-MS Please could you take a look at this also? This would be a solution to https://github.com/JamesHenry/tsep-babylon-test/issues/19

See above for the precedent set by flow, I think it differs slightly from babylon's current output

@soda0289
Copy link
Member Author

I have not tested this with eslint yet, not sure if any rules will fail. Will try it out tonight

@JamesHenry
Copy link
Member

@soda0289 Did you get chance to try it out? How did/were you planning on evaluating it out of interest? Do you have a particular repo set up?

@soda0289
Copy link
Member Author

Sorry forgot about this. Was a little busy last week. I have several repos at work that I can run this change under and make sure there are no crashes or false positives.

@soda0289
Copy link
Member Author

@JamesHenry
This does cause an issue with the eslint-plugin-typescript. The rule typescript/type-annotation-spacing has false positives. Which makes sense since we are changing how the type annotation range is calculated.

@JamesHenry
Copy link
Member

I think that plugin currently has a number of issues right? I would think it should be pretty straightforward to fix

@soda0289
Copy link
Member Author

Yes the plugin does have several issues. Should be good to merge this too.

@JamesHenry JamesHenry force-pushed the identifier-range-include-type-annotation branch from 92fab2e to b4fc319 Compare July 10, 2017 17:41
@eslintbot
Copy link

LGTM

@JamesHenry JamesHenry merged commit 6a612cd into master Jul 10, 2017
@JamesHenry JamesHenry deleted the identifier-range-include-type-annotation branch July 10, 2017 17:47
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