Open
Description
Bug Report
π Search Terms
declaration emit this any
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
export function test() {
return {
relyingOnThis() {
return this;
},
};
}
// seen and recognized locally in TS files
test().relyingOnThis();
π Actual behavior
// generated .d.ts
export declare function test(): {
relyingOnThis(): any;
};
π Expected behavior
Make this
type to work in such contexts and emit that:
declare function test(): {
relyingOnThis(): this; // currently reports `A 'this' type is available only in a non-static member of a class or interface.(2526)`
};
Or emit the content of the anonymous type there somehow (when possible, be cautious with circularities, generics etc):
declare const _type: {
relyingOnThis(): typeof _type;
}
declare function test(): typeof _type
Or just emit a diagnostic that this isn't portable and that an explicit annotation is needed.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Symbol.observable
method in the generated.d.ts
solidjs/solid#1499