typescript-is
Advanced tools
Comparing version
@@ -18,2 +18,3 @@ "use strict"; | ||
ignoreMethods: !!(options && options.ignoreMethods), | ||
ignoreFunctions: !!(options && options.ignoreFunctions), | ||
disallowSuperfluousObjectProperties: !!(options && options.disallowSuperfluousObjectProperties) | ||
@@ -20,0 +21,0 @@ }, |
@@ -7,2 +7,3 @@ import * as ts from 'typescript'; | ||
ignoreMethods: boolean; | ||
ignoreFunctions: boolean; | ||
disallowSuperfluousObjectProperties: boolean; | ||
@@ -9,0 +10,0 @@ } |
@@ -166,2 +166,11 @@ "use strict"; | ||
} | ||
else if ('valueDeclaration' in type.symbol | ||
&& (type.symbol.valueDeclaration.kind === ts.SyntaxKind.MethodDeclaration || type.symbol.valueDeclaration.kind === ts.SyntaxKind.FunctionType)) { | ||
if (visitorContext.options.ignoreFunctions) { | ||
return VisitorUtils.getIgnoredTypeFunction(visitorContext); | ||
} | ||
else { | ||
throw new Error('Encountered a function declaration, but functions are not supported. Issue: https://github.com/woutervh-/typescript-is/issues/50'); | ||
} | ||
} | ||
else { | ||
@@ -168,0 +177,0 @@ // Index type is string -> regular object type. |
@@ -53,7 +53,10 @@ "use strict"; | ||
} | ||
const isMethod = ts.isMethodSignature(valueDeclaration) | ||
|| valueDeclaration.type !== undefined && ts.isFunctionTypeNode(valueDeclaration.type); | ||
const isMethod = ts.isMethodSignature(valueDeclaration); | ||
const isFunction = valueDeclaration.type !== undefined && ts.isFunctionTypeNode(valueDeclaration.type); | ||
if (isMethod && !visitorContext.options.ignoreMethods) { | ||
throw new Error('Encountered a method declaration, but methods are not supported. Issue: https://github.com/woutervh-/typescript-is/issues/5'); | ||
} | ||
if (isFunction && !visitorContext.options.ignoreFunctions) { | ||
throw new Error('Encountered a function declaration, but functions are not supported. Issue: https://github.com/woutervh-/typescript-is/issues/50'); | ||
} | ||
let propertyType = undefined; | ||
@@ -60,0 +63,0 @@ if (valueDeclaration.type === undefined) { |
{ | ||
"name": "typescript-is", | ||
"version": "0.14.2", | ||
"version": "0.14.3", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=6.14.4" |
@@ -98,2 +98,3 @@ # typescript-is | ||
| `ignoreMethods` | Boolean (default: `false`). If `true`, when the transformer encounters a method, it will ignore it and simply return `true`. If `false`, an error is generated at compile time. | | ||
| `ignoreFunctions` | Boolean (default: `false`). If `true`, when the transformer encounters a function, it will ignore it and simply return `true`. If `false`, an error is generated at compile time. | | ||
| `disallowSuperfluousObjectProperties` | Boolean (default: `false`). If `true`, objects are checked for having superfluous properties and will cause the validation to fail if they do. If `false`, no check for superfluous properties is made. | | ||
@@ -112,2 +113,3 @@ | ||
"ignoreMethods": true, | ||
"ignoreFunctions": true, | ||
"disallowSuperfluousObjectProperties": true | ||
@@ -114,0 +116,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
214026
0.79%2655
0.53%295
0.68%