Skip to content

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

Closed
@alvinleung1996

Description

@alvinleung1996

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;
    };
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions