Skip to content

fix: variable inference under ts 5.7#86

Merged
spion merged 4 commits intomainfrom
fix/typescript-5.7-inference
Dec 28, 2024
Merged

fix: variable inference under ts 5.7#86
spion merged 4 commits intomainfrom
fix/typescript-5.7-inference

Conversation

@spion
Copy link
Copy Markdown
Collaborator

@spion spion commented Dec 27, 2024

Under compiler version 5.7.2 (or more specifically since PR microsoft/TypeScript#52095) TypeScript will more eagerly instantiate generic types when intersections are involved. This causes all variables in the generic input type in TGB to be inferred as having type unknown #85

To prevent this from happening, we insert a dummy conditional type that involves the generic type. This causes the compiler to defer instantiating the ExactArgNames restriction and instead use other types to do the generic inference, restoring correct variable type inference.

I feel that at this point we're too reliant on implementation details of the typescript compiler, and while this patch fixes the immediate problem, a response from the TypeScript team would be much appreciated to make better decisions on the direction going forward.

@spion spion merged commit 6026361 into main Dec 28, 2024
@spion spion deleted the fix/typescript-5.7-inference branch December 28, 2024 19:21
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 4.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant