generated from johngeorgewright/ts-module
-
Notifications
You must be signed in to change notification settings - Fork 6
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
0eec87b
commit 4d58972
Showing
4 changed files
with
63 additions
and
78 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,49 @@ | ||
import { Type } from 'ts-morph' | ||
import arrayTypeGenerator from './array' | ||
import enumTypeGenerator from './enum' | ||
import intersecionTypeGenerator from './intersection' | ||
import literalTypeGenerator from './literal' | ||
import objectTypeGenerator from './object' | ||
import simpleTypeGenerator from './simple' | ||
import unionTypeGenerator from './union' | ||
|
||
export default function factory(type: Type) { | ||
switch (true) { | ||
case type.isString(): | ||
return simpleTypeGenerator('String') | ||
|
||
case type.isNumber(): | ||
return simpleTypeGenerator('Number') | ||
|
||
case type.isBoolean(): | ||
return simpleTypeGenerator('Boolean') | ||
|
||
case type.isArray(): | ||
return arrayTypeGenerator(type) | ||
|
||
case type.isEnum(): | ||
return enumTypeGenerator(type) | ||
|
||
case type.isIntersection(): | ||
return intersecionTypeGenerator(type) | ||
|
||
case type.isUnion(): | ||
return unionTypeGenerator(type) | ||
|
||
case type.isLiteral(): | ||
return literalTypeGenerator(type) | ||
|
||
case type.isAny(): | ||
return simpleTypeGenerator('Unknown') | ||
|
||
case type.isUndefined(): | ||
return simpleTypeGenerator('Undefined') | ||
|
||
case type.isInterface(): | ||
case type.isObject(): | ||
return objectTypeGenerator(type) | ||
|
||
default: | ||
throw new Error('!!! TYPE ' + type.getText() + ' NOT PARSED !!!') | ||
} | ||
} |
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.