-
Notifications
You must be signed in to change notification settings - Fork 12.8k
language service warns about ES private field emit in declaration files (#private
)
#36963
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
Comments
#private
in declaration files leads to language service warnings
#private
in declaration files leads to language service warnings#private
)
@mheiber I think in your first example the emit should not include export declare class A {
#private; // two language service warnings here
constructor();
} That's what I get when trying to repro this, at least. |
The implicit any error was fixed in #36640. I note that the language service puts this warning on lots of different ambient declarations: export declare class AA {
#private; // warning
private y; // warning
x: number; // ok
constructor();
}
declare class BB { // warning
x: number // ok
} I don't think this is worth a patch fix since it's just a language service warning, and one people have been living with on (Also there is an almost-done version of the playground that does have dts output: https://www.typescriptlang.org/v2/en/play. I'm not sure if the url reflects which output tab is selected. However, the playground doesn't request or show suggestion diagnostics, so it's still not usable to repro this.) |
@
That's right, I pasted wrong. Thanks for checking. |
Thanks @sandersn ! |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.9.0-dev.20200222
Search Terms:
private fields, es private fields, declaration files
Code
Expected behavior:
npx typescript@next 1.ts --target esnext --declaration
should produce a declaration file that the language service doesn't complain about.Actual behavior:
The language service complains about the following issues in the declaration file:
Playground Link:
Can't do, since the playground doesn't yet support dts generation
Suggested solution
To get rid of the warning about implicit any, we could change the emit to:
To get rid of the warning about an unused variable, we could update the language service to never warn on unused private fields in declarations. I think this rule would ideally be applied for declarations anywhere (not just in declaration files), since the use cases for forcing nominality are probably the same in .ts files.
Happy to implement!
The text was updated successfully, but these errors were encountered: