fix(compiler): collect non exported symbols in d.ts files (#19301)

TS treats all symbols in d.ts files as exported,
whether they have an `export` keyword or not.

PR Close #19301
This commit is contained in:
Tobias Bosch
2017-09-20 16:25:08 -07:00
committed by Igor Minar
parent b826e0c636
commit 62602b9bd8
2 changed files with 21 additions and 10 deletions

View File

@ -12,16 +12,7 @@ import {Evaluator, errorSymbol} from './evaluator';
import {ClassMetadata, ConstructorMetadata, FunctionMetadata, InterfaceMetadata, MemberMetadata, MetadataEntry, MetadataError, MetadataMap, MetadataSymbolicBinaryExpression, MetadataSymbolicCallExpression, MetadataSymbolicExpression, MetadataSymbolicIfExpression, MetadataSymbolicIndexExpression, MetadataSymbolicPrefixExpression, MetadataSymbolicReferenceExpression, MetadataSymbolicSelectExpression, MetadataSymbolicSpreadExpression, MetadataValue, MethodMetadata, ModuleExportMetadata, ModuleMetadata, VERSION, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataSymbolicExpression, isMetadataSymbolicReferenceExpression, isMetadataSymbolicSelectExpression, isMethodMetadata} from './schema';
import {Symbols} from './symbols';
// In TypeScript 2.1 these flags moved
// These helpers work for both 2.0 and 2.1.
const isExport = (ts as any).ModifierFlags ?
((node: ts.Node) =>
!!((ts as any).getCombinedModifierFlags(node) & (ts as any).ModifierFlags.Export)) :
((node: ts.Node) => !!((node.flags & (ts as any).NodeFlags.Export)));
const isStatic = (ts as any).ModifierFlags ?
((node: ts.Node) =>
!!((ts as any).getCombinedModifierFlags(node) & (ts as any).ModifierFlags.Static)) :
((node: ts.Node) => !!((node.flags & (ts as any).NodeFlags.Static)));
const isStatic = (node: ts.Node) => ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Static;
/**
* A set of collector options to use when collecting metadata.
@ -284,6 +275,8 @@ export class MetadataCollector {
}
});
const isExport = (node: ts.Node) =>
sourceFile.isDeclarationFile || ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export;
const isExportedIdentifier = (identifier?: ts.Identifier) =>
identifier && exportMap.has(identifier.text);
const isExported =