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

private class field declaration generates #private in dts #38050

Closed
dnalborczyk opened this issue Apr 19, 2020 · 2 comments
Closed

private class field declaration generates #private in dts #38050

dnalborczyk opened this issue Apr 19, 2020 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@dnalborczyk
Copy link

dnalborczyk commented Apr 19, 2020

TypeScript Version: 3.8.3 and v3.9.0 nightly

repro:

// ts
class FooBar {
    #foo = 'foo'

    bar() {
        return this.#foo
    }
}

Expected behavior:

// dts
declare class FooBar {
    bar(): string;
}

Actual behavior:

// dts
declare class FooBar {
    #private;
    bar(): string;
}

playground:
https://www.typescriptlang.org/play?ts=3.9.0-dev.20200418#code/MYGwhgzhAEBiD28BCYBO0DeAoavoGIAzRaAXmgHJj4Ksc8AjNACgEpN689UBTAFwCuqAHbQ+ACwCWEAHRFEnaAF8sSoA

Related Issues:
#36963
#36640
#36630

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 20, 2020
@RyanCavanaugh
Copy link
Member

This is the intended behavior so that classes with #p private fields retain their nominal typing behavior when emitted to a .d.ts file

@pikadun
Copy link

pikadun commented May 18, 2020

@RyanCavanaugh

I used a npm package with d.ts containing #private, the compiler issues some errors, such as : '#private' is declared here., Property '#private' is missing in type xxx.

The #private in lib/api/Element.d.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants