Skip to content

Typescript: Keep question mark for optional computed class property#6601

Closed
fisker wants to merge 2 commits intoprettier:masterfrom
fisker:ts-optional-computed-class-prop
Closed

Typescript: Keep question mark for optional computed class property#6601
fisker wants to merge 2 commits intoprettier:masterfrom
fisker:ts-optional-computed-class-prop

Conversation

@fisker
Copy link
Copy Markdown
Member

@fisker fisker commented Oct 3, 2019

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • (If the change is user-facing) I’ve added my changes to the CHANGELOG.unreleased.md file following the template.
  • I’ve read the contributing guidelines.

Try the playground for this PR

fix #6569

this is a bug from @typescript-eslint/typescript-estree typescript-eslint/typescript-eslint#1019 , add a test to confirm this works

Notice: @typescript-eslint/typescript-estree@2.3.2 requires node >=8 , so this PR might can't merge until prettier@2

@alexander-akait
Copy link
Copy Markdown
Member

@fisker it is better to avoid PRs for 2 branch now, since we didn’t even start it, better fix bugs

@fisker fisker force-pushed the ts-optional-computed-class-prop branch from ad9d93d to 2d16647 Compare October 3, 2019 18:43
@fisker
Copy link
Copy Markdown
Member Author

fisker commented Oct 3, 2019

@evilebottnawi How about the idea of using a fork version of @typescript-eslint/typescript-estree that supports old node version, if this is OK, i will try to improve the fork

@sosukesuzuki
Copy link
Copy Markdown
Contributor

Personally, considering the maintenance cost of the fork, it is better to hurry for major updates for us.

@alexander-akait
Copy link
Copy Markdown
Member

alexander-akait commented Oct 4, 2019

@fisker it is problem not only for typescript, other packages also can require node@8, I think we should talk about it and choose the best strategy.

@thorn0
Copy link
Copy Markdown
Member

thorn0 commented Oct 15, 2019

? is still lost if the key is an expression. The AST doesn't even contain the relevant info.

Prettier pr-6601
Playground link

--parser typescript

Input:

class Foo {
    [Symbol.bar]?();
}

Output:

class Foo {
  [Symbol.bar]();
}

@Lodin
Copy link
Copy Markdown

Lodin commented Oct 16, 2019

@fisker, probably, my issue is connected with the one you are fixing in this PR. Could you also take a look at it? I tried it in the PR playground but the issue is still reproducible.

@fisker fisker closed this Oct 17, 2019
@sosukesuzuki
Copy link
Copy Markdown
Contributor

@thorn0 I think this problem caused by parser side.

@Lodin I think your issue is not related to this PR. Probably, it is other problem, so we can fix your issue without updating typescript-estree.

@thorn0
Copy link
Copy Markdown
Member

thorn0 commented Oct 17, 2019

#6673 fixes @Lodin 's issue, but only for simple cases where the key is a simple identifier (variable). Cases where the key is a more complex expression indeed require an update of typescript-estree to be fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Typescript] Prettier removes question mark from optional computed class property

5 participants