Skip to content

Nested class's private field has inconsistent name in declaration file under watch mode #47490

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

Closed
alvinleung1996 opened this issue Jan 18, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@alvinleung1996
Copy link

Bug Report

πŸ”Ž Search Terms

private field declaration

πŸ•— Version & Regression Information

v3.8.3, v4.5.4, v4.6.0-dev.20220116

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

export function func() {
    return class A {
        #field = ''
    }
}

πŸ™ Actual behavior

In watch mode, the name of the private field in the declaration file is not consistent after rebuild.

The initial build emits the following declaration:

export declare function func(): {
    new (): {
        "__#1@#field": string;
    };
};

Do some changes in the source file, for example:

export function func() {
    return class A {
        #field = 'a'
    }
}

The output becomes:

export declare function func(): {
    new (): {
        "__#12@#field": string;
    };
};

Undo the change. The output becomes:

export declare function func(): {
    new (): {
        "__#16@#field": string;
    };
};

The number in the emitted private field name seems to increase after each rebuild.

πŸ™‚ Expected behavior

The emitted private field name is consistent across rebuild and should be named #private.

export declare function func(): {
    new (): {
        #private;
    };
};
@MartinJohns
Copy link
Contributor

MartinJohns commented Jan 18, 2022

Duplicate of #36548. Used search terms: private emit in:title

Technically your bug is about the identifier changing, the other not... but the identifier being in that format is the actual bug.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 18, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants