diff --git a/src/lib/converter/convert-expression.ts b/src/lib/converter/convert-expression.ts index 9f1e7c9a5..8368fa5f7 100644 --- a/src/lib/converter/convert-expression.ts +++ b/src/lib/converter/convert-expression.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../ts-internal"; /** @@ -29,7 +30,7 @@ export function convertExpression(expression:ts.Expression):string case ts.SyntaxKind.FalseKeyword: return 'false'; default: - var source = ts.getSourceFileOfNode(expression); + var source = _ts.getSourceFileOfNode(expression); return source.text.substring(expression.pos, expression.end); } } diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index aaa6ca8c7..55ad9581b 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../ts-internal"; import * as Path from "path"; import {Application} from "../application"; @@ -331,7 +332,7 @@ export class Converter extends ChildableComponent { - if (ts.isBindingPattern(node.name)) { + if (_ts.isBindingPattern(node.name)) { parameter.type = context.converter.convertType(context, node.name); parameter.name = '__namedParameters' } else { diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index b81f700fc..03563ab73 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Reflection, ReflectionKind, DeclarationReflection} from "../../models/index"; import {createDeclaration} from "../factories/index"; @@ -44,7 +45,7 @@ export class ClassConverter extends ConverterNodeComponent }); } - var baseType = ts.getClassExtendsHeritageClauseElement(node); + var baseType = _ts.getClassExtendsHeritageClauseElement(node); if (baseType) { var type = context.getTypeAtLocation(baseType); if (!context.isInherit) { @@ -59,7 +60,7 @@ export class ClassConverter extends ConverterNodeComponent } } - var implementedTypes = ts.getClassImplementsHeritageClauseElements(node); + var implementedTypes = _ts.getClassImplementsHeritageClauseElements(node); if (implementedTypes) { implementedTypes.forEach((implementedType) => { if (!reflection.implementedTypes) { diff --git a/src/lib/converter/nodes/interface.ts b/src/lib/converter/nodes/interface.ts index c61578f73..7a9e20d02 100644 --- a/src/lib/converter/nodes/interface.ts +++ b/src/lib/converter/nodes/interface.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Reflection, ReflectionKind, DeclarationReflection} from "../../models/index"; import {createDeclaration} from "../factories/index"; @@ -39,7 +40,7 @@ export class InterfaceConverter extends ConverterNodeComponent { var type = context.getTypeAtLocation(baseType); diff --git a/src/lib/converter/nodes/variable-statement.ts b/src/lib/converter/nodes/variable-statement.ts index 0fc0f5e89..18d9a1c3d 100644 --- a/src/lib/converter/nodes/variable-statement.ts +++ b/src/lib/converter/nodes/variable-statement.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Reflection, ReflectionKind} from "../../models/index"; import {Context} from "../context"; @@ -26,7 +27,7 @@ export class VariableStatementConverter extends ConverterNodeComponent { - if (ts.isBindingPattern(variableDeclaration.name)) { + if (_ts.isBindingPattern(variableDeclaration.name)) { this.convertBindingPattern(context, variableDeclaration.name); } else { this.owner.convertNode(context, variableDeclaration); @@ -48,7 +49,7 @@ export class VariableStatementConverter extends ConverterNodeComponent { this.owner.convertNode(context, element); - if (ts.isBindingPattern(element.name)) { + if (_ts.isBindingPattern(element.name)) { this.convertBindingPattern(context, element.name); } }); diff --git a/src/lib/converter/nodes/variable.ts b/src/lib/converter/nodes/variable.ts index eb98de472..7d780d68e 100644 --- a/src/lib/converter/nodes/variable.ts +++ b/src/lib/converter/nodes/variable.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Reflection, ReflectionKind, IntrinsicType} from "../../models/index"; import {createDeclaration, createComment} from "../factories/index"; @@ -50,9 +51,9 @@ export class VariableConverter extends ConverterNodeComponent { if (index < signature.parameters.length) { var parameter = signature.parameters[index]; - result[parameter.name] = ts.getTextOfNode(arg); + result[parameter.name] = _ts.getTextOfNode(arg); } else { if (!result['...']) result['...'] = []; - result['...'].push(ts.getTextOfNode(arg)); + result['...'].push(_ts.getTextOfNode(arg)); } }); @@ -87,7 +88,7 @@ export class DecoratorPlugin extends ConverterComponent } var info:IDecorator = { - name: ts.getTextOfNode(identifier) + name: _ts.getTextOfNode(identifier) }; var type = context.checker.getTypeAtLocation(identifier); diff --git a/src/lib/converter/plugins/SourcePlugin.ts b/src/lib/converter/plugins/SourcePlugin.ts index c30888950..5021382f2 100644 --- a/src/lib/converter/plugins/SourcePlugin.ts +++ b/src/lib/converter/plugins/SourcePlugin.ts @@ -1,5 +1,6 @@ import * as Path from "path"; import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Reflection, ProjectReflection, DeclarationReflection} from "../../models/reflections/index"; import {SourceDirectory, SourceFile} from "../../models/sources/index"; @@ -92,7 +93,7 @@ export class SourcePlugin extends ConverterComponent */ private onDeclaration(context:Context, reflection:Reflection, node?:ts.Node) { if (!node) return; - var sourceFile = ts.getSourceFileOfNode(node); + var sourceFile = _ts.getSourceFileOfNode(node); var fileName = sourceFile.fileName; var file:SourceFile = this.getSourceFile(fileName, context.project); diff --git a/src/lib/converter/ts-internal.ts b/src/lib/converter/ts-internal.ts deleted file mode 100644 index 08611213e..000000000 --- a/src/lib/converter/ts-internal.ts +++ /dev/null @@ -1,130 +0,0 @@ -import * as ts from "typescript"; - -/** - * Expose the internal TypeScript APIs that are used by TypeDoc - */ -declare module "typescript" { - interface Symbol { - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2166 - id?: number; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2168 - parent?: ts.Symbol; - } - - interface Node { - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L469 - symbol?: ts.Symbol; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L472 - localSymbol?: ts.Symbol; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L471 - nextContainer?: ts.Node; - } - - /** - * These functions are in "core" and are marked as @internal: - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L4-L5 - */ - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L411 - // function hasProperty(map: ts.MapLike, key: string): boolean; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L655-L656 - export function createCompilerDiagnostic(message: ts.DiagnosticMessage, ...args: any[]): ts.Diagnostic; - export function createCompilerDiagnostic(message: ts.DiagnosticMessage): ts.Diagnostic; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L701 - function compareValues(a: T, b: T): number; // Actually returns a ts.Comparison which is internal - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L790 - function normalizeSlashes(path: string): string; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L795 - function getRootLength(path: string): number; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L845 - // function normalizePath(path: string): string; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L852-L854 - function getDirectoryPath(path: ts.Path): ts.Path; - function getDirectoryPath(path: string): string; - function getDirectoryPath(path: string): any; - - /** - * These functions are in "utilities" and are marked as @internal: - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L3-L4 - */ - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L188 - function getSourceFileOfNode(node: ts.Node): ts.SourceFile; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L333 - function getTextOfNode(node: ts.Node, includeTrivia?: boolean): string; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L438 - function declarationNameToString(name: ts.DeclarationName); - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L598 - function getJsDocComments(node: ts.Node, sourceFileOfNode: ts.SourceFile); - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1487 - function isBindingPattern(node: ts.Node): node is ts.BindingPattern; - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1696 - function getClassExtendsHeritageClauseElement(node: ts.ClassLikeDeclaration | ts.InterfaceDeclaration); - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1701 - function getClassImplementsHeritageClauseElements(node: ts.ClassLikeDeclaration); - - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1706 - function getInterfaceBaseTypeNodes(node: ts.InterfaceDeclaration); - - - /** - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2789-L2924 - * This is large enum of char codes. - * - * Faking the enum as a var (only certain codes are used by TypeDoc) - */ - var CharacterCodes: { - [key: string]: number; - doubleQuote: number; - space: number; - minus: number; - at: number; - }; - - /** - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2334 - * Duplicating the interface definition :( - */ - // interface IntrinsicType extends ts.Type { - // intrinsicName: string; - // } - - const optionDeclarations: CommandLineOption[]; - - /** - * Command line options - */ - interface CommandLineOption { - name: string; - type: string; - shortName: string; - description: DiagnosticsEnumValue; - paramType: DiagnosticsEnumValue; - } - - const Diagnostics: { - [key: string]: DiagnosticsEnumValue; - FILE: DiagnosticsEnumValue; - DIRECTORY: DiagnosticsEnumValue; - }; - - interface DiagnosticsEnumValue { - code: number; - category: ts.DiagnosticCategory; - key: string; - message: string; - } - -} diff --git a/src/lib/converter/types/alias.ts b/src/lib/converter/types/alias.ts index 80aba63fb..b035de0e8 100644 --- a/src/lib/converter/types/alias.ts +++ b/src/lib/converter/types/alias.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {ReferenceType} from "../../models/index"; import {Component, ConverterTypeComponent, ITypeNodeConverter} from "../components"; @@ -37,7 +38,7 @@ export class AliasConverter extends ConverterTypeComponent implements ITypeNodeC if (!symbolName.length) return false; if (symbolName[0].substr(0, 1) == '"') symbolName.shift(); - var nodeName = ts.getTextOfNode(node.typeName).split('.'); + var nodeName = _ts.getTextOfNode(node.typeName).split('.'); if (!nodeName.length) return false; var common = Math.min(symbolName.length, nodeName.length); @@ -65,7 +66,7 @@ export class AliasConverter extends ConverterTypeComponent implements ITypeNodeC * @returns A type reference pointing to the type alias definition. */ convertNode(context:Context, node:ts.TypeReferenceNode):ReferenceType { - var name = ts.getTextOfNode(node.typeName); + var name = _ts.getTextOfNode(node.typeName); return new ReferenceType(name, ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME); } } diff --git a/src/lib/converter/types/type-parameter.ts b/src/lib/converter/types/type-parameter.ts index 1b0f17174..78f0b40ce 100644 --- a/src/lib/converter/types/type-parameter.ts +++ b/src/lib/converter/types/type-parameter.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Type, TypeParameterType} from "../../models/types/index"; import {Component, ConverterTypeComponent, ITypeNodeConverter} from "../components"; @@ -41,7 +42,7 @@ export class TypeParameterConverter extends ConverterTypeComponent implements IT */ convertNode(context:Context, node:ts.TypeReferenceNode):Type { if (node.typeName) { - var name = ts.getTextOfNode(node.typeName); + var name = _ts.getTextOfNode(node.typeName); if (context.typeParameters && context.typeParameters[name]) { return context.typeParameters[name].clone(); } diff --git a/src/lib/converter/utils/compiler-host.ts b/src/lib/converter/utils/compiler-host.ts index b26b70c5b..a67bbdfeb 100644 --- a/src/lib/converter/utils/compiler-host.ts +++ b/src/lib/converter/utils/compiler-host.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import * as Path from "path"; import {ConverterComponent} from "../components"; @@ -57,7 +58,7 @@ export class CompilerHost extends ConverterComponent implements ts.CompilerHost */ getDefaultLibFileName(options:ts.CompilerOptions):string { var lib = this.owner.getDefaultLib(); - var path = ts.getDirectoryPath(normalizePath(require.resolve('typescript'))); + var path = _ts.getDirectoryPath(normalizePath(require.resolve('typescript'))); return Path.join(path, lib); } diff --git a/src/lib/ts-internal.ts b/src/lib/ts-internal.ts new file mode 100644 index 000000000..598fa2dd3 --- /dev/null +++ b/src/lib/ts-internal.ts @@ -0,0 +1,152 @@ +import * as ts from "typescript"; +const tsany = ts as any; + +/** + * Expose the internal TypeScript APIs that are used by TypeDoc + */ +declare module "typescript" { + interface Symbol { + // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2166 + id?: number; + // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2168 + parent?: ts.Symbol; + } + + interface Node { + // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L469 + symbol?: ts.Symbol; + // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L472 + localSymbol?: ts.Symbol; + // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L471 + nextContainer?: ts.Node; + } +} + + +/** + * These functions are in "core" and are marked as @internal: + * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L4-L5 + */ + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L655-L656 +export function createCompilerDiagnostic(message: ts.DiagnosticMessage, ...args: any[]): ts.Diagnostic; +export function createCompilerDiagnostic(message: ts.DiagnosticMessage): ts.Diagnostic; +export function createCompilerDiagnostic() { + return tsany.createCompilerDiagnostic.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L701 +export function compareValues(a: T, b: T): number { + return tsany.compareValues.apply(this, arguments); // Actually returns a ts.Comparison which is also internal +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L790 +export function normalizeSlashes(path: string): string { + return tsany.normalizeSlashes.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L795 +export function getRootLength(path: string): number { + return tsany.getRootLength.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L852-L854 +export function getDirectoryPath(path: ts.Path): ts.Path; +export function getDirectoryPath(path: string): string; +export function getDirectoryPath(path: string): any; +export function getDirectoryPath() { + return tsany.getDirectoryPath.apply(this, arguments); +} + +/** + * These functions are in "utilities" and are marked as @internal: + * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L3-L4 + */ + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L188 +export function getSourceFileOfNode(node: ts.Node): ts.SourceFile { + return tsany.getSourceFileOfNode.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L333 +export function getTextOfNode(node: ts.Node, includeTrivia?: boolean): string { + return tsany.getTextOfNode.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L438 +export function declarationNameToString(name: ts.DeclarationName): string { + return tsany.declarationNameToString.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L598 +export function getJsDocComments(node: ts.Node, sourceFileOfNode: ts.SourceFile) { + return tsany.getJsDocComments.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1487 +export function isBindingPattern(node: ts.Node): node is ts.BindingPattern { + return tsany.isBindingPattern.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1696 +export function getClassExtendsHeritageClauseElement(node: ts.ClassLikeDeclaration | ts.InterfaceDeclaration) { + return tsany.getClassExtendsHeritageClauseElement.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1701 +export function getClassImplementsHeritageClauseElements(node: ts.ClassLikeDeclaration) { + return tsany.getClassImplementsHeritageClauseElements.apply(this, arguments); +} + +// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1706 +export function getInterfaceBaseTypeNodes(node: ts.InterfaceDeclaration) { + return tsany.getInterfaceBaseTypeNodes.apply(this, arguments); +} + +/** + * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2789-L2924 + * This is large enum of char codes. + * + * Faking the enum as a var (only certain codes are used by TypeDoc) + */ +export const CharacterCodes: { + [key: string]: number; + doubleQuote: number; + space: number; + minus: number; + at: number; +} = tsany.CharacterCodes; + +/** + * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2334 + * Duplicating the interface definition :( + */ +// interface IntrinsicType extends ts.Type { +// intrinsicName: string; +// } + +export const optionDeclarations: CommandLineOption[] = tsany.optionDeclarations; + +/** + * Command line options + */ +export interface CommandLineOption { + name: string; + type: string; + shortName: string; + description: DiagnosticsEnumValue; + paramType: DiagnosticsEnumValue; +} + +export const Diagnostics: { + [key: string]: DiagnosticsEnumValue; + FILE: DiagnosticsEnumValue; + DIRECTORY: DiagnosticsEnumValue; +} = tsany.Diagnostics; + +export interface DiagnosticsEnumValue { + code: number; + category: ts.DiagnosticCategory; + key: string; + message: string; +} diff --git a/src/lib/utils/fs.ts b/src/lib/utils/fs.ts index ec97f8a18..ea9188f14 100644 --- a/src/lib/utils/fs.ts +++ b/src/lib/utils/fs.ts @@ -1,7 +1,9 @@ import * as ts from "typescript"; +import * as _ts from "../ts-internal"; import * as FS from "fs"; + /** * List of known existent directories. Used to speed up [[directoryExists]]. */ @@ -45,8 +47,8 @@ export function directoryExists(directoryPath: string): boolean { * @param directoryPath The directory that should be validated. */ export function ensureDirectoriesExist(directoryPath: string) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); + if (directoryPath.length > _ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = _ts.getDirectoryPath(directoryPath); ensureDirectoriesExist(parentDirectory); ts.sys.createDirectory(directoryPath); } @@ -65,7 +67,7 @@ export function ensureDirectoriesExist(directoryPath: string) { */ export function writeFile(fileName:string, data:string, writeByteOrderMark:boolean, onError?:(message:string) => void) { try { - ensureDirectoriesExist(ts.getDirectoryPath(normalizePath(fileName))); + ensureDirectoriesExist(_ts.getDirectoryPath(normalizePath(fileName))); ts.sys.writeFile(fileName, data, writeByteOrderMark); } catch (e) { if (onError) onError(e.message); diff --git a/src/lib/utils/options/help.ts b/src/lib/utils/options/help.ts index 36b521eb5..0e0e1c9f8 100644 --- a/src/lib/utils/options/help.ts +++ b/src/lib/utils/options/help.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../ts-internal"; import {Options} from "./options"; import {ParameterScope, ParameterHint} from "./declaration"; @@ -20,7 +21,7 @@ export interface IParameterHelp { function getParameterHelp(options:Options, scope:ParameterScope):IParameterHelp { var parameters = options.getDeclarationsByScope(scope); parameters.sort((a, b) => { - return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()) + return _ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()) }); var names:string[] = []; diff --git a/src/lib/utils/options/readers/arguments.ts b/src/lib/utils/options/readers/arguments.ts index 70b25bafb..a0f5a7228 100644 --- a/src/lib/utils/options/readers/arguments.ts +++ b/src/lib/utils/options/readers/arguments.ts @@ -1,4 +1,5 @@ import * as ts from "typescript"; +import * as _ts from "../../../ts-internal"; import {Component} from "../../component"; import {DiscoverEvent, OptionsComponent} from "../options"; @@ -52,10 +53,10 @@ export class ArgumentsReader extends OptionsComponent while (index < args.length) { var arg = args[index++]; - if (arg.charCodeAt(0) === ts.CharacterCodes.at) { + if (arg.charCodeAt(0) === _ts.CharacterCodes.at) { this.parseResponseFile(event, arg.slice(1)); - } else if (arg.charCodeAt(0) === ts.CharacterCodes.minus) { - readArgument(arg.slice(arg.charCodeAt(1) === ts.CharacterCodes.minus ? 2 : 1).toLowerCase()); + } else if (arg.charCodeAt(0) === _ts.CharacterCodes.minus) { + readArgument(arg.slice(arg.charCodeAt(1) === _ts.CharacterCodes.minus ? 2 : 1).toLowerCase()); } else { event.addInputFile(arg); } @@ -80,13 +81,13 @@ export class ArgumentsReader extends OptionsComponent var args:string[] = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= ts.CharacterCodes.space) pos++; + while (pos < text.length && text.charCodeAt(pos) <= _ts.CharacterCodes.space) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === ts.CharacterCodes.doubleQuote) { + if (text.charCodeAt(start) === _ts.CharacterCodes.doubleQuote) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== ts.CharacterCodes.doubleQuote) pos++; + while (pos < text.length && text.charCodeAt(pos) !== _ts.CharacterCodes.doubleQuote) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); pos++; @@ -95,7 +96,7 @@ export class ArgumentsReader extends OptionsComponent return; } } else { - while (text.charCodeAt(pos) > ts.CharacterCodes.space) pos++; + while (text.charCodeAt(pos) > _ts.CharacterCodes.space) pos++; args.push(text.substring(start, pos)); } } diff --git a/src/lib/utils/options/sources/typescript.ts b/src/lib/utils/options/sources/typescript.ts index b7ad5e469..07a2946e6 100644 --- a/src/lib/utils/options/sources/typescript.ts +++ b/src/lib/utils/options/sources/typescript.ts @@ -1,4 +1,6 @@ import * as ts from "typescript"; +import * as _ts from "../../../ts-internal"; + import {Component} from "../../component"; import {OptionsComponent} from "../options"; @@ -28,7 +30,7 @@ export class TypeScriptSource extends OptionsComponent var ignored = TypeScriptSource.IGNORED; this.declarations = []; - for (var declaration of ts.optionDeclarations) { + for (var declaration of _ts.optionDeclarations) { if (ignored.indexOf(declaration.name) === -1) { this.addTSOption(declaration); } @@ -44,7 +46,7 @@ export class TypeScriptSource extends OptionsComponent } - private addTSOption(option:ts.CommandLineOption) { + private addTSOption(option:_ts.CommandLineOption) { var param:IOptionDeclaration = { name: option.name, short: option.shortName, @@ -67,16 +69,16 @@ export class TypeScriptSource extends OptionsComponent param.type = ParameterType.Map; param.map = option.type; if (option['error']) { - var error = ts.createCompilerDiagnostic(option['error']); + var error = _ts.createCompilerDiagnostic(option['error']); param.mapError = ts.flattenDiagnosticMessageText(error.messageText, ', '); } } switch (option.paramType) { - case ts.Diagnostics.FILE: + case _ts.Diagnostics.FILE: param.hint = ParameterHint.File; break; - case ts.Diagnostics.DIRECTORY: + case _ts.Diagnostics.DIRECTORY: param.hint = ParameterHint.Directory; break; } diff --git a/tsconfig.json b/tsconfig.json index d10d16df1..e211d239c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,11 +15,11 @@ "files": [ "src/lib/application.ts", "src/lib/cli.ts", + "src/lib/ts-internal.ts", "src/lib/converter/components.ts", "src/lib/converter/context.ts", "src/lib/converter/convert-expression.ts", "src/lib/converter/converter.ts", - "src/lib/converter/ts-internal.ts", "src/lib/converter/factories/comment.ts", "src/lib/converter/factories/declaration.ts", "src/lib/converter/factories/index.ts",