New isolatedDeclarations error with generic this parameter inference Steps to reproduce…
- User
New isolatedDeclarations error with generic
thisparameter inferenceSteps to reproduce
export function fromProviders<T>() { return { tearDown(this: {state: T}): void {} }; }Behavior with
typescript@6.0no error, .d.ts emitted is:
export declare function fromProviders<T>(): { tearDown(this: { state: T; }): void; };Behavior with
tsgoerror TS9008: Method must have an explicit return type annotation with --isolatedDeclarations.Interface
No new interfaces are introduced.
- Assistant
I’ll trace the isolated-declaration diagnostic path for object-literal methods with explicit
thisand return types, patch the inference check, then run the focused compiler tests. - Assistant
The failure comes from comparing the syntactic parameter list (which includes
this) against the checker signature’s ordinary parameters (which intentionally excludesthis). I’m updating both object-method and function-expression equivalence checks to validate the explicitthisparameter separately. - Assistant
The focused baseline now emits the expected
this: { state: T }declaration with no isolated-declarations error. I also added coverage for a normal parameter afterthisand for returned function expressions, since they use the same comparison machinery.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →