Effect CommunityEC
Effect Community2y ago
7 replies
Guido

Extracting TypeScript Types from Schema Definitions in TypeScript

hi! maybe this isn't good practice, but is there a way of pulling this type (see ts type) from something like this (see schema):

{success: true, projectId: string} | {success: false}


const CreateTeamsSolutionResponseDataSchema = Schema.Union(
  Schema.Struct({
    success: Schema.Literal(true),
    projectId: Schema.String,
  }),
  Schema.Struct({
    success: Schema.Literal(false),
  }),
);


(i accept better practices suggestions, but i need to extract that type with Schema.Schema.Type<typeof CreateTeamsSolutionRequestDataSchema>)
Was this page helpful?