Loading...
Loading...
Advanced TypeScript patterns for type-safe, maintainable code using sophisticated type system features. Use when building type-safe APIs, implementing complex domain models, or leveraging TypeScript's advanced type capabilities.
npx skill4agent add blockmatic/basilic-skills typescript-v6package.jsontypescript@typescript/typescript6npm view typescript@typescript/nativetsc"strict": trueesnextes2025"ignoreDeprecations": "6.0"value is Typeunknownanyas Typereadonly"strict": truetsconfig.jsonunknownanyvalue is Typetypeinterfacereadonlyanyunknownassert { type: ... }withtype Partial<T> = { [P in keyof T]?: T[P] }
type Readonly<T> = { readonly [P in keyof T]: T[P] }
type Pick<T, K extends keyof T> = { [P in K]: T[P] }function isString(value: unknown): value is string {
return typeof value === 'string'
}
function isSuccess(result: Result): result is Success {
return result.status === 'success'
}type UserId = string & { readonly __brand: 'UserId' }
type PostId = string & { readonly __brand: 'PostId' }
function createUserId(id: string): UserId {
return id as UserId
}type LoadingState =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: string[] }
| { status: 'error'; error: Error }