Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ts support for all optional keys in data model #5283

Conversation

jrozbicki
Copy link
Contributor

Closes #5272

Is object extends T different than T extends object?

Before: Following basic example, if Person had only optional fields DeepKeys would use object extends T and infer string

type Person = {
  firstName?: string
  lastName?: string
  age?: number
  visits?: number
  status?: string
  progress?: number
  address?: {
    city?: string
  }
}

type Test = DeepKeys<Person>
   // ^? type Test = string

After: When that got removed, the same case will fall under T extends object and will nicely infer key names.

type Person = {
  firstName?: string
  lastName?: string
  age?: number
  visits?: number
  status?: string
  progress?: number
  address?: {
    city?: string
  }
}

type Test = DeepKeys<Person>
   // ^? type Test = "firstName" | "lastName" | "age" | "visits" | "status" | "progress" | "address" | "address.city"

Did I missed something obvious? It was probably there for a reason

Copy link
Member

@KevinVandy KevinVandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this for a while, and it looks good. We can revert if something pops up

Copy link

nx-cloud bot commented Feb 28, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b4ea6f3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

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.

createColumnHelper loses typesafety when TData contains only optional fields
2 participants