Skip to content

Literal strings with generics are inconsistant when strictNullChecks is falseΒ #50787

Open

Description

Bug Report

πŸ”Ž Search Terms

  • string literal
  • strictNullChecks
  • keyof

πŸ•— Version & Regression Information

It works properly on v4.7.4 but is failing on v4.8.2 and with the nightly build.
It also works normally when strictNullChecks is true.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Model = { s: string; b: boolean }
let pick: <Keys extends keyof Model>(properties: readonly Keys[]) => Pick<Model, Keys>
let transform: <T>(obj: T) => T

const result1 = transform(pick(["s"]))

const intermediate = pick(["s"])
const result2 = transform(intermediate)

πŸ™ Actual behavior

result1 has a type of Pick<Model, keyof Model> and result2 as a type of Pick<Model, "s">

πŸ™‚ Expected behavior

result1 and result2 should have the same type Pick<Model, "s">.

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

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions