Skip to content

Commit

Permalink
another expect statement
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Oct 11, 2024
1 parent b5670e2 commit b2c6186
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prisma-old/generated/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {type a,b} from './types'

type asd= a.TestUser

const c = b.C
19 changes: 19 additions & 0 deletions prisma-old/generated/types copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { ColumnType } from "kysely";

export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export type Timestamp = ColumnType<Date, Date | string, Date | string>;

export type Eagle = {
id: number;
name: string;
};
export type Elephant = {
id: number;
name: string;
};
export type DB = {
"birds.eagles": Eagle;
"mammals.elephants": Elephant;
};
32 changes: 32 additions & 0 deletions prisma-old/generated/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { ColumnType } from "kysely";

export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export type Timestamp = ColumnType<Date, Date | string, Date | string>;

export const Ability = {
FLY: "FLY",
WALK: "WALK",
} as const;
export type Ability = (typeof Ability)[keyof typeof Ability];
export const Color = {
GRAY: "GRAY",
PINK: "PINK",
} as const;
export type Color = (typeof Color)[keyof typeof Color];
export type Eagle = {
id: number;
name: string;
ability: Generated<Ability>;
};
export type Elephant = {
id: number;
name: string;
ability: Generated<Ability>;
color: Color;
};
export type DB = {
"birds.eagles": Eagle;
"mammals.elephants": Elephant;
};
43 changes: 43 additions & 0 deletions prisma-old/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
generator kysely {
provider = "node ./dist/bin.js"
previewFeatures = ["multiSchema"]
}

datasource db {
provider = "postgresql"
schemas = ["mammals", "birds", "world"]
url = env("TEST_DATABASE_URL")
}

model Elephant {
id Int @id
name String
ability Ability @default(WALK)
color Color
@@map("elephants")
@@schema("mammals")
}

model Eagle {
id Int @id
name String
ability Ability @default(FLY)
@@map("eagles")
@@schema("birds")
}

enum Ability {
FLY
WALK
@@schema("world")
}

enum Color {
GRAY
PINK
@@schema("mammals")
}
3 changes: 3 additions & 0 deletions src/__test__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ enum Color {
expect(typeFile).toContain(`export namespace Mammals {
export const Color = {`);

// correctly references the color enum
expect(typeFile).toContain("color: Mammals.Color;");

expect(typeFile).toContain(`export type DB = {
"birds.eagles": Birds.Eagle;
"mammals.elephants": Mammals.Elephant;
Expand Down

0 comments on commit b2c6186

Please sign in to comment.