(type: ts.Type)
| 111 | } |
| 112 | |
| 113 | export function isEnumType(type: ts.Type) { |
| 114 | // if for some reason this returns true... |
| 115 | if (hasFlag(type, ts.TypeFlags.Enum)) { |
| 116 | return true; |
| 117 | } |
| 118 | // it's not an enum type if it's an enum literal type |
| 119 | if (hasFlag(type, ts.TypeFlags.EnumLiteral)) { |
| 120 | return true; |
| 121 | } |
| 122 | // get the symbol and check if its value declaration is an enum declaration |
| 123 | const symbol = type.getSymbol(); |
| 124 | if (!symbol) { |
| 125 | return false; |
| 126 | } |
| 127 | const { valueDeclaration } = symbol; |
| 128 | |
| 129 | return valueDeclaration && valueDeclaration.kind === ts.SyntaxKind.EnumDeclaration; |
| 130 | } |
| 131 | |
| 132 | export function wrapToNonNull(isNullableType: boolean, expr: ts.Expression, factory: ts.NodeFactory) { |
| 133 | return isNullableType ? expr : factory.createNonNullExpression(expr); |
no test coverage detected