refactor(tsc-wrapped): collect all exported functions and classes and bump metadata version from 1 to 2
This is needed to resolve symbols without `.d.ts` files. This bumps the version of the metadata from 1 to 2. This adds logic into `ng_host.ts` to automatically upgrade version 1 to version 2 metadata by adding the exported symbols from the `.d.ts` file.
This commit is contained in:

committed by
Chuck Jazdzewski

parent
bccf0e69dc
commit
dddbb1c1cb
@ -256,9 +256,11 @@ export class MetadataCollector {
|
||||
if (classDeclaration.name) {
|
||||
const className = classDeclaration.name.text;
|
||||
if (node.flags & ts.NodeFlags.Export) {
|
||||
if (!metadata) metadata = {};
|
||||
if (classDeclaration.decorators) {
|
||||
if (!metadata) metadata = {};
|
||||
metadata[className] = classMetadataOf(classDeclaration);
|
||||
} else {
|
||||
metadata[className] = {__symbolic: 'class'};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,10 +271,14 @@ export class MetadataCollector {
|
||||
// names substitution will be performed by the StaticReflector.
|
||||
const functionDeclaration = <ts.FunctionDeclaration>node;
|
||||
if (node.flags & ts.NodeFlags.Export) {
|
||||
if (!metadata) metadata = {};
|
||||
const maybeFunc = maybeGetSimpleFunction(functionDeclaration);
|
||||
if (maybeFunc) {
|
||||
if (!metadata) metadata = {};
|
||||
metadata[maybeFunc.name] = recordEntry(maybeFunc.func, node);
|
||||
} else if (functionDeclaration.name.kind == ts.SyntaxKind.Identifier) {
|
||||
const nameNode = <ts.Identifier>functionDeclaration.name;
|
||||
const functionName = nameNode.text;
|
||||
metadata[functionName] = {__symbolic: 'function'};
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -15,7 +15,7 @@
|
||||
// semantics of the file in an array. For example, when generating a version 2 file, if version 1
|
||||
// can accurately represent the metadata, generate both version 1 and version 2 in an array.
|
||||
|
||||
export const VERSION = 1;
|
||||
export const VERSION = 2;
|
||||
|
||||
export type MetadataEntry = ClassMetadata | FunctionMetadata | MetadataValue;
|
||||
|
||||
|
Reference in New Issue
Block a user