MCPcopy
hub / github.com/prisma/prisma / toTS

Method toTS

packages/client-generator-ts/src/TSClient/Enum.ts:21–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 }
20
21 public toTS(): string {
22 const { type } = this
23
24 const enumVariants = `{
25${indent(type.values.map((v) => `${v}: ${this.getValue(v)}`).join(',\n'), TAB_SIZE)}
26} as const`
27 const enumBody = this.isStrictEnum() ? `runtime.makeStrictEnum(${enumVariants})` : enumVariants
28
29 return `export const ${type.name} = ${enumBody}
30
31export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]\n`
32 }
33
34 private getValue(value: string): string {
35 return this.isObjectEnum() ? value : `'${value}'`

Callers

nothing calls this directly

Calls 2

getValueMethod · 0.95
isStrictEnumMethod · 0.95

Tested by

no test coverage detected