ts-runtime
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -101,3 +101,3 @@ #!/usr/bin/env node | ||
function setStackTraceOutput(limit) { | ||
options.stackTraceOutput = limit; | ||
options.stackTraceOutput = parseInt(limit); | ||
} | ||
@@ -104,0 +104,0 @@ function setTempFolderName(name) { |
@@ -92,2 +92,7 @@ "use strict"; | ||
} | ||
if (typeInfo.symbol && typeInfo.symbol.valueDeclaration && util.canHaveType(typeInfo.symbol.valueDeclaration)) { | ||
if (typeInfo.symbol.valueDeclaration.type === undefined || util.isAnyKeyword(typeInfo.symbol.valueDeclaration.type)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
@@ -94,0 +99,0 @@ } |
@@ -397,3 +397,3 @@ "use strict"; | ||
if (hasExtender) { | ||
extender = this.libCall('extend', extendsClause.types.map(expressionWithTypeArguments => { | ||
extender = this.libCall('extends', extendsClause.types.map(expressionWithTypeArguments => { | ||
return this.typeReflection(expressionWithTypeArguments); | ||
@@ -400,0 +400,0 @@ })); |
@@ -32,3 +32,3 @@ "use strict"; | ||
t.nostrict = (...args) => { | ||
return t.union(...args, t.null()); | ||
return t.union(...args, t.null(), t.undef()); | ||
}; | ||
@@ -35,0 +35,0 @@ t.void = () => { |
@@ -87,2 +87,6 @@ "use strict"; | ||
mutatePropertyDeclaration(node) { | ||
// TODO: Property decorators are causing problems, as they won't be writeable any more | ||
if (true === true) { | ||
return node; | ||
} | ||
if (!this.options.assertAny && this.context.isAny(node.type)) { | ||
@@ -89,0 +93,0 @@ return node; |
@@ -13,2 +13,3 @@ "use strict"; | ||
experimentalDecorators: true, | ||
emitDecoratorMetadata: true, | ||
sourceMap: false, | ||
@@ -15,0 +16,0 @@ removeComments: true, |
{ | ||
"name": "ts-runtime", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Runtime type checks for TypeScript", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"build": "./node_modules/.bin/tsc --rootDir src --outDir dist --module CommonJS --target es6 --skipLibCheck && cp package.json dist/package.json && cp README.md dist/README.md && cp LICENSE dist/LICENSE", | ||
"build:tsr": "ts-node ./src/bin/index src/index.ts ./src/lib/index.ts ./src/bin/index.ts --compilerOptions '{\"outDir\": \"dist-tsr\", \"strictNullChecks\": false, \"moduleResolution\": \"Node\", \"module\": \"commonjs\", \"target\": \"ES5\", \"lib\": [\"ESNext\"]}'" | ||
"build:tsr": "ts-node ./src/bin/index src/index src/lib/index src/bin/index src/bin/process --moduleAlias --compilerOptions '{\"outDir\": \"dist-tsr\", \"strictNullChecks\": false, \"moduleResolution\": \"Node\", \"module\": \"commonjs\", \"target\": \"ES2015\", \"lib\": [\"ESNext\"]}'" | ||
}, | ||
@@ -20,0 +20,0 @@ "_moduleAliases": { |
@@ -42,2 +42,4 @@ "use strict"; | ||
ts.SyntaxKind.Parameter, | ||
ts.SyntaxKind.PropertySignature, | ||
ts.SyntaxKind.PropertyDeclaration | ||
]; | ||
@@ -100,3 +102,3 @@ this.AllowedDeclarations = ts.SymbolFlags.Interface | ts.SymbolFlags.Class | | ||
if (type) { | ||
symbol = type.symbol || type.aliasSymbol; | ||
symbol = type.aliasSymbol || type.symbol; | ||
} | ||
@@ -103,0 +105,0 @@ if (!symbol && node) { |
@@ -193,2 +193,3 @@ "use strict"; | ||
if (util.annotateWithAny(node)) { | ||
// do nothing for now | ||
} | ||
@@ -195,0 +196,0 @@ } |
@@ -41,2 +41,5 @@ import * as ts from 'typescript'; | ||
export declare function extendsClauseHasTypeArguments(node: ts.HeritageClause): boolean; | ||
export declare function canHaveType(node: any): node is { | ||
type: ts.TypeNode; | ||
}; | ||
export declare function annotateWithAny(node: ts.Node): boolean; |
28
util.js
@@ -73,2 +73,5 @@ "use strict"; | ||
function isAnyKeyword(node) { | ||
if (!node) { | ||
return false; | ||
} | ||
if (node.kind === ts.SyntaxKind.AnyKeyword) { | ||
@@ -288,2 +291,27 @@ return true; | ||
exports.extendsClauseHasTypeArguments = extendsClauseHasTypeArguments; | ||
function canHaveType(node) { | ||
if (!node) { | ||
return false; | ||
} | ||
switch (node.kind) { | ||
case ts.SyntaxKind.VariableDeclaration: | ||
case ts.SyntaxKind.ObjectBindingPattern: | ||
case ts.SyntaxKind.ArrayBindingPattern: | ||
case ts.SyntaxKind.Parameter: | ||
case ts.SyntaxKind.PropertySignature: | ||
case ts.SyntaxKind.PropertyDeclaration: | ||
case ts.SyntaxKind.MethodSignature: | ||
case ts.SyntaxKind.CallSignature: | ||
case ts.SyntaxKind.ConstructSignature: | ||
case ts.SyntaxKind.IndexSignature: | ||
case ts.SyntaxKind.MethodDeclaration: | ||
case ts.SyntaxKind.GetAccessor: | ||
case ts.SyntaxKind.FunctionExpression: | ||
case ts.SyntaxKind.ArrowFunction: | ||
case ts.SyntaxKind.FunctionDeclaration: | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.canHaveType = canHaveType; | ||
function annotateWithAny(node) { | ||
@@ -290,0 +318,0 @@ switch (node.kind) { |
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
191243
4201