-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow up to #20150. Changes we did to extensions have fixed name clashes for models, but not for enums. Enums problem is more complicated: in case of name clash, it is impossible for contents of `Prisma` namespace to reference the value from outer scope. Solution is: all top-level enums are put into $Enums namespace. Types within `Prisma` namespace always refer to them using fully-qualifed name. Top-level enums are re-exported from `$Enums` namespace for backward compatiblity. Also, does opportunistic clean-ups/refactors Fix #20031
- Loading branch information
Showing
15 changed files
with
197 additions
and
122 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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
3 changes: 2 additions & 1 deletion
3
packages/client/src/generation/ts-builders/AnyDeclarationBuilder.ts
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { ConstDeclaration } from './ConstDeclaration' | ||
import { TypeDeclaration } from './TypeDeclaration' | ||
|
||
// TODO: enum, class, interface | ||
export type AnyDeclarationBuilder = TypeDeclaration | ||
export type AnyDeclarationBuilder = TypeDeclaration | ConstDeclaration |
20 changes: 20 additions & 0 deletions
20
packages/client/src/generation/ts-builders/ConstDeclaration.test.ts
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,20 @@ | ||
import { constDeclaration } from './ConstDeclaration' | ||
import { docComment } from './DocComment' | ||
import { namedType } from './NamedType' | ||
import { stringify } from './stringify' | ||
|
||
const A = namedType('A') | ||
|
||
test('basic', () => { | ||
expect(stringify(constDeclaration('B', A))).toMatchInlineSnapshot(`const B: A`) | ||
}) | ||
|
||
test('with doc comment', () => { | ||
const decl = constDeclaration('B', A).setDocComment(docComment('Some important value')) | ||
expect(stringify(decl)).toMatchInlineSnapshot(` | ||
/** | ||
* Some important value | ||
*/ | ||
const B: A | ||
`) | ||
}) |
Oops, something went wrong.