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

Missing readonly and declare in ClassMethod and TSMethodSignature #9760

Closed
fisker opened this issue Nov 24, 2020 · 3 comments
Closed

Missing readonly and declare in ClassMethod and TSMethodSignature #9760

fisker opened this issue Nov 24, 2020 · 3 comments
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@fisker
Copy link
Member

fisker commented Nov 24, 2020

Prettier 2.2.1
Playground link

--parser typescript

Input:

class C {
  readonly *e() {}
  declare *f() {}
}

interface Foo {
  declare e();
  abstract f();
}

Output:

class C {
  *e() {}
  *f() {}
}

interface Foo {
  e();
  f();
}

Expected behavior:

class C {
  readonly *e() {}
  declare *f() {}
}

interface Foo {
  declare e();
  abstract f();
}

Update

Expected behavior:

Throw SyntaxError.

@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Nov 24, 2020
@brodybits
Copy link
Contributor

Playground link

Same output comes from both typescript and babel-ts parsers (other JavaScript parsers signal a syntax error).

Background is in PR #9748 & typescript-eslint/typescript-eslint#2908.

I gather that the testing with AST_COMPARE=1 does not show an issue because the attributes are not present in the AST coming either from babel-ts or typescript parser.

@fisker
Copy link
Member Author

fisker commented Dec 31, 2020

I gather that the testing with AST_COMPARE=1 does not show an issue because the attributes are not present in the AST

#9768

@fisker fisker changed the title Missing readonly and declare in ClassMethod Missing readonly and declare in ClassMethod and TSMethodSignature Feb 25, 2021
@fisker
Copy link
Member Author

fisker commented Apr 25, 2021

Invalid declare on accessors not throwing, should be the same problem. babel-ts fixed this in #10750.

Prettier 2.2.1
Playground link

--parser typescript

Input:

class Foo {
  declare get foo()
  declare set foo(v)
}

Output:

class Foo {
  get foo();
  set foo(v);
}

@fisker fisker closed this as completed in f8f0c41 Mar 27, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2023
medikoo pushed a commit to medikoo/prettier-elastic that referenced this issue Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants