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
Let me reproduce the issue first.
- Assistant
Reproduced. Now let's find where the error is raised.
- Assistant
Let me look at where
pseudoTypeEquivalentToTypeis called and howtypeFromFunctionLikeExpressionbuilds signatures: - Assistant
Let me confirm the function-expression variant is also affected:
- Assistant
Now add the helper functions:
- Assistant
Now run the full test suite to check for regressions in existing baselines:
- Assistant
That was suspiciously fast — the submodule tests may be skipped. Let me check:
- Assistant
The submodule tests are skipped because the TypeScript submodule isn't cloned. Network access worked for Go modules, so let me clone it to run the full conformance suite:
- Assistant
That's a sandbox process limit issue (fork/exec failures), not test failures. Retry with limited parallelism:
- Assistant
All tests pass. Let me review the final diff:
- Assistant
The fix is complete. Summary of what was done:
Problem
tsgoreported a falseTS9008: Method must have an explicit return type annotation with --isolatedDeclarationsfor fully-annotated methods/function expressions with athisparameter, e.g.:export function fromProviders<T>() { return { tearDown(this: {state: T}): void {} }; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.