microsoft / microsoft/TypeScript

Version 5.0.4 -> 5.1.3 Regression when using generic types

Open
#54,805 2 comments 4 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Jun 28, 2023.

Bug Domain: check: Type Inference Rescheduled
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

Generic, 5.1.3

🕗 Version & Regression Information
  • This changed between versions 5.0.4 and 5.1.3
⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.1.3#code/C4TwDgpgBAMhAeBLAxgQwDYGED2BbXqAdgCYA8AKgAqojrarEB8UAvFAEoTLYBOZAzsB6JCAcwA0UQhABuEHowDcAKGWhIUAJKF+84OQTBqtesVYcIDbIXQhSAbyjBDALiiDhYqAF8lqgGYAroTIwIjWUMg8ls44+ERk5IwAFACUbnBIaFh4BCQUzPbKUCVQ0cCBPIRQ9t4q3qrcOsBaAHIAygCi7OQA+uSdABp9mADyALLjAIKtACIZCCgYcXlk2ro8+obGdAzMLMWR0aixuQlpikA

💻 Code
type LexicalCommand<TPayload> = Record<string, never>;

type InsertTextPayload = Readonly<{ text: string }>;

function createCommand<T>(): LexicalCommand<T> {
    return {};
}

const INSERT_TEXT_COMMAND: LexicalCommand<InsertTextPayload> =
  createCommand();
🙁 Actual behavior

The type of INSERT_TEXT_COMMAND is LexicalCommand<TPayload> in 5.1.3 (but LexicalCommand<InsertTextPayload> in 5.0.4).

🙂 Expected behavior

The type of INSERT_TEXT_COMMAND should be LexicalCommand<InsertTextPayload>.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.