@@ -20,6 +20,7 @@ const ignoreNode = "";
2020export  interface  ICompilerOptions  { 
2121  format ?: "ts"  |  "js:esm"  |  "js:cjs" 
2222  ignoreGenerics ?: boolean ; 
23+   ignoreNotSupported ?: boolean ; 
2324  ignoreIndexSignature ?: boolean ; 
2425  inlineImports ?: boolean ; 
2526} 
@@ -37,7 +38,7 @@ export class Compiler {
3738    if  ( ! topNode )  { 
3839      throw  new  Error ( `Can't process ${ filePath } ${ collectDiagnostics ( program ) }  ) ; 
3940    } 
40-     options  =  { format : defaultFormat ,  ignoreGenerics : false ,  ignoreIndexSignature : false ,  inlineImports : false ,  ...options } 
41+     options  =  { format : defaultFormat ,  ignoreGenerics : false ,  ignoreNotSupported :  false ,   ignoreIndexSignature : false ,  inlineImports : false ,  ...options } 
4142    return  new  Compiler ( checker ,  options ,  topNode ) . compileNode ( topNode ) ; 
4243  } 
4344
@@ -80,6 +81,8 @@ export class Compiler {
8081      case  ts . SyntaxKind . ExportDeclaration :
8182      case  ts . SyntaxKind . ImportDeclaration :
8283        return  this . _compileImportDeclaration ( node  as  ts . ImportDeclaration ) ; 
84+       case  ts . SyntaxKind . ModuleDeclaration :
85+         return  node . getSourceFile ( ) . statements . map ( this . compileNode ) . filter ( s  =>  s ) . join ( "\n\n" ) ; 
8386      case  ts . SyntaxKind . SourceFile : return  this . _compileSourceFile ( node  as  ts . SourceFile ) ; 
8487      case  ts . SyntaxKind . AnyKeyword : return  '"any"' ; 
8588      case  ts . SyntaxKind . NumberKeyword : return  '"number"' ; 
@@ -97,6 +100,12 @@ export class Compiler {
97100    } 
98101    // Skip top-level statements that we haven't handled. 
99102    if  ( ts . isSourceFile ( node . parent ! ) )  {  return  "" ;  } 
103+     
104+     if  ( this . options . ignoreNotSupported )  { 
105+       console . log ( `Node ${ ts . SyntaxKind [ node . kind ] }   + 
106+         node . getText ( ) ) ; 
107+       return  node . getText ( ) ; 
108+     } 
100109    throw  new  Error ( `Node ${ ts . SyntaxKind [ node . kind ] }   + 
101110      node . getText ( ) ) ; 
102111  } 
@@ -139,6 +148,8 @@ export class Compiler {
139148      return  this . compileNode ( node . typeArguments [ 0 ] ) ; 
140149    }  else  if  ( node . typeName . getText ( )  ===  "Array" )  { 
141150      return  `t.array(${ this . compileNode ( node . typeArguments [ 0 ] ) }  ; 
151+     }  else  if  ( node . typeName . getText ( )  ===  "Record" )  { 
152+       return  '"object"' ; 
142153    }  else  if  ( this . options . ignoreGenerics )  { 
143154      return  '"any"' ; 
144155    }  else  { 
@@ -302,6 +313,7 @@ export function main() {
302313  . option ( "--format <format>" ,  `Format to use for output; options are 'ts' (default), 'js:esm', 'js:cjs'` ) 
303314  . option ( "-g, --ignore-generics" ,  `Ignores generics` ) 
304315  . option ( "-i, --ignore-index-signature" ,  `Ignores index signature` ) 
316+   . option ( "--ignore-not-supported" ,  `Skip all not supported code` ) 
305317  . option ( "--inline-imports" ,  `Traverses the full import tree and inlines all types into output` ) 
306318  . option ( "-s, --suffix <suffix>" ,  `Suffix to append to generated files (default ${ defaultSuffix }  ,  defaultSuffix ) 
307319  . option ( "-o, --outDir <path>" ,  `Directory for output files; same as source file if omitted` ) 
@@ -317,6 +329,7 @@ export function main() {
317329  const  options : ICompilerOptions  =  { 
318330    format : commander . format  ||  defaultFormat , 
319331    ignoreGenerics : commander . ignoreGenerics , 
332+     ignoreNotSupported : commander . ignoreNotSupported , 
320333    ignoreIndexSignature : commander . ignoreIndexSignature , 
321334    inlineImports : commander . inlineImports , 
322335  } ; 
0 commit comments