Skip to content

How to make only some props optional #1125

Answered by sinclairzx81
psi-4ward asked this question in Q&A
Discussion options

You must be logged in to vote

@psi-4ward Hi, Try the following

TypeScript Link Here

import { Type } from '@sinclair/typebox'

// ----------------------------------------------------------------
// TypeScript
// ----------------------------------------------------------------

type Composite<T> = {[K in keyof T]: T[K]} & {} // replicate TB composite

type FileSelect = {
  id: string,
  created_at: number
  updated_at: number
  contentType: string
  filename: string
  description: string
}

type FileInsert = Composite<
  Omit<FileSelect, 'id' | 'created_at' | 'updated_at' | 'contentType'> &
  Partial<Pick<FileSelect, 'contentType'>>
>



// ----------------------------------------------------------------
// TypeBox
// -…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@psi-4ward
Comment options

Answer selected by psi-4ward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants