Silently ignore identifiers with missing types

This commit is contained in:
Dan Rosén 2017-11-15 13:17:18 +01:00
parent 21075b81a6
commit 587ac52c05

View file

@ -19,6 +19,15 @@ function flatten<A>(xss: A[][]): A[] {
return ([] as A[]).concat(...xss) return ([] as A[]).concat(...xss)
} }
function silently<A>(m: () => A): A | undefined {
try {
return m()
} catch (e) {
// console.error(e)
return undefined
}
}
type Top = {filename: string, defs: Defs}[] type Top = {filename: string, defs: Defs}[]
type Defs = Def[] type Defs = Def[]
@ -101,9 +110,11 @@ function generateDocumentation(program: ts.Program, filenames: string[]): Top {
|| ts.isClassDeclaration(node) || ts.isClassDeclaration(node)
|| ts.isTypeAliasDeclaration(node), || ts.isTypeAliasDeclaration(node),
type: type:
(symbol.valueDeclaration && !ts.isClassDeclaration(node)) silently(() =>
? checker.typeToString(checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration), node, 65535) (symbol.valueDeclaration && !ts.isClassDeclaration(node))
: undefined, ? checker.typeToString(checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration), node, 65535)
: undefined
),
children: [] children: []
} }
if ( ts.isInterfaceDeclaration(node) ) { if ( ts.isInterfaceDeclaration(node) ) {