Skip to content

Use private TypeScript APIs from internal module #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/converter/convert-expression.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../ts-internal";


/**
Expand Down Expand Up @@ -29,7 +30,7 @@ export function convertExpression(expression:ts.Expression):string
case ts.SyntaxKind.FalseKeyword:
return 'false';
default:
var source = ts.getSourceFileOfNode(<ts.Node>expression);
var source = _ts.getSourceFileOfNode(<ts.Node>expression);
return source.text.substring(expression.pos, expression.end);
}
}
3 changes: 2 additions & 1 deletion src/lib/converter/converter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../ts-internal";
import * as Path from "path";

import {Application} from "../application";
Expand Down Expand Up @@ -331,7 +332,7 @@ export class Converter extends ChildableComponent<Application, ConverterComponen
*/
convert(fileNames:string[]):IConverterResult {
for (var i = 0, c = fileNames.length; i < c; i++) {
fileNames[i] = normalizePath(ts.normalizeSlashes(fileNames[i]));
fileNames[i] = normalizePath(_ts.normalizeSlashes(fileNames[i]));
}

var program = ts.createProgram(fileNames, this.application.options.getCompilerOptions(), this.compilerHost);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converter/factories/comment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../../ts-internal";

import {Comment, CommentTag} from "../../models/comments/index";

Expand Down Expand Up @@ -86,8 +87,8 @@ export function getRawComment(node:ts.Node):string {
}
}

var sourceFile = ts.getSourceFileOfNode(node);
var comments = ts.getJsDocComments(node, sourceFile);
var sourceFile = _ts.getSourceFileOfNode(node);
var comments = _ts.getJsDocComments(node, sourceFile);
if (comments && comments.length) {
var comment:ts.CommentRange;
if (node.kind == ts.SyntaxKind.SourceFile) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/factories/parameter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../../ts-internal";

import {ReflectionFlag, ReflectionKind, ParameterReflection, SignatureReflection} from "../../models/reflections/index";
import {Context} from "../context";
Expand All @@ -22,7 +23,7 @@ export function createParameter(context:Context, node:ts.ParameterDeclaration):P
var parameter = new ParameterReflection(signature, node.symbol.name, ReflectionKind.Parameter);
context.registerReflection(parameter, node);
context.withScope(parameter, () => {
if (ts.isBindingPattern(node.name)) {
if (_ts.isBindingPattern(node.name)) {
parameter.type = context.converter.convertType(context, node.name);
parameter.name = '__namedParameters'
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converter/nodes/class.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -44,7 +45,7 @@ export class ClassConverter extends ConverterNodeComponent<ts.ClassDeclaration>
});
}

var baseType = ts.getClassExtendsHeritageClauseElement(node);
var baseType = _ts.getClassExtendsHeritageClauseElement(node);
if (baseType) {
var type = context.getTypeAtLocation(baseType);
if (!context.isInherit) {
Expand All @@ -59,7 +60,7 @@ export class ClassConverter extends ConverterNodeComponent<ts.ClassDeclaration>
}
}

var implementedTypes = ts.getClassImplementsHeritageClauseElements(node);
var implementedTypes = _ts.getClassImplementsHeritageClauseElements(node);
if (implementedTypes) {
implementedTypes.forEach((implementedType) => {
if (!reflection.implementedTypes) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/nodes/interface.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -39,7 +40,7 @@ export class InterfaceConverter extends ConverterNodeComponent<ts.InterfaceDecla
});
}

var baseTypes = ts.getInterfaceBaseTypeNodes(node);
var baseTypes = _ts.getInterfaceBaseTypeNodes(node);
if (baseTypes) {
baseTypes.forEach((baseType) => {
var type = context.getTypeAtLocation(baseType);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converter/nodes/variable-statement.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -26,7 +27,7 @@ export class VariableStatementConverter extends ConverterNodeComponent<ts.Variab
convert(context:Context, node:ts.VariableStatement):Reflection {
if (node.declarationList && node.declarationList.declarations) {
node.declarationList.declarations.forEach((variableDeclaration) => {
if (ts.isBindingPattern(variableDeclaration.name)) {
if (_ts.isBindingPattern(variableDeclaration.name)) {
this.convertBindingPattern(context, <ts.BindingPattern>variableDeclaration.name);
} else {
this.owner.convertNode(context, variableDeclaration);
Expand All @@ -48,7 +49,7 @@ export class VariableStatementConverter extends ConverterNodeComponent<ts.Variab
node.elements.forEach((element:ts.BindingElement) => {
this.owner.convertNode(context, <any>element);

if (ts.isBindingPattern(element.name)) {
if (_ts.isBindingPattern(element.name)) {
this.convertBindingPattern(context, <ts.BindingPattern>element.name);
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converter/nodes/variable.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -50,9 +51,9 @@ export class VariableConverter extends ConverterNodeComponent<ts.VariableDeclara
}

var name:string, isBindingPattern:boolean;
if (ts.isBindingPattern(node.name)) {
if (_ts.isBindingPattern(node.name)) {
if (node['propertyName']) {
name = ts.declarationNameToString(node['propertyName']);
name = _ts.declarationNameToString(node['propertyName']);
isBindingPattern = true;
} else {
return null;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/converter/plugins/DecoratorPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../../ts-internal";

import {ReferenceType} from "../../models/types/index";
import {Reflection, IDecorator} from "../../models/reflections/index";
Expand Down Expand Up @@ -40,10 +41,10 @@ export class DecoratorPlugin extends ConverterComponent
args.forEach((arg:ts.Expression, index:number) => {
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));
}
});

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/plugins/SourcePlugin.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);

Expand Down
130 changes: 0 additions & 130 deletions src/lib/converter/ts-internal.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/lib/converter/types/alias.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion src/lib/converter/types/type-parameter.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/utils/compiler-host.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../../ts-internal";
import * as Path from "path";

import {ConverterComponent} from "../components";
Expand Down Expand Up @@ -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);
}

Expand Down
Loading