We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5d5e4c4 + 59457f7 commit 7b7192cCopy full SHA for 7b7192c
src/utils/getDatabaseType.ts
@@ -0,0 +1,17 @@
1
+import { SourceFile, Node } from 'ts-morph';
2
+
3
+export function getDatabaseType(sourceFile: SourceFile) {
4
+ const databaseInterface = sourceFile.getInterface('Database');
5
+ if (databaseInterface) {
6
+ return databaseInterface;
7
+ } else {
8
+ const node = sourceFile
9
+ .getTypeAliasOrThrow('Database')
10
+ .getTypeNodeOrThrow();
11
+ if (Node.isTypeLiteral(node)) {
12
+ return node;
13
14
+ throw Error('Expected database type to be an object literal.');
15
+ }
16
17
+}
0 commit comments