-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
Property of exported anonymous class type may not be private or protected
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
β― Playground Link
No response
π» Code
export function foo() {
return class X {
protected foo() {}
}
}π Actual behavior
test.ts:1:17 - error TS4094: Property 'foo' of exported anonymous class type may not be private or protected.
1 export function foo() {
~~~
Found 1 error in test.ts:1
π Expected behavior
In the .d.ts file, just add a temporary class to remove this bug...
Additional information about the issue
This bug was signaled ~6 years ago, but was closed: #30355
The following works:
class X {
protected foo() {}
}
export function foo() {
return X;
}It produces this .d.ts :
declare class X {
protected foo(): void;
}
export declare function foo(): typeof X;
export {}So for our case, just create a temporary class outside of foo() and use it...
declare class foo__internals__X {
protected foo(): void;
}
export declare function foo(): typeof foo__internals__X;
export {}trusktr
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created