typescript-is
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -169,2 +169,18 @@ "use strict"; | ||
} | ||
function visitNonPrimitive(type, accessor, visitorContext) { | ||
const intrinsicName = type.intrinsicName; | ||
let conditions; | ||
if (intrinsicName === 'object') { | ||
conditions = [ | ||
ts.createStrictInequality(ts.createTypeOf(accessor), ts.createStringLiteral('boolean')), | ||
ts.createStrictInequality(ts.createTypeOf(accessor), ts.createStringLiteral('number')), | ||
ts.createStrictInequality(ts.createTypeOf(accessor), ts.createStringLiteral('string')) | ||
]; | ||
} | ||
else { | ||
throw new Error(`Unsupported non-primitive with intrinsic name: ${intrinsicName}.`); | ||
} | ||
// Using internal TypeScript API, hacky. | ||
return conditions.reduce((condition, expression) => ts.createBinary(condition, ts.SyntaxKind.AmpersandAmpersandToken, expression)); | ||
} | ||
function visitTypeParameter(type, accessor, visitorContext) { | ||
@@ -230,2 +246,6 @@ const typeMapper = visitorContext.typeMapperStack[visitorContext.typeMapperStack.length - 1]; | ||
} | ||
else if ((ts.TypeFlags.NonPrimitive & type.flags) !== 0) { | ||
// Non-primitive such as object | ||
return visitNonPrimitive(type, accessor, visitorContext); | ||
} | ||
else { | ||
@@ -232,0 +252,0 @@ throw new Error('Unsupported type with flags: ' + type.flags); |
{ | ||
"name": "typescript-is", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=6.14.4" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73358
757