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

Breaking: Convert Signature types to be more ESTree like (fixes #262) #264

Merged
merged 4 commits into from
May 28, 2017

Conversation

soda0289
Copy link
Member

@soda0289 soda0289 commented May 7, 2017

I noticed that optional is used twice. Once in identifier and once in the TSPropertySignature. Maybe we should clean that up.

Here is what this produces:
#262 (comment)

@eslintbot
Copy link

LGTM

@soda0289 soda0289 force-pushed the fix-computed-property branch from 5421cea to ddeaaea Compare May 8, 2017 00:12
@eslintbot
Copy link

LGTM

@soda0289
Copy link
Member Author

soda0289 commented May 8, 2017

We can move optional and computed to the Identifier node. I think that might make more sense

@@ -0,0 +1,15 @@
interface Foo {
Copy link
Member

Choose a reason for hiding this comment

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

A number of these aren't semantically valid TypeScript, but I guess we are further evaluating errorRecovery here, so it should be ok

Copy link
Member Author

Choose a reason for hiding this comment

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

I can split them into two test. Not sure which ones are invalid exactly but I think the computed property don't make sense in interfaces.

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

LGTM overall. Are you planning any more breaking changes after this?

It would be great if we could have a period of stability to allow for the prettier implementation to catch up a bit.

We done a lot of breaking changes recently (albeit a lot of those were in response to prettier issues 😄 )

lib/convert.js Outdated
case SyntaxKind.MethodSignature: {
Object.assign(result, {
type: AST_NODE_TYPES.TSMethodSignature,
optional: (node.questionToken) ? (node.questionToken.kind === SyntaxKind.QuestionToken) : false,
Copy link
Member

Choose a reason for hiding this comment

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

Worth a util function?

lib/convert.js Outdated
Object.assign(result, {
type: AST_NODE_TYPES.TSMethodSignature,
optional: (node.questionToken) ? (node.questionToken.kind === SyntaxKind.QuestionToken) : false,
computed: node.name.kind === SyntaxKind.ComputedPropertyName,
Copy link
Member

Choose a reason for hiding this comment

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

Worth a util function?

@soda0289
Copy link
Member Author

@JamesHenry Thanks for the review. Will make the changes.

The only other breaking changes we could do are:

@eslintbot
Copy link

LGTM

@soda0289
Copy link
Member Author

I added two functions to node-utils:

  • isComputedProperty()
  • isOptional()

@JamesHenry
Copy link
Member

Again, just want to check how/if the AST alignment work affects this?

@soda0289
Copy link
Member Author

I need to change this so that only optional and typeAnnoations appear on Identifier node. Everything else should be on parent node.

@JamesHenry
Copy link
Member

I think we should look to finalise this after #292 gets resolved right?

@soda0289 soda0289 force-pushed the fix-computed-property branch from fa7e22a to a361063 Compare May 28, 2017 18:04
@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@soda0289
Copy link
Member Author

@JamesHenry Should be good.

@JamesHenry
Copy link
Member

This LGTM, @vjeux there are a lot of changes here, would you mind just confirming that this is all what you are expecting?

@vjeux
Copy link

vjeux commented May 28, 2017

Yup, I actually made prettier use this branch :) Shipit!

@JamesHenry JamesHenry merged commit dd6404a into master May 28, 2017
@JamesHenry JamesHenry deleted the fix-computed-property branch May 28, 2017 21:49
@JamesHenry
Copy link
Member

Thanks, chaps! Awesome work

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.

4 participants