Skip to content

Private field has no type in declaration fileΒ #52127

Description

Bug Report

πŸ”Ž Search Terms

private declaration

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about and private fields

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

export class UiKitModule {
    private data: string = '123';
    private getData(params?: string): string {
        return this.data;
    }

    forRoot(params?: string): string {
        return this.getData(params) + '4';
    }
    forChild(params?: string): string {
        return this.getData(params) + '5';
    }
}

export class UiKitModuleNativePrivate {
    #data: string = '123';
    #getData(params?: string): string {
        return this.#data;
    }

    forRoot(params?: string): string {
        return this.#getData(params) + '4';
    }
    forChild(params?: string): string {
        return this.#getData(params) + '5';
    }
}

πŸ™ Actual behavior

// Output d.ts
export declare class UiKitModule {
    private data;
    private getData;
    forRoot(params?: string): string;
    forChild(params?: string): string;
}
export declare class UiKitModuleNativePrivate {
    #private;
    forRoot(params?: string): string;
    forChild(params?: string): string;
}

πŸ™‚ Expected behavior

// Output d.ts
export declare class UiKitModule {
    private data: string;
    private getData(params?: string): string;
    forRoot(params?: string): string;
    forChild(params?: string): string;
}
export declare class UiKitModuleNativePrivate {
    forRoot(params?: string): string;
    forChild(params?: string): string;
}

Activity

  1. changed the title [-]Private static field has no type in declaration file[/-] [+]Private field has no type in declaration file[/+] on Jan 6, 2023
  2. MartinJohns commented on Jan 6, 2023

    @MartinJohns
    Contributor

    This is intentional. In a declaration file the only thing matters is that there is a private property, the type is irrelevant.

  3. typescript-bot commented on Jan 8, 2023

    @typescript-bot
    Contributor

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

  4. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions