ISSUE DESCRIPTION New isolatedDeclarations error with generic this parameter inference…
- User
ISSUE DESCRIPTION
New isolatedDeclarations error with generic
thisparameter inferenceSteps to reproduce
typescriptexport function fromProviders<T>() { return { tearDown(this: {state: T}): void {} }; }Behavior with
typescript@6.0no error, .d.ts emitted is:
typescriptexport declare function fromProviders<T>(): { tearDown(this: { state: T; }): void; };Behavior with
tsgocodeerror TS9008: Method must have an explicit return type annotation with --isolatedDeclarations.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted. Assistant
Build succeeded. Now run it on repro.
Assistant
Line 446 is in PseudoObjectElementKindMethod within equivalence check (the one we found around 446-472), and line 524 is PseudoTypeKindSingleCallSignature in equivalence check. Let's view exact lines to edit.
Assistant
Now let's write the fix. I'll add a helper function to strip/compare the
thisparameter, then apply it in both places (method case and single-call-signature case).Assistant
Now insert new helper functions right before
isStructuralPseudoType:Assistant
Now let's build and re-run repro.
Assistant
Build succeeded (no errors output). Let's rebuild tsgo binary and test.
Assistant
Fixed. Now let's test edge cases: function expression with explicit
thisparameter, arrow function returning object with method withthisparam but mismatched type (should still error), and a case wherethistype doesn't match (to confirm error still correctly reported).Assistant
Let's check for a compiler test runner package (e.g.,
internal/testrunneror similar) that runs baseline compiler tests, and see if it can run without submodule.Assistant
All correct: optional/rest params after
thiswork fine, and legitimately-needed errors still fire correctly.Now let's run broader Go test suite to check nothing else broke.
Assistant
All tests pass. Let's view the final diff.
Assistant
Now let's re-verify the original issue reproduction once more with a fresh build, and clean up temp files.
Assistant
Matches expected output from the issue exactly, and exits cleanly.
Assistant
Only the intended file is modified. Let's go through the checklist:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.