@@ -295,6 +295,10 @@ export default class DeclarationTranspiler extends base.TranspilerBase {
295
295
let propertyDecl = < ts . PropertyDeclaration | ts . VariableDeclaration > node ;
296
296
// We need to emit these as properties not fields.
297
297
if ( ! this . promoteFunctionLikeMembers || ! isFunctionLikeProperty ( propertyDecl , this . tc ) ) {
298
+ // Suppress the prototype member
299
+ if ( base . ident ( propertyDecl . name ) === 'prototype' ) {
300
+ return ;
301
+ }
298
302
orderedGroups . push ( [ node ] ) ;
299
303
return ;
300
304
}
@@ -611,18 +615,17 @@ export default class DeclarationTranspiler extends base.TranspilerBase {
611
615
this . emit ( '/* WARNING: export assignment not yet supported. */\n' ) ;
612
616
break ;
613
617
case ts . SyntaxKind . TypeAliasDeclaration : {
614
- // Object literal type alias declarations can be treated like interface declarations.
615
- let alias = < ts . TypeAliasDeclaration > node ;
616
- let type = alias . type ;
617
- if ( type . kind === ts . SyntaxKind . TypeLiteral ) {
618
- let literal = < ts . TypeLiteralNode > type ;
618
+ const alias = < ts . TypeAliasDeclaration > node ;
619
+ const type = alias . type ;
620
+ if ( ts . isTypeLiteralNode ( type ) ) {
621
+ // Object literal type alias declarations can be treated like interface declarations.
622
+ const literal = type ;
619
623
this . emit ( '@anonymous\n@JS()\n' ) ;
620
624
this . visitClassLikeHelper (
621
625
'abstract class' , literal , alias . name , alias . typeParameters , null ) ;
622
- } else if ( type . kind === ts . SyntaxKind . FunctionType ) {
626
+ } else if ( ts . isFunctionTypeNode ( type ) ) {
623
627
// Function type alias definitions are equivalent to dart typedefs.
624
- this . visitFunctionTypedefInterface (
625
- base . ident ( alias . name ) , type as ts . FunctionTypeNode , alias . typeParameters ) ;
628
+ this . visitFunctionTypedefInterface ( base . ident ( alias . name ) , type , alias . typeParameters ) ;
626
629
} else {
627
630
this . enterCodeComment ( ) ;
628
631
if ( ts . isMappedTypeNode ( alias . type ) ) {
@@ -691,6 +694,17 @@ export default class DeclarationTranspiler extends base.TranspilerBase {
691
694
case ts . SyntaxKind . Constructor :
692
695
case ts . SyntaxKind . ConstructSignature : {
693
696
const ctorDecl = < ts . ConstructorDeclaration > node ;
697
+ if ( ts . isTypeLiteralNode ( node . parent ) ) {
698
+ // All constructors within TypeLiteralNodes should have been merged into corresponding
699
+ // classes. The only exception is this case, where there exist aliases to those literals.
700
+ this . emit ( '// Skipping constructor from aliased type.\n' ) ;
701
+ this . enterCodeComment ( ) ;
702
+ this . emit ( 'new' ) ;
703
+ this . visitParameters ( ctorDecl . parameters , { namesOnly : false } ) ;
704
+ this . emitNoSpace ( ';' ) ;
705
+ this . exitCodeComment ( ) ;
706
+ break ;
707
+ }
694
708
// Find containing class name.
695
709
let classDecl = base . getEnclosingClass ( ctorDecl ) ;
696
710
if ( ! classDecl ) this . reportError ( ctorDecl , 'cannot find outer class node' ) ;
@@ -802,7 +816,7 @@ export default class DeclarationTranspiler extends base.TranspilerBase {
802
816
this . fc . visitTypeName ( name ) ;
803
817
}
804
818
805
- if ( fn . typeParameters ) {
819
+ if ( fn . typeParameters && fn . typeParameters . length > 0 ) {
806
820
let insideComment = this . insideCodeComment ;
807
821
if ( ! insideComment ) {
808
822
this . enterCodeComment ( ) ;
@@ -928,7 +942,7 @@ export default class DeclarationTranspiler extends base.TranspilerBase {
928
942
this . emitNoSpace ( 'Extensions' ) ;
929
943
}
930
944
931
- if ( typeParameters ) {
945
+ if ( typeParameters && typeParameters . length > 0 ) {
932
946
this . emit ( '<' ) ;
933
947
this . enterTypeArguments ( ) ;
934
948
this . visitList ( typeParameters ) ;
0 commit comments