Silently ignore identifiers with missing types
This commit is contained in:
parent
21075b81a6
commit
587ac52c05
1 changed files with 14 additions and 3 deletions
17
src/main.ts
17
src/main.ts
|
@ -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) ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue