ts-runtime
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
const program = require("./program"); | ||
const transform_1 = require("../transform"); | ||
const errors_1 = require("../errors"); | ||
@@ -19,4 +20,11 @@ const options_1 = require("../options"); | ||
let tsConfigPath; | ||
let fastMode = false; | ||
function defaultAction() { | ||
program.start(options, pkg.version); | ||
if (fastMode) { | ||
options.log = true; | ||
} | ||
else { | ||
program.start(options, pkg.version); | ||
options.log = false; | ||
} | ||
const files = commander.args | ||
@@ -31,9 +39,7 @@ .filter(arg => typeof arg === 'string'); | ||
catch (e) { | ||
program.status.error(`Could not parse compiler configuration.`); | ||
return; | ||
throw new errors_1.ProgramError(`Could not parse compiler configuration.`); | ||
} | ||
if (tsConfigPath) { | ||
if (!ts.sys.fileExists(tsConfigPath)) { | ||
program.status.error(`Could not load configuration from ${tsConfigPath}.`); | ||
return; | ||
throw new errors_1.ProgramError(`Could not load configuration from ${tsConfigPath}.`); | ||
} | ||
@@ -46,3 +52,8 @@ const resolvedTsConfigPath = path.resolve(tsConfigPath); | ||
else { | ||
program.status.warn(`No compiler options found in ${tsConfigPath}, used defaults.`); | ||
if (options.log) { | ||
console.warn(`No compiler options found in ${tsConfigPath}, used defaults.`); | ||
} | ||
else { | ||
program.status.warn(`No compiler options found in ${tsConfigPath}, used defaults.`); | ||
} | ||
parsedCompilerOptions = {}; | ||
@@ -52,5 +63,11 @@ } | ||
const opts = ts.convertCompilerOptionsFromJson(parsedCompilerOptions, '.'); | ||
options.log = false; | ||
options.compilerOptions = opts.options; | ||
if (opts.errors.length > 0) { | ||
const formattedDiagnostics = util.formatDiagnostics(opts.errors); | ||
if (options.log) { | ||
for (let diagnostic of formattedDiagnostics) { | ||
console.error(diagnostic); | ||
} | ||
process.exit(1); | ||
} | ||
program.status.diagnostics(util.formatDiagnostics(opts.errors)); | ||
@@ -60,3 +77,8 @@ program.status.error(); | ||
} | ||
program.transform(files); | ||
if (fastMode) { | ||
transform_1.transform(files, options); | ||
} | ||
else { | ||
program.transform(files); | ||
} | ||
} | ||
@@ -91,2 +113,5 @@ function useTsConfig(path) { | ||
} | ||
function setFast() { | ||
fastMode = true; | ||
} | ||
function setKeepTemp() { | ||
@@ -119,4 +144,4 @@ options.keepTemp = true; | ||
.description(`--------- ts-runtime --------- | ||
Turns TypeScript type assertions | ||
into runtime type checks for you | ||
Turn TypeScript type annotations | ||
--> into runtime type checks <-- | ||
--------------------------------`) | ||
@@ -128,5 +153,6 @@ .usage('<file...> [options]') | ||
.option('-d, --declarationFileName <fileName>', 'set file name for global declarations. defaults to "tsr-declarations"', setDeclarationFileName) | ||
.option('-e, --excludeDeclarationFile', 'do not automatically import ambient declarations in the entry file. default to false', setExcludeDeclarationFile) | ||
.option('-e, --excludeDeclarationFile', 'don not import the ambient declarationsfile. defaults to false', setExcludeDeclarationFile) | ||
.option('-E, --excludeLib', 'do not automatically import the runtime library. defaults to false', setExcludeLib) | ||
.option('-f, --force', 'try to finish on TypeScript compiler error. defaults to false', setForce) | ||
.option('-F, --fast', 'no status for the command line, but faster processing. defaults to false', setFast) | ||
.option('-k, --keepTemp', 'keep temporary files. defaults to false', setKeepTemp) | ||
@@ -140,3 +166,3 @@ .option('-l, --libIdentifier <name>', 'lib import name. defaults to "t"', setLibIdentifier) | ||
.option('-t, --tempFolderName <name>', 'set folder name for temporary files. defaults to ".tsr"', setTempFolderName) | ||
.on('--help', () => { | ||
.on('-h, --help', () => { | ||
console.log(' Examples:'); | ||
@@ -143,0 +169,0 @@ console.log(); |
@@ -30,2 +30,4 @@ import * as ts from 'typescript'; | ||
hasApparentSelfReference(node: ts.Node): boolean; | ||
hasProperty(node: ts.ClassDeclaration, name: string): boolean; | ||
getPropertyName(node: ts.ClassDeclaration, name: string): string; | ||
getIdentifier(text: string): string; | ||
@@ -32,0 +34,0 @@ getTypeDeclarationName(node: string | ts.Identifier): string; |
@@ -168,2 +168,27 @@ "use strict"; | ||
} | ||
hasProperty(node, name) { | ||
const typeInfo = this.scanner.getTypeInfo(node); | ||
if (!typeInfo || !typeInfo.type) { | ||
return false; | ||
} | ||
for (let prop of typeInfo.type.getProperties()) { | ||
if (prop.name === name) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
getPropertyName(node, name) { | ||
const typeInfo = this.scanner.getTypeInfo(node); | ||
if (!typeInfo || !typeInfo.type) { | ||
return name; | ||
} | ||
const ids = typeInfo.type.getProperties().map(prop => { | ||
return prop.name; | ||
}); | ||
while (ids && ids.indexOf(name) !== -1) { | ||
name = `_${name}`; | ||
} | ||
return name; | ||
} | ||
getIdentifier(text) { | ||
@@ -170,0 +195,0 @@ const ids = this.scanner.getIdentifiers(this.sourceFile); |
@@ -212,5 +212,5 @@ "use strict"; | ||
const isTypeParameter = util.isTypeParameter(node); | ||
const flowInto = isTypeParameter && !this.rule(exports.FactoryRule.NoFlowInto); | ||
const parentClass = !TSR_DECLARATION && isTypeParameter && util.isTypeParameterOfClass(node); | ||
const isClassTypeParameter = !!parentClass; | ||
const flowInto = isTypeParameter && !isClassTypeParameter && !this.rule(exports.FactoryRule.NoFlowInto); | ||
const asLiteral = !isTypeParameter && TSR_DECLARATION; | ||
@@ -388,12 +388,15 @@ let result; | ||
let intersections = []; | ||
if (hasIntersections) { | ||
intersections = implementsClause.types.map(expressionWithTypeArguments => { | ||
return this.typeReflection(expressionWithTypeArguments); | ||
}); | ||
} | ||
// TODO: For now, do not include interfaces in the reflection, as they must be implemented in the prototype chain. | ||
if (intersections.length > 0) { | ||
// reflection = [this.propertyAccessCall(this.intersect([...intersections, this.asObject(reflection)]), 'unwrap')]; | ||
// reflection = [this.intersect([...intersections, this.asObject(reflection)]) ]; | ||
} | ||
// Do not include interfaces in the reflection for now, as they must be implemented in the prototype chain. | ||
// See: https://github.com/codemix/flow-runtime/issues/127 | ||
// | ||
// if (hasIntersections) { | ||
// intersections = implementsClause.types.map(expressionWithTypeArguments => { | ||
// return this.typeReflection(expressionWithTypeArguments); | ||
// }); | ||
// } | ||
// | ||
// if (intersections.length > 0) { | ||
// // reflection = [this.propertyAccessCall(this.intersect([...intersections, this.asObject(reflection)]), 'unwrap')]; | ||
// // reflection = [this.intersect([...intersections, this.asObject(reflection)]) ]; | ||
// } | ||
if (hasExtender) { | ||
@@ -400,0 +403,0 @@ extender = this.libCall('extends', extendsClause.types.map(expressionWithTypeArguments => { |
@@ -10,1 +10,2 @@ import * as bus from './bus'; | ||
export * from './transform'; | ||
export * from './transformModules'; |
@@ -16,1 +16,2 @@ "use strict"; | ||
__export(require("./transform")); | ||
__export(require("./transformModules")); |
@@ -10,23 +10,25 @@ "use strict"; | ||
const decorate = t.decorate; | ||
t.decorate = (type, shouldAssert) => { | ||
return (input, propertyName, descriptor) => { | ||
const decorator = decorate.bind(t)(type, shouldAssert)(input, propertyName, descriptor); | ||
if (descriptor) | ||
descriptor.writable = true; | ||
input.writable = true; | ||
Object.defineProperty(input, propertyName, decorator); | ||
}; | ||
}; | ||
t.declare = (name, type) => { | ||
map.set(name, type); | ||
declare.bind(t)(name, type); | ||
}; | ||
t.ref = (type, ...args) => { | ||
if (typeof type === 'string') { | ||
if (map.has(type)) { | ||
type = map.get(type); | ||
} | ||
} | ||
return ref.bind(t)(type, ...args); | ||
}; | ||
// t.decorate = (type: any, shouldAssert?: boolean) => { | ||
// return (input: any, propertyName: any, descriptor: any) => { | ||
// const decorator = decorate.bind(t)(type, shouldAssert)(input, propertyName, descriptor); | ||
// if (descriptor) descriptor.writable = true; | ||
// input.writable = true; | ||
// Object.defineProperty(input, propertyName, decorator); | ||
// }; | ||
// } | ||
// | ||
// t.declare = (name: string, type: any) => { | ||
// map.set(name, type); | ||
// declare.bind(t)(name, type); | ||
// } | ||
// | ||
// t.ref = (type: any, ...args: any[]) => { | ||
// if (typeof type === 'string') { | ||
// if (map.has(type)) { | ||
// type = map.get(type); | ||
// } | ||
// } | ||
// | ||
// return ref.bind(t)(type, ...args); | ||
// } | ||
// t.intersect = (...args: any[]) => { | ||
@@ -33,0 +35,0 @@ // return intersect.bind(t)(...args).unwrap(); |
@@ -14,2 +14,3 @@ import { Mutator } from './mutators/Mutator'; | ||
export { Mutator, ArrowFunctionMutator, AsExpressionMutator, BinaryExpressionMutator, BlockLikeMutator, ClassDeclarationMutator, FunctionDeclarationMutator, FunctionExpressionMutator, InterfaceDeclarationMutator, SourceFileMutator, TypeAliasDeclarationMutator, VariableDeclarationListMutator }; | ||
export declare const mutators: Mutator[]; | ||
export declare const mutators: (typeof Mutator)[]; | ||
export declare function getMutators(): Mutator[]; |
@@ -28,13 +28,21 @@ "use strict"; | ||
exports.mutators = [ | ||
new ArrowFunctionMutator_1.ArrowFunctionMutator(), | ||
new AsExpressionMutator_1.AsExpressionMutator(), | ||
new BinaryExpressionMutator_1.BinaryExpressionMutator(), | ||
new BlockLikeMutator_1.BlockLikeMutator(), | ||
new ClassDeclarationMutator_1.ClassDeclarationMutator(), | ||
new FunctionDeclarationMutator_1.FunctionDeclarationMutator(), | ||
new FunctionExpressionMutator_1.FunctionExpressionMutator(), | ||
new InterfaceDeclararionMutator_1.InterfaceDeclarationMutator(), | ||
new SourceFileMutator_1.SourceFileMutator(), | ||
new TypeAliasDeclararionMutator_1.TypeAliasDeclarationMutator(), | ||
new VariableDeclarationListMutator_1.VariableDeclarationListMutator(), | ||
ArrowFunctionMutator_1.ArrowFunctionMutator, | ||
AsExpressionMutator_1.AsExpressionMutator, | ||
BinaryExpressionMutator_1.BinaryExpressionMutator, | ||
BlockLikeMutator_1.BlockLikeMutator, | ||
ClassDeclarationMutator_1.ClassDeclarationMutator, | ||
FunctionDeclarationMutator_1.FunctionDeclarationMutator, | ||
FunctionExpressionMutator_1.FunctionExpressionMutator, | ||
InterfaceDeclararionMutator_1.InterfaceDeclarationMutator, | ||
SourceFileMutator_1.SourceFileMutator, | ||
TypeAliasDeclararionMutator_1.TypeAliasDeclarationMutator, | ||
VariableDeclarationListMutator_1.VariableDeclarationListMutator, | ||
]; | ||
function getMutators() { | ||
const instances = []; | ||
for (let mutator of exports.mutators) { | ||
instances.push(new mutator()); | ||
} | ||
return instances; | ||
} | ||
exports.getMutators = getMutators; |
@@ -5,5 +5,7 @@ import * as ts from 'typescript'; | ||
protected kind: ts.SyntaxKind; | ||
protected initializers: ts.Statement[]; | ||
protected mutate(node: ts.ClassDeclaration): ts.Node; | ||
private setMerged(node); | ||
private reflectClass(node); | ||
private addInitializers(node, members); | ||
private assertImplementing(node, members); | ||
@@ -10,0 +12,0 @@ private declareTypeParameters(node, members); |
@@ -10,5 +10,8 @@ "use strict"; | ||
this.kind = ts.SyntaxKind.ClassDeclaration; | ||
this.initializers = []; | ||
} | ||
mutate(node) { | ||
const members = []; | ||
const decorators = this.options.noAnnotate ? | ||
node.decorators : this.reflectClass(node); | ||
for (let member of node.members) { | ||
@@ -23,3 +26,3 @@ switch (member.kind) { | ||
case ts.SyntaxKind.PropertyDeclaration: | ||
members.push(this.mutatePropertyDeclaration(member)); | ||
members.push(...util.asArray(this.mutatePropertyDeclaration(member))); | ||
break; | ||
@@ -31,7 +34,6 @@ case ts.SyntaxKind.IndexSignature: | ||
} | ||
this.addInitializers(node, members); | ||
this.declareTypeParameters(node, members); | ||
this.assertImplementing(node, members); | ||
this.setMerged(node); | ||
const decorators = this.options.noAnnotate ? | ||
node.decorators : this.reflectClass(node); | ||
return ts.updateClassDeclaration(node, decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, members); | ||
@@ -50,2 +52,13 @@ } | ||
} | ||
addInitializers(node, members) { | ||
if (this.initializers.length === 0) { | ||
return; | ||
} | ||
const constructor = this.getConstructor(members); | ||
let statements = util.asNewArray(constructor.body.statements); | ||
for (let initializer of this.initializers) { | ||
statements = util.insertAfterSuper(statements, initializer); | ||
} | ||
this.updateConstructor(members, constructor, statements); | ||
} | ||
assertImplementing(node, members) { | ||
@@ -77,6 +90,7 @@ const implementsClause = util.getImplementsClause(node); | ||
let bindStatement; | ||
const insert = []; | ||
if (hasTypeParameters) { | ||
typeParametersStatement = this.factory.typeParametersLiteralDeclaration(node.typeParameters); | ||
thisStatement = this.factory.classTypeParameterSymbolConstructorDeclaration(node.name); | ||
util.insertBeforeSuper(statements, typeParametersStatement); | ||
insert.push(typeParametersStatement); | ||
} | ||
@@ -86,3 +100,4 @@ if (extendsClauseHasTypeArguments) { | ||
} | ||
util.insertAfterSuper(statements, [thisStatement, bindStatement].filter(statement => !!statement)); | ||
insert.push(...[thisStatement, bindStatement].filter(statement => !!statement)); | ||
util.insertAfterSuper(statements, insert); | ||
this.updateConstructor(members, constructor, statements); | ||
@@ -92,25 +107,50 @@ members.unshift(this.factory.classTypeParameterSymbolPropertyDeclaration(node.name)); | ||
} | ||
// TODO: Define getters and setters for properties, to always check them | ||
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)) { | ||
return node; | ||
} | ||
// if (!node.initializer) { | ||
// return node; | ||
if (ts.isComputedPropertyName(node.name)) { | ||
return node; | ||
} | ||
if (util.hasModifier(node, ts.SyntaxKind.AbstractKeyword)) { | ||
return node; | ||
} | ||
// Do not use decorators (for now at least), but define getters and setters for properties. | ||
// const decorators = util.asNewArray(node.decorators); | ||
// | ||
// if (node.initializer) { | ||
// const typeReflection = this.factory.typeReflection(node.type); | ||
// | ||
// let decorator: ts.Decorator; | ||
// | ||
// if (util.hasKind(typeReflection, ts.SyntaxKind.ThisKeyword)) { | ||
// decorator = ts.createDecorator(this.factory.decorate( | ||
// ts.createFunctionExpression(undefined, undefined, undefined, undefined, undefined, undefined, | ||
// ts.createBlock([ts.createReturn(typeReflection)], true) | ||
// ) | ||
// )); | ||
// } else { | ||
// decorator = ts.createDecorator(this.factory.decorate(typeReflection)); | ||
// } | ||
// | ||
// decorators.unshift(decorator); | ||
// } | ||
const decorators = util.asNewArray(node.decorators); | ||
const typeReflection = this.factory.typeReflection(node.type); | ||
let decorator; | ||
if (util.hasKind(typeReflection, ts.SyntaxKind.ThisKeyword)) { | ||
decorator = ts.createDecorator(this.factory.decorate(ts.createFunctionExpression(undefined, undefined, undefined, undefined, undefined, undefined, ts.createBlock([ts.createReturn(typeReflection)], true)))); | ||
// ts.createGetAccessor(undefined, node.modifiers, ) | ||
let name = node.name.text; | ||
if (!ts.isComputedPropertyName(node.name)) { | ||
name = this.context.getPropertyName(this.node, `_${node.name.text}`); | ||
} | ||
else { | ||
decorator = ts.createDecorator(this.factory.decorate(typeReflection)); | ||
if (node.initializer) { | ||
this.initializers.push(ts.createStatement(ts.createBinary(ts.createPropertyAccess(ts.createThis(), name), ts.SyntaxKind.FirstAssignment, this.factory.typeReflectionAndAssertion(node.type, node.initializer)))); | ||
} | ||
decorators.unshift(decorator); | ||
return this.map(ts.updateProperty(node, decorators, node.modifiers, node.name, node.type, node.initializer), node); | ||
const property = this.map(ts.updateProperty(node, node.decorators, node.modifiers, ts.createIdentifier(name), node.type, undefined), node); | ||
let setAccessor; | ||
if (!util.hasModifier(node, ts.SyntaxKind.ReadonlyKeyword)) { | ||
setAccessor = this.factory.mutateFunctionBody(ts.createSetAccessor(undefined, node.modifiers, node.name, [ | ||
ts.createParameter(undefined, undefined, undefined, node.name.text, undefined, node.type) | ||
], ts.createBlock([ts.createStatement(ts.createBinary(ts.createPropertyAccess(ts.createThis(), name), ts.SyntaxKind.FirstAssignment, node.name))], true))); | ||
} | ||
const getAccessor = ts.createGetAccessor(undefined, node.modifiers, node.name, undefined, node.type, ts.createBlock([ts.createReturn(ts.createPropertyAccess(ts.createThis(), name))], true)); | ||
node.name.text = name; | ||
return [property, getAccessor, setAccessor].filter(val => !!val); | ||
} | ||
@@ -117,0 +157,0 @@ mutateMethodDeclaration(node) { |
@@ -19,3 +19,2 @@ "use strict"; | ||
if (!this.options.excludeDeclarationFile && this.context.scanner.getDeclarations().length > 0 && this.context.isEntryFile(node.fileName)) { | ||
// TODO: refactor to not use path module | ||
const relativePath = path.relative(path.dirname(node.fileName), this.context.commonDir); | ||
@@ -22,0 +21,0 @@ const filePath = path.join(relativePath, this.context.options.declarationFileName); |
{ | ||
"name": "ts-runtime", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Runtime type checks for TypeScript", | ||
@@ -17,3 +17,6 @@ "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 src/lib/index src/bin/index src/bin/process --moduleAlias --compilerOptions '{\"outDir\": \"dist-tsr\", \"strictNullChecks\": false, \"moduleResolution\": \"Node\", \"module\": \"commonjs\", \"target\": \"ES2015\", \"lib\": [\"ESNext\"]}'" | ||
"build:docs": "yarn build:docs:lib && node_modules/.bin/webpack --config webpack.docs.config.js", | ||
"build:docs:lib": "node_modules/.bin/webpack --config webpack.lib.config.js", | ||
"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\"]}'", | ||
"build:tsr:fast": "ts-node ./src/bin/index src/index src/lib/index src/bin/index src/bin/process --fast --moduleAlias --compilerOptions '{\"outDir\": \"dist-tsr\", \"strictNullChecks\": false, \"moduleResolution\": \"Node\", \"module\": \"commonjs\", \"target\": \"ES2015\", \"lib\": [\"ESNext\"]}'" | ||
}, | ||
@@ -32,3 +35,3 @@ "_moduleAliases": { | ||
"rimraf": "^2.6.1", | ||
"typescript": "^2.4.0" | ||
"typescript": "^2.4.1" | ||
}, | ||
@@ -38,6 +41,21 @@ "devDependencies": { | ||
"@types/commander": "^2.3.31", | ||
"@types/node": "^8.0.7", | ||
"@types/lodash.debounce": "^4.0.2", | ||
"@types/node": "^8.0.10", | ||
"@types/rimraf": "^0.0.28", | ||
"module-alias": "^2.0.0" | ||
"babel-core": "^6.25.0", | ||
"babel-loader": "^7.1.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"copy-webpack-plugin": "^4.0.1", | ||
"css-loader": "^0.28.4", | ||
"lodash.debounce": "^4.0.8", | ||
"module-alias": "^2.0.0", | ||
"monaco-editor": "^0.9.0", | ||
"raw-loader": "^0.5.1", | ||
"source-map-loader": "^0.2.1", | ||
"source-map-support": "^0.4.15", | ||
"ts-loader": "^2.2.2", | ||
"uglifyjs-webpack-plugin": "^0.4.6", | ||
"webpack": "^2.2.0", | ||
"worker-loader": "^0.8.1" | ||
} | ||
} |
@@ -9,2 +9,6 @@ # ts-runtime | ||
## Playground | ||
You can try `ts-runtime` on the playground: https://fabiandev.github.io/ts-runtime/ | ||
## Quick Start | ||
@@ -450,3 +454,5 @@ | ||
- No support for string enums. | ||
- readonly or class visibility modifiers are not asserted. | ||
- `readonly` is currently only supported for classes. | ||
- Class visibility modifiers are not asserted. | ||
- Class type parameters are only checked when extending, at this time. | ||
- No declaration merging. | ||
@@ -614,2 +620,3 @@ - Method overloading is only supported within the same declaration. | ||
-f, --force try to finish on TypeScript compiler error. defaults to false | ||
-F, --fast no fancy status for the command line, but faster processing. defaults to false | ||
-k, --keepTemp keep temporary files. defaults to false | ||
@@ -616,0 +623,0 @@ -l, --libIdentifier <name> lib import name. defaults to "t" |
@@ -6,3 +6,2 @@ "use strict"; | ||
const path = require("path"); | ||
// TODO: only scan required nodes and build symbol table for other purposes | ||
class Scanner { | ||
@@ -122,6 +121,6 @@ constructor(program, options) { | ||
} | ||
// TODO: refactor to not use path module | ||
pathIsExternal(fileName) { | ||
const rootDir = this.program.getCompilerOptions().rootDir + path.sep; | ||
return !path.resolve(fileName).startsWith(path.resolve(rootDir)); | ||
const r = this.program.getCompilerOptions().rootDir; | ||
const rootDir = !r ? '' : r + path.sep; | ||
return !fileName.startsWith(rootDir); | ||
} | ||
@@ -269,3 +268,3 @@ getType(node) { | ||
if (this._isTsrDeclaration === undefined) { | ||
if (!this.scanner.options.libDeclarations && !this.isExternalModule) { | ||
if (this.isExternal && !this.scanner.options.libDeclarations && !this.isExternalModule) { | ||
return this._isTsrDeclaration = false; | ||
@@ -272,0 +271,0 @@ } |
@@ -21,3 +21,3 @@ "use strict"; | ||
const opts = Object.assign({}, options_1.defaultOptions, options); | ||
opts.compilerOptions = Object.assign({}, options_1.defaultOptions.compilerOptions, options.compilerOptions || {}); | ||
opts.compilerOptions = Object.assign({}, options_1.defaultOptions.compilerOptions, options && options.compilerOptions || {}); | ||
return opts; | ||
@@ -205,3 +205,3 @@ } | ||
} | ||
for (let mutator of mutators_1.mutators) { | ||
for (let mutator of mutators_1.getMutators()) { | ||
let previous = node; | ||
@@ -241,3 +241,3 @@ node = mutator.mutateNode(node, context); | ||
if (!options.compilerOptions.preserveConstEnums) { | ||
const warning = 'Compiler option preserveConstEnums was changed and set to true by'; | ||
const warning = 'Compiler option "preserveConstEnums" was enabled.'; | ||
options.compilerOptions.preserveConstEnums = true; | ||
@@ -244,0 +244,0 @@ emit(bus.events.WARN, warning); |
@@ -259,3 +259,4 @@ "use strict"; | ||
else { | ||
statements.splice(statements.length, 0, ...insert); | ||
statements.unshift(...insert); | ||
// statements.splice(statements.length, 0, ...insert); | ||
} | ||
@@ -262,0 +263,0 @@ return statements; |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
396574
119
9192
642
20
5
Updatedtypescript@^2.4.1