fix(compiler-cli): fix types
This commit is contained in:
parent
d321b0ebf5
commit
ef153649b3
|
@ -25,7 +25,7 @@ export interface StaticReflectorHost {
|
||||||
* @param modulePath is a string identifier for a module as an absolute path.
|
* @param modulePath is a string identifier for a module as an absolute path.
|
||||||
* @returns the metadata for the given module.
|
* @returns the metadata for the given module.
|
||||||
*/
|
*/
|
||||||
getMetadataFor(modulePath: string): {[key: string]: any};
|
getMetadataFor(modulePath: string): {[key: string]: any}|{[key: string]: any}[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a symbol from an import statement form, to the file where it is declared.
|
* Resolve a symbol from an import statement form, to the file where it is declared.
|
||||||
|
@ -72,13 +72,12 @@ export class StaticReflector implements ReflectorReader {
|
||||||
constructor(private host: StaticReflectorHost) { this.initializeConversionMap(); }
|
constructor(private host: StaticReflectorHost) { this.initializeConversionMap(); }
|
||||||
|
|
||||||
importUri(typeOrFunc: StaticSymbol): string {
|
importUri(typeOrFunc: StaticSymbol): string {
|
||||||
var staticSymbol = this.host.findDeclaration(typeOrFunc.filePath, typeOrFunc.name, '');
|
const staticSymbol = this.host.findDeclaration(typeOrFunc.filePath, typeOrFunc.name, '');
|
||||||
return staticSymbol ? staticSymbol.filePath : null;
|
return staticSymbol ? staticSymbol.filePath : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any {
|
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any {
|
||||||
const result = this.host.findDeclaration(moduleUrl, name, '');
|
return this.host.findDeclaration(moduleUrl, name, '');
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveEnum(enumIdentifier: any, name: string): any {
|
resolveEnum(enumIdentifier: any, name: string): any {
|
||||||
|
@ -238,9 +237,9 @@ export class StaticReflector implements ReflectorReader {
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
public simplify(context: StaticSymbol, value: any): any {
|
public simplify(context: StaticSymbol, value: any): any {
|
||||||
let _this = this;
|
const _this = this;
|
||||||
let scope = BindingScope.empty;
|
let scope = BindingScope.empty;
|
||||||
let calling = new Map<StaticSymbol, boolean>();
|
const calling = new Map<StaticSymbol, boolean>();
|
||||||
|
|
||||||
function simplifyInContext(context: StaticSymbol, value: any, depth: number): any {
|
function simplifyInContext(context: StaticSymbol, value: any, depth: number): any {
|
||||||
function resolveReference(context: StaticSymbol, expression: any): StaticSymbol {
|
function resolveReference(context: StaticSymbol, expression: any): StaticSymbol {
|
||||||
|
@ -255,16 +254,15 @@ export class StaticReflector implements ReflectorReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveReferenceValue(staticSymbol: StaticSymbol): any {
|
function resolveReferenceValue(staticSymbol: StaticSymbol): any {
|
||||||
let result: any = staticSymbol;
|
const moduleMetadata = _this.getModuleMetadata(staticSymbol.filePath);
|
||||||
let moduleMetadata = _this.getModuleMetadata(staticSymbol.filePath);
|
const declarationValue =
|
||||||
let declarationValue =
|
|
||||||
moduleMetadata ? moduleMetadata['metadata'][staticSymbol.name] : null;
|
moduleMetadata ? moduleMetadata['metadata'][staticSymbol.name] : null;
|
||||||
return declarationValue;
|
return declarationValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOpaqueToken(context: StaticSymbol, value: any): boolean {
|
function isOpaqueToken(context: StaticSymbol, value: any): boolean {
|
||||||
if (value && value.__symbolic === 'new' && value.expression) {
|
if (value && value.__symbolic === 'new' && value.expression) {
|
||||||
let target = value.expression;
|
const target = value.expression;
|
||||||
if (target.__symbolic == 'reference') {
|
if (target.__symbolic == 'reference') {
|
||||||
return sameSymbol(resolveReference(context, target), _this.opaqueToken);
|
return sameSymbol(resolveReference(context, target), _this.opaqueToken);
|
||||||
}
|
}
|
||||||
|
@ -535,7 +533,7 @@ export class StaticReflector implements ReflectorReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = simplifyInContext(context, value, 0);
|
const result = simplifyInContext(context, value, 0);
|
||||||
if (shouldIgnore(result)) {
|
if (shouldIgnore(result)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -550,8 +548,7 @@ export class StaticReflector implements ReflectorReader {
|
||||||
if (!moduleMetadata) {
|
if (!moduleMetadata) {
|
||||||
moduleMetadata = this.host.getMetadataFor(module);
|
moduleMetadata = this.host.getMetadataFor(module);
|
||||||
if (Array.isArray(moduleMetadata)) {
|
if (Array.isArray(moduleMetadata)) {
|
||||||
moduleMetadata = (<Array<any>>moduleMetadata)
|
moduleMetadata = moduleMetadata.find(md => md['version'] === SUPPORTED_SCHEMA_VERSION) ||
|
||||||
.find(element => element.version === SUPPORTED_SCHEMA_VERSION) ||
|
|
||||||
moduleMetadata[0];
|
moduleMetadata[0];
|
||||||
}
|
}
|
||||||
if (!moduleMetadata) {
|
if (!moduleMetadata) {
|
||||||
|
@ -568,12 +565,8 @@ export class StaticReflector implements ReflectorReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTypeMetadata(type: StaticSymbol): {[key: string]: any} {
|
private getTypeMetadata(type: StaticSymbol): {[key: string]: any} {
|
||||||
let moduleMetadata = this.getModuleMetadata(type.filePath);
|
const moduleMetadata = this.getModuleMetadata(type.filePath);
|
||||||
let result = moduleMetadata['metadata'][type.name];
|
return moduleMetadata['metadata'][type.name] || {__symbolic: 'class'};
|
||||||
if (!result) {
|
|
||||||
result = {__symbolic: 'class'};
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +606,7 @@ function produceErrorMessage(error: any): string {
|
||||||
function mapStringMap(input: {[key: string]: any}, transform: (value: any, key: string) => any):
|
function mapStringMap(input: {[key: string]: any}, transform: (value: any, key: string) => any):
|
||||||
{[key: string]: any} {
|
{[key: string]: any} {
|
||||||
if (!input) return {};
|
if (!input) return {};
|
||||||
var result: {[key: string]: any} = {};
|
const result: {[key: string]: any} = {};
|
||||||
Object.keys(input).forEach((key) => {
|
Object.keys(input).forEach((key) => {
|
||||||
let value = transform(input[key], key);
|
let value = transform(input[key], key);
|
||||||
if (!shouldIgnore(value)) {
|
if (!shouldIgnore(value)) {
|
||||||
|
@ -638,8 +631,7 @@ abstract class BindingScope {
|
||||||
public static empty: BindingScope = {resolve: name => BindingScope.missing};
|
public static empty: BindingScope = {resolve: name => BindingScope.missing};
|
||||||
|
|
||||||
public static build(): BindingScopeBuilder {
|
public static build(): BindingScopeBuilder {
|
||||||
let current = new Map<string, any>();
|
const current = new Map<string, any>();
|
||||||
let parent: BindingScope = undefined;
|
|
||||||
return {
|
return {
|
||||||
define: function(name, value) {
|
define: function(name, value) {
|
||||||
current.set(name, value);
|
current.set(name, value);
|
||||||
|
|
Loading…
Reference in New Issue