Skip to content

make trackedTask infer the return type correctly#188

Open
emattias wants to merge 1 commit intouniversal-ember:mainfrom
emattias:fix-tracked-task-return-inference
Open

make trackedTask infer the return type correctly#188
emattias wants to merge 1 commit intouniversal-ember:mainfrom
emattias:fix-tracked-task-return-inference

Conversation

@emattias
Copy link
Copy Markdown

fixes #84

  • typeScript infers generics left to right. Return appears first, but nothing in the parameter positions directly constrains it — it only appears indirectly inside the constraint of LocalTask. TypeScript can't "reverse-infer" Return from LocalTask's constraint, so it falls back to the default unknown
  • the fix is add an overload that removes Return and Args as independent generics and instead extract them from LocalTask using conditional types

- typeScript infers generics left to right. Return appears first, but nothing in the parameter positions directly constrains it — it only appears indirectly inside the constraint of LocalTask. TypeScript can't "reverse-infer" Return from LocalTask's constraint, so it falls back to the default unknown
- the fix is add an overload that removes Return and Args as independent generics and instead extract them from LocalTask using conditional types
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

@emattias is attempting to deploy a commit to the universal-ember Team on Vercel.

A member of the Team first needs to authorize it.

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

Any ideas for a type test to ensure this doesn't regress?

@emattias
Copy link
Copy Markdown
Author

Not sure, are there other type tests?

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

looks like not in the traditional sense (separate project with expect-type), but this repo has a lint:types in each project, which you could use in the tests/vite-app for examplee -- make a ts file that creates the situation that failed before with type checking, and hope that your change makes typechecking succeed (you can still add eexpect type if you perefr to use that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

restartableTask Should Populate Existing Task Types

2 participants