| OLD | NEW |
| 1 import * as ts from 'typescript'; | 1 import * as ts from 'typescript'; |
| 2 | 2 |
| 3 import * as base from './base'; | 3 import * as base from './base'; |
| 4 import {FacadeConverter} from './facade_converter'; | 4 import {FacadeConverter} from './facade_converter'; |
| 5 import {Transpiler} from './main'; | 5 import {Transpiler} from './main'; |
| 6 import {MergedParameter, MergedType, MergedTypeParameters} from './merge'; | 6 import {MergedParameter, MergedType, MergedTypeParameters} from './merge'; |
| 7 | 7 |
| 8 export function isFunctionLikeProperty( | 8 export function isFunctionLikeProperty( |
| 9 decl: ts.PropertyDeclaration|ts.ParameterDeclaration, tc: ts.TypeChecker): b
oolean { | 9 decl: ts.PropertyDeclaration|ts.ParameterDeclaration, tc: ts.TypeChecker): b
oolean { |
| 10 if (!decl.type) return false; | 10 if (!decl.type) return false; |
| 11 // Only properties with simple identifier names are candidates to treat as fun
ctions. | 11 // Only properties with simple identifier names are candidates to treat as fun
ctions. |
| 12 if (decl.name.kind !== ts.SyntaxKind.Identifier) return false; | 12 if (decl.name.kind !== ts.SyntaxKind.Identifier) return false; |
| 13 let name = base.ident(decl.name); | 13 let name = base.ident(decl.name); |
| 14 if (name.match(/^on[A-Z]/)) return false; | 14 if (name.match(/^on[A-Z]/)) return false; |
| 15 return base.isFunctionType(decl.type, tc); | 15 return base.isFunctionType(decl.type, tc); |
| 16 } | 16 } |
| 17 | 17 |
| 18 export default class DeclarationTranspiler extends base.TranspilerBase { | 18 export default class DeclarationTranspiler extends base.TranspilerBase { |
| 19 private tc: ts.TypeChecker; | 19 private tc: ts.TypeChecker; |
| 20 | 20 |
| 21 private extendsClass: boolean = false; | 21 private extendsClass: boolean = false; |
| 22 | 22 |
| 23 static NUM_FAKE_REST_PARAMETERS = 5; | 23 static NUM_FAKE_REST_PARAMETERS = 5; |
| 24 | 24 |
| 25 setTypeChecker(tc: ts.TypeChecker) { this.tc = tc; } | 25 setTypeChecker(tc: ts.TypeChecker) { |
| 26 setFacadeConverter(fc: FacadeConverter) { this.fc = fc; } | 26 this.tc = tc; |
| 27 } |
| 28 setFacadeConverter(fc: FacadeConverter) { |
| 29 this.fc = fc; |
| 30 } |
| 27 | 31 |
| 28 getJsPath(node: ts.Node, suppressUnneededPaths = true): string { | 32 getJsPath(node: ts.Node, suppressUnneededPaths = true): string { |
| 29 let path: Array<String> = []; | 33 let path: Array<String> = []; |
| 30 let moduleDecl = | 34 let moduleDecl = |
| 31 base.getAncestor(node, ts.SyntaxKind.ModuleDeclaration) as ts.ModuleDecl
aration; | 35 base.getAncestor(node, ts.SyntaxKind.ModuleDeclaration) as ts.ModuleDecl
aration; |
| 32 while (moduleDecl != null) { | 36 while (moduleDecl != null) { |
| 33 path.unshift(moduleDecl.name.text); | 37 path.unshift(moduleDecl.name.text); |
| 34 moduleDecl = | 38 moduleDecl = |
| 35 base.getAncestor( | 39 base.getAncestor( |
| 36 moduleDecl.parent, ts.SyntaxKind.ModuleDeclaration) as ts.Modu
leDeclaration; | 40 moduleDecl.parent, ts.SyntaxKind.ModuleDeclaration) as ts.Modu
leDeclaration; |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 this.emitNoSpace('<'); | 888 this.emitNoSpace('<'); |
| 885 this.enterTypeArguments(); | 889 this.enterTypeArguments(); |
| 886 this.visitList(typeParameters); | 890 this.visitList(typeParameters); |
| 887 this.exitTypeArguments(); | 891 this.exitTypeArguments(); |
| 888 this.emitNoSpace('>'); | 892 this.emitNoSpace('>'); |
| 889 } | 893 } |
| 890 this.visitParameters(signature.parameters); | 894 this.visitParameters(signature.parameters); |
| 891 this.emitNoSpace(';'); | 895 this.emitNoSpace(';'); |
| 892 } | 896 } |
| 893 } | 897 } |
| OLD | NEW |