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

Syntax error in emitted output from tsc when exporting value of symbol key #43154

Open
laverdet opened this issue Mar 9, 2021 Β· 2 comments
Open

Syntax error in emitted output from tsc when exporting value of symbol key #43154

laverdet opened this issue Mar 9, 2021 Β· 2 comments

Comments

@laverdet
Copy link
Contributor

@laverdet laverdet commented Mar 9, 2021 β€’

Bug Report

πŸ”Ž Search Terms

syntax error tsc declaration class symbol TS1003 Identifier expected

πŸ•— Version & Regression Information

Every version from 3.3.3 - 4.2.3 and nightly

  • This is a crash

⏯ Playground Link

https://www.typescriptlang.org/play?ts=4.3.0-dev.20210308#code/MYewdgzgLgBAyjAvPAngWwEYgDYAoCUA3AFDDYCGEEMAYiCDAN7EyszTlQCWwMA2nAC6BRgF9i4gKYAPAA4gATrFCRYaSVAAWIACZJa9AYMJA

πŸ’» Code

const S = Symbol();
class Foo {
    static [S](){}
}
export const method = Foo[S];

πŸ™ Actual behavior

Output of the d.ts follows:

declare const S: unique symbol;
declare class Foo {
    static [S](): void;
}
export declare const method: typeof Foo.[S];
export {};

There is a syntax error on line 5: typeof Foo.[S]

πŸ™‚ Expected behavior

A dot should not be emitted when the key is a symbol

@laverdet
Copy link
Contributor Author

@laverdet laverdet commented Mar 15, 2021

@a-tarasyuk thanks for taking a look at this. I noticed another issue with the emitter that will cause a syntax error:

const S = '#foo' as const;
class Foo {
    static [S](){}
}
export const method = Foo[S];

This emits: export declare const method: typeof Foo.#foo; which of course needs to be quoted.

@vimark1
Copy link

@vimark1 vimark1 commented Jun 10, 2021

This is still an issue in main (4903c64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants