Skip to content

Instantly share code, notes, and snippets.

@anztrax
Created December 1, 2025 02:47
Show Gist options
  • Select an option

  • Save anztrax/cd00a5538912bf7afdf805dc32c03a45 to your computer and use it in GitHub Desktop.

Select an option

Save anztrax/cd00a5538912bf7afdf805dc32c03a45 to your computer and use it in GitHub Desktop.
Simple implementation of Readonly + Exclude in Typescript
type MyReadonly2<T, K extends keyof T = keyof T> = {
readonly [P in K] :T[P]
} & {
[P in keyof T as P extends K ? never : P] : T[P]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment