-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68dae7b
commit 87f806c
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
output = "../target/string" | ||
} | ||
|
||
generator json { | ||
provider = "node ./index.js" | ||
namespace = "PStringJson" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = "" | ||
} | ||
|
||
model Model { | ||
id Int @id @default(autoincrement()) | ||
untyped String | ||
/// [WithType] | ||
typed String | ||
/// !['A' | 'B'] | ||
literal String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,6 @@ model Model { | |
id Int @id @default(autoincrement()) | ||
field Json | ||
str String | ||
int Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expectNotType, expectType } from 'tsd'; | ||
import { Model } from '../target/string/index'; | ||
|
||
declare global { | ||
export namespace PStringJson { | ||
type WithType = 'C' | 'D'; | ||
} | ||
} | ||
|
||
expectType<Model>({ | ||
id: 0, | ||
untyped: '' as string, | ||
typed: 'C' as PStringJson.WithType, | ||
literal: 'A' as 'A' | 'B' | ||
}); | ||
|
||
expectNotType<Model>({ | ||
id: 0, | ||
untyped: 'Mesquita' as string, | ||
typed: 'D' as string, | ||
literal: 'D' as string | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters