fix(compiler): use either summary or metadata information when reading .d.ts files (#18912)

This fix applies for getting all symbols in file.

PR Close #18912
This commit is contained in:
Tobias Bosch
2017-08-28 15:51:27 -07:00
committed by Jason Aden
parent 83e5deb988
commit f1e526f046
4 changed files with 47 additions and 39 deletions

View File

@ -269,17 +269,20 @@ export class StaticSymbolResolver {
}
getSymbolsOf(filePath: string): StaticSymbol[] {
const summarySymbols = this.summaryResolver.getSymbolsOf(filePath);
if (summarySymbols) {
return summarySymbols;
}
// Note: Some users use libraries that were not compiled with ngc, i.e. they don't
// have summaries, only .d.ts files. So we always need to check both, the summary
// and metadata.
let symbols = new Set<StaticSymbol>(this.summaryResolver.getSymbolsOf(filePath));
// have summaries, only .d.ts files, but `summaryResolver.isLibraryFile` returns true.
this._createSymbolsOf(filePath);
const metadataSymbols: StaticSymbol[] = [];
this.resolvedSymbols.forEach((resolvedSymbol) => {
if (resolvedSymbol.symbol.filePath === filePath) {
symbols.add(resolvedSymbol.symbol);
metadataSymbols.push(resolvedSymbol.symbol);
}
});
return Array.from(symbols);
return metadataSymbols;
}
private _createSymbolsOf(filePath: string) {