Skip to content

False error TS4094: ... exported class expression may not be private or protected. #30355

Description

@a-student

TypeScript Version: 3.3.3333

Code

src/test.ts:

exportfunctiontest(){returnclass{privateprivateMember(){}};}

tsconfig.json:

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}

Expected behavior:
No compilation error.

Actual behavior:
Compiler prints error:
$ tsc
src/test.ts(1,17): error TS4094: Property 'privateMember' of exported class expression may not be private or protected.

Playground Link: not possible to provide.

Workaround

Declare the return type explicitly:

exportfunctiontest(): new()=>Object{returnclass{privateprivateMember(){}};}

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