Closed
Description
TypeScript Version: 3.3.3333
Code
src/test.ts:
export function test () {
return class {
private privateMember () {
}
};
}
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:
export function test (): new() => Object {
return class {
private privateMember () {
}
};
}