chore(tools): Remove use of TypeChecker from metadata collector.

The metadata collector was modified to look up references in the
import list instead of resolving the symbol using the TypeChecker
making the use of the TypeChecker vestigial. This change removes
all uses of the TypeChecker.

Modified the schema to be able to record global and local (non-module
specific references).

Added error messages to the schema and errors are recorded in
the metadata file allowing the static reflector to throw errors
if an unsupported construct is referenced by metadata.

Closes #8966
Fixes #8893
Fixes #8894
This commit is contained in:
Chuck Jazdzewski
2016-05-31 11:00:39 -07:00
parent 13c39a52c6
commit 01dd7dde24
13 changed files with 656 additions and 353 deletions

View File

@ -121,7 +121,6 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
this.doFullBuild();
} else {
let program = this.tsService.getProgram();
let typeChecker = program.getTypeChecker();
tsEmitInternal = false;
pathsToEmit.forEach((tsFilePath) => {
let output = this.tsService.getEmitOutput(tsFilePath);
@ -139,7 +138,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
fs.writeFileSync(o.name, this.fixSourceMapSources(o.text), FS_OPTS);
if (endsWith(o.name, '.d.ts')) {
const sourceFile = program.getSourceFile(tsFilePath);
this.emitMetadata(o.name, sourceFile, typeChecker);
this.emitMetadata(o.name, sourceFile);
}
});
}
@ -210,7 +209,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
const originalFile = absoluteFilePath.replace(this.tsOpts.outDir, this.tsOpts.rootDir)
.replace(/\.d\.ts$/, '.ts');
const sourceFile = program.getSourceFile(originalFile);
this.emitMetadata(absoluteFilePath, sourceFile, typeChecker);
this.emitMetadata(absoluteFilePath, sourceFile);
}
});
@ -256,10 +255,9 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
* Emit a .metadata.json file to correspond to the .d.ts file if the module contains classes that
* use decorators or exported constants.
*/
private emitMetadata(
dtsFileName: string, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker) {
private emitMetadata(dtsFileName: string, sourceFile: ts.SourceFile) {
if (sourceFile) {
const metadata = this.metadataCollector.getMetadata(sourceFile, typeChecker);
const metadata = this.metadataCollector.getMetadata(sourceFile);
if (metadata && metadata.metadata) {
const metadataText = JSON.stringify(metadata);
const metadataFileName = dtsFileName.replace(/\.d.ts$/, '.metadata.json');