parent
78946fe9fa
commit
96ae348648
|
@ -483,8 +483,8 @@ function runTsc(project, done) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('test.js', function(done) {
|
gulp.task('test.js', function(done) {
|
||||||
runSequence('test.unit.tools/ci', 'test.transpiler.unittest', 'test.unit.js/ci',
|
runSequence('test.compiler_cli', 'test.unit.tools/ci', 'test.transpiler.unittest',
|
||||||
'test.unit.cjs/ci', 'test.compiler_cli', 'test.typings', 'check-public-api',
|
'test.unit.js/ci', 'test.unit.cjs/ci', 'test.typings', 'check-public-api',
|
||||||
sequenceComplete(done));
|
sequenceComplete(done));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ export interface StaticReflectorHost {
|
||||||
*
|
*
|
||||||
* This token is unique for a moduleId and name and can be used as a hash table key.
|
* This token is unique for a moduleId and name and can be used as a hash table key.
|
||||||
*/
|
*/
|
||||||
export class StaticSymbol {
|
export class StaticSymbol implements ModuleContext {
|
||||||
constructor(public moduleId: string, public filePath: string, public name: string) {}
|
constructor(public moduleId: string, public filePath: string, public name: string) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ export class StaticReflector implements ReflectorReader {
|
||||||
if (isClassMetadata(declarationValue)) {
|
if (isClassMetadata(declarationValue)) {
|
||||||
result = staticSymbol;
|
result = staticSymbol;
|
||||||
} else {
|
} else {
|
||||||
const newModuleContext =
|
let newModuleContext =
|
||||||
new ModuleContext(staticSymbol.moduleId, staticSymbol.filePath);
|
new ModuleContext(staticSymbol.moduleId, staticSymbol.filePath);
|
||||||
result = _this.simplify(newModuleContext, declarationValue, crossModules);
|
result = _this.simplify(newModuleContext, declarationValue, crossModules);
|
||||||
}
|
}
|
||||||
|
@ -382,9 +382,6 @@ export class StaticReflector implements ReflectorReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTypeMetadata(type: StaticSymbol): {[key: string]: any} {
|
private getTypeMetadata(type: StaticSymbol): {[key: string]: any} {
|
||||||
if (!(type instanceof StaticSymbol)) {
|
|
||||||
throw new Error('not static type');
|
|
||||||
}
|
|
||||||
let moduleMetadata = this.getModuleMetadata(type.filePath);
|
let moduleMetadata = this.getModuleMetadata(type.filePath);
|
||||||
let result = moduleMetadata['metadata'][type.name];
|
let result = moduleMetadata['metadata'][type.name];
|
||||||
if (!isPresent(result)) {
|
if (!isPresent(result)) {
|
||||||
|
|
|
@ -234,13 +234,13 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should simplify a module reference across modules', () => {
|
it('should simplify a module reference across modules', () => {
|
||||||
expect(crossModuleSimplify({moduleId: '', filePath: '/src/cases'},
|
expect(crossModuleSimplify(new ModuleContext('', '/src/cases'),
|
||||||
({__symbolic: "reference", module: "./extern", name: "s"})))
|
({__symbolic: "reference", module: "./extern", name: "s"})))
|
||||||
.toEqual("s");
|
.toEqual("s");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should simplify a module reference without crossing modules', () => {
|
it('should simplify a module reference without crossing modules', () => {
|
||||||
expect(singleModuleSimplify({moduleId: '', filePath: '/src/cases'},
|
expect(singleModuleSimplify(new ModuleContext('', '/src/cases'),
|
||||||
({__symbolic: "reference", module: "./extern", name: "s"})))
|
({__symbolic: "reference", module: "./extern", name: "s"})))
|
||||||
.toEqual(host.getStaticSymbol('', '/src/extern.d.ts', 's'));
|
.toEqual(host.getStaticSymbol('', '/src/extern.d.ts', 's'));
|
||||||
});
|
});
|
||||||
|
@ -261,7 +261,7 @@ class MockReflectorHost implements StaticReflectorHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In tests, assume that symbols are not re-exported
|
// In tests, assume that symbols are not re-exported
|
||||||
findDeclaration(modulePath: string, symbolName: string, containingFile: string): StaticSymbol {
|
findDeclaration(modulePath: string, symbolName: string, containingFile?: string): StaticSymbol {
|
||||||
function splitPath(path: string): string[] { return path.split(/\/|\\/g); }
|
function splitPath(path: string): string[] { return path.split(/\/|\\/g); }
|
||||||
|
|
||||||
function resolvePath(pathParts: string[]): string {
|
function resolvePath(pathParts: string[]): string {
|
||||||
|
|
|
@ -14,14 +14,14 @@ export function main() {
|
||||||
|
|
||||||
// A service available to the Injector, used by the HelloCmp component.
|
// A service available to the Injector, used by the HelloCmp component.
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class GreetingService {
|
export class GreetingService {
|
||||||
greeting: string = 'hello';
|
greeting: string = 'hello';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Directives are light-weight. They don't allow new
|
// Directives are light-weight. They don't allow new
|
||||||
// expression contexts (use @Component for those needs).
|
// expression contexts (use @Component for those needs).
|
||||||
@Directive({selector: '[red]'})
|
@Directive({selector: '[red]'})
|
||||||
class RedDec {
|
export class RedDec {
|
||||||
// ElementRef is always injectable and it wraps the element on which the
|
// ElementRef is always injectable and it wraps the element on which the
|
||||||
// directive was found by the compiler.
|
// directive was found by the compiler.
|
||||||
constructor(el: ElementRef, renderer: Renderer) {
|
constructor(el: ElementRef, renderer: Renderer) {
|
||||||
|
@ -34,8 +34,6 @@ class RedDec {
|
||||||
// ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/)
|
// ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/)
|
||||||
// - Directive - add behavior to existing elements.
|
// - Directive - add behavior to existing elements.
|
||||||
|
|
||||||
// @Component is AtScript syntax to annotate the HelloCmp class as an Angular
|
|
||||||
// 2.0 component.
|
|
||||||
@Component({
|
@Component({
|
||||||
// The Selector prop tells Angular on which elements to instantiate this
|
// The Selector prop tells Angular on which elements to instantiate this
|
||||||
// class. The syntax supported is a basic subset of CSS selectors, for example
|
// class. The syntax supported is a basic subset of CSS selectors, for example
|
||||||
|
|
|
@ -24,8 +24,6 @@ class RedDec {
|
||||||
// ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/)
|
// ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/)
|
||||||
// - Directive - add behavior to existing elements.
|
// - Directive - add behavior to existing elements.
|
||||||
|
|
||||||
// @Component is AtScript syntax to annotate the HelloCmp class as an Angular
|
|
||||||
// 2.0 component.
|
|
||||||
@Component({
|
@Component({
|
||||||
// The Selector prop tells Angular on which elements to instantiate this
|
// The Selector prop tells Angular on which elements to instantiate this
|
||||||
// class. The syntax supported is a basic subset of CSS selectors, for example
|
// class. The syntax supported is a basic subset of CSS selectors, for example
|
||||||
|
|
|
@ -68,7 +68,7 @@ export class NodeReflectorHost implements StaticReflectorHost {
|
||||||
if (!symbol) {
|
if (!symbol) {
|
||||||
throw new Error(`can't find symbol ${symbolName} exported from module ${filePath}`);
|
throw new Error(`can't find symbol ${symbolName} exported from module ${filePath}`);
|
||||||
}
|
}
|
||||||
while (symbol &&
|
if (symbol &&
|
||||||
symbol.flags & ts.SymbolFlags.Alias) { // This is an alias, follow what it aliases
|
symbol.flags & ts.SymbolFlags.Alias) { // This is an alias, follow what it aliases
|
||||||
symbol = tc.getAliasedSymbol(symbol);
|
symbol = tc.getAliasedSymbol(symbol);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,18 +117,20 @@ describe('Evaluator', () => {
|
||||||
expect(evaluator.evaluateNode(findVar(forwardRef, 'bFalse').initializer)).toEqual(false);
|
expect(evaluator.evaluateNode(findVar(forwardRef, 'bFalse').initializer)).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return new expressions', () => {
|
fit('should return new expressions', () => {
|
||||||
|
evaluator =
|
||||||
|
new Evaluator(typeChecker, symbols, [{from: './classes', namedImports: [{name: 'Value'}]}]);
|
||||||
var newExpression = program.getSourceFile('newExpression.ts');
|
var newExpression = program.getSourceFile('newExpression.ts');
|
||||||
expect(evaluator.evaluateNode(findVar(newExpression, 'someValue').initializer))
|
expect(evaluator.evaluateNode(findVar(newExpression, 'someValue').initializer))
|
||||||
.toEqual({
|
.toEqual({
|
||||||
__symbolic: "new",
|
__symbolic: "new",
|
||||||
expression: {__symbolic: "reference", name: "Value", module: "classes.ts"},
|
expression: {__symbolic: "reference", name: "Value", module: "./classes"},
|
||||||
arguments: ["name", 12]
|
arguments: ["name", 12]
|
||||||
});
|
});
|
||||||
expect(evaluator.evaluateNode(findVar(newExpression, 'complex').initializer))
|
expect(evaluator.evaluateNode(findVar(newExpression, 'complex').initializer))
|
||||||
.toEqual({
|
.toEqual({
|
||||||
__symbolic: "new",
|
__symbolic: "new",
|
||||||
expression: {__symbolic: "reference", name: "Value", module: "classes.ts"},
|
expression: {__symbolic: "reference", name: "Value", module: "./classes"},
|
||||||
arguments: ["name", 12]
|
arguments: ["name", 12]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ const COMPILER = [
|
||||||
'CompileDirectiveMetadata.type:CompileTypeMetadata',
|
'CompileDirectiveMetadata.type:CompileTypeMetadata',
|
||||||
'CompileDirectiveMetadata.viewQueries:CompileQueryMetadata[]',
|
'CompileDirectiveMetadata.viewQueries:CompileQueryMetadata[]',
|
||||||
'CompileTemplateMetadata',
|
'CompileTemplateMetadata',
|
||||||
'CompileTemplateMetadata.constructor({encapsulation,template,templateUrl,styles,styleUrls,ngContentSelectors}:{encapsulation?:ViewEncapsulation, template?:string, templateUrl?:string, styles?:string[], styleUrls?:string[], ngContentSelectors?:string[]})',
|
'CompileTemplateMetadata.constructor({encapsulation,template,templateUrl,styles,styleUrls,ngContentSelectors,baseUrl}:{encapsulation?:ViewEncapsulation, template?:string, templateUrl?:string, styles?:string[], styleUrls?:string[], ngContentSelectors?:string[], baseUrl?:string})',
|
||||||
'CompileTemplateMetadata.encapsulation:ViewEncapsulation',
|
'CompileTemplateMetadata.encapsulation:ViewEncapsulation',
|
||||||
'CompileTemplateMetadata.fromJson(data:{[key:string]:any}):CompileTemplateMetadata',
|
'CompileTemplateMetadata.fromJson(data:{[key:string]:any}):CompileTemplateMetadata',
|
||||||
'CompileTemplateMetadata.ngContentSelectors:string[]',
|
'CompileTemplateMetadata.ngContentSelectors:string[]',
|
||||||
|
@ -1040,6 +1040,7 @@ const COMPILER = [
|
||||||
'CompileTemplateMetadata.template:string',
|
'CompileTemplateMetadata.template:string',
|
||||||
'CompileTemplateMetadata.templateUrl:string',
|
'CompileTemplateMetadata.templateUrl:string',
|
||||||
'CompileTemplateMetadata.toJson():{[key:string]:any}',
|
'CompileTemplateMetadata.toJson():{[key:string]:any}',
|
||||||
|
'CompileTemplateMetadata.baseUrl:string',
|
||||||
'CompileTypeMetadata',
|
'CompileTypeMetadata',
|
||||||
'CompileTypeMetadata.diDeps:CompileDiDependencyMetadata[]',
|
'CompileTypeMetadata.diDeps:CompileDiDependencyMetadata[]',
|
||||||
'CompileTypeMetadata.fromJson(data:{[key:string]:any}):CompileTypeMetadata',
|
'CompileTypeMetadata.fromJson(data:{[key:string]:any}):CompileTypeMetadata',
|
||||||
|
|
Loading…
Reference in New Issue