chore: Make field declarations explicit
This used to be valid code: ``` class Foo { constructor() { this.bar = ‘string’; } } ``` This will now fail since ‘bar’ is not explicitly defined as a field. We now have to write: ``` class Foo { bar:string; // << REQUIRED constructor() { this.bar = ‘string’; } } ```
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach} from 'test_lib/test_lib';
|
||||
import {bootstrap, appDocumentToken, appElementToken, documentDependentBindings}
|
||||
from 'core/application';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {DOM} from 'facade/dom';
|
||||
import {ListWrapper} from 'facade/collection';
|
||||
import {PromiseWrapper} from 'facade/async';
|
||||
@ -16,6 +16,7 @@ import {TemplateConfig} from 'core/annotations/template_config';
|
||||
})
|
||||
})
|
||||
class HelloRootCmp {
|
||||
greeting:string;
|
||||
constructor() {
|
||||
this.greeting = 'hello';
|
||||
}
|
||||
@ -29,6 +30,7 @@ class HelloRootCmp {
|
||||
})
|
||||
})
|
||||
class HelloRootCmp2 {
|
||||
greeting:string;
|
||||
constructor() {
|
||||
this.greeting = 'hello';
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import {Compiler} from 'core/compiler/compiler';
|
||||
import {ProtoView} from 'core/compiler/view';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {TemplateLoader} from 'core/compiler/template_loader';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
import {CompileElement} from 'core/compiler/pipeline/compile_element';
|
||||
import {CompileStep} from 'core/compiler/pipeline/compile_step'
|
||||
@ -98,6 +98,7 @@ class MainComponent {}
|
||||
class NestedComponent {}
|
||||
|
||||
class TestableCompiler extends Compiler {
|
||||
steps:List;
|
||||
constructor(templateLoader:TemplateLoader, reflector:Reflector, parser, closureMap, steps:List<CompileStep>) {
|
||||
super(templateLoader, reflector, parser, closureMap);
|
||||
this.steps = steps;
|
||||
@ -108,6 +109,7 @@ class TestableCompiler extends Compiler {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach} from 'test_lib/test_lib';
|
||||
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, FakeObject} from 'test_lib/test_lib';
|
||||
import {isBlank, isPresent, FIELD, IMPLEMENTS} from 'facade/lang';
|
||||
import {ListWrapper, MapWrapper, List} from 'facade/collection';
|
||||
import {ProtoElementInjector, PreBuiltObjects} from 'core/compiler/element_injector';
|
||||
import {Parent, Ancestor} from 'core/annotations/visibility';
|
||||
import {Injector, Inject, bind} from 'di/di';
|
||||
import {View} from 'core/compiler/view';
|
||||
import {ProtoRecordRange} from 'change_detection/record_range';
|
||||
import {NgElement} from 'core/dom/element';
|
||||
|
||||
@IMPLEMENTS(View)
|
||||
class DummyView {}
|
||||
//TODO: vsavkin: use a spy object
|
||||
class DummyView extends View {
|
||||
constructor() {
|
||||
super(null, null, null, null, null, new ProtoRecordRange(), null);
|
||||
}
|
||||
}
|
||||
|
||||
class Directive {
|
||||
}
|
||||
@ -18,28 +23,28 @@ class SomeOtherDirective {
|
||||
}
|
||||
|
||||
class NeedsDirective {
|
||||
@FIELD("dependency:Directive")
|
||||
dependency:Directive;
|
||||
constructor(dependency:Directive){
|
||||
this.dependency = dependency;
|
||||
}
|
||||
}
|
||||
|
||||
class NeedDirectiveFromParent {
|
||||
@FIELD("dependency:Directive")
|
||||
dependency:Directive;
|
||||
constructor(@Parent() dependency:Directive){
|
||||
this.dependency = dependency;
|
||||
}
|
||||
}
|
||||
|
||||
class NeedDirectiveFromAncestor {
|
||||
@FIELD("dependency:Directive")
|
||||
dependency:Directive;
|
||||
constructor(@Ancestor() dependency:Directive){
|
||||
this.dependency = dependency;
|
||||
}
|
||||
}
|
||||
|
||||
class NeedsService {
|
||||
@FIELD("service:Object")
|
||||
service:any;
|
||||
constructor(@Inject("service") service) {
|
||||
this.service = service;
|
||||
}
|
||||
@ -54,7 +59,7 @@ class B_Needs_A {
|
||||
}
|
||||
|
||||
class NeedsView {
|
||||
@FIELD("view:Object")
|
||||
view:any;
|
||||
constructor(@Inject(View) view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ import {Lexer} from 'change_detection/parser/lexer';
|
||||
import {Compiler} from 'core/compiler/compiler';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
|
||||
export function main() {
|
||||
@ -87,6 +87,7 @@ export function main() {
|
||||
bind: {'elprop':'dirProp'}
|
||||
})
|
||||
class MyDir {
|
||||
dirProp:string;
|
||||
constructor() {
|
||||
this.dirProp = '';
|
||||
}
|
||||
@ -98,6 +99,7 @@ class MyDir {
|
||||
})
|
||||
})
|
||||
class MyComp {
|
||||
ctxProp:string;
|
||||
constructor() {
|
||||
this.ctxProp = 'initial value';
|
||||
}
|
||||
@ -112,12 +114,14 @@ class MyComp {
|
||||
})
|
||||
})
|
||||
class ChildComp {
|
||||
ctxProp:string;
|
||||
constructor(service: MyService) {
|
||||
this.ctxProp = service.greeting;
|
||||
}
|
||||
}
|
||||
|
||||
class MyService {
|
||||
greeting:string;
|
||||
constructor() {
|
||||
this.greeting = 'hello';
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ import {CompileStep} from 'core/compiler/pipeline/compile_step';
|
||||
import {CompileElement} from 'core/compiler/pipeline/compile_element';
|
||||
import {CompileControl} from 'core/compiler/pipeline/compile_control';
|
||||
import {DOM} from 'facade/dom';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Template} from 'core/annotations/template';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {Template} from 'core/annotations/annotations';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {Parser} from 'change_detection/parser/parser';
|
||||
@ -165,6 +165,7 @@ export function main() {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import {CompileElement} from 'core/compiler/pipeline/compile_element';
|
||||
import {CompileStep} from 'core/compiler/pipeline/compile_step'
|
||||
import {CompileControl} from 'core/compiler/pipeline/compile_control';
|
||||
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Template} from 'core/annotations/template';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {Template} from 'core/annotations/annotations';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {ProtoView, ElementPropertyMemento, DirectivePropertyMemento} from 'core/compiler/view';
|
||||
import {ProtoElementInjector} from 'core/compiler/element_injector';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
@ -265,6 +265,7 @@ class SomeDecoratorDirective {
|
||||
bind: {'boundprop1': 'decorProp'}
|
||||
})
|
||||
class SomeDecoratorDirectiveWithBinding {
|
||||
decorProp;
|
||||
constructor() {
|
||||
this.decorProp = null;
|
||||
}
|
||||
@ -278,6 +279,7 @@ class SomeTemplateDirective {
|
||||
bind: {'boundprop2': 'templProp'}
|
||||
})
|
||||
class SomeTemplateDirectiveWithBinding {
|
||||
templProp;
|
||||
constructor() {
|
||||
this.templProp = null;
|
||||
}
|
||||
@ -291,12 +293,16 @@ class SomeComponentDirective {
|
||||
bind: {'boundprop3': 'compProp'}
|
||||
})
|
||||
class SomeComponentDirectiveWithBinding {
|
||||
compProp;
|
||||
constructor() {
|
||||
this.compProp = null;
|
||||
}
|
||||
}
|
||||
|
||||
class Context {
|
||||
prop1;
|
||||
prop2;
|
||||
prop3;
|
||||
constructor() {
|
||||
this.prop1 = null;
|
||||
this.prop2 = null;
|
||||
@ -305,6 +311,7 @@ class Context {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import {CompileElement} from 'core/compiler/pipeline/compile_element';
|
||||
import {CompileStep} from 'core/compiler/pipeline/compile_step'
|
||||
import {CompileControl} from 'core/compiler/pipeline/compile_control';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {Template} from 'core/annotations/template';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Template} from 'core/annotations/annotations';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
|
||||
export function main() {
|
||||
describe('ElementBindingMarker', () => {
|
||||
@ -101,6 +101,7 @@ function assertBinding(pipelineElement, shouldBePresent) {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe} from 'test_lib/test_lib';
|
||||
import {ListWrapper} from 'facade/collection';
|
||||
import {ListWrapper, List} from 'facade/collection';
|
||||
import {DOM} from 'facade/dom';
|
||||
import {isPresent, NumberWrapper} from 'facade/lang';
|
||||
|
||||
@ -106,6 +106,7 @@ export function main() {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
@ -115,6 +116,7 @@ class MockStep extends CompileStep {
|
||||
}
|
||||
|
||||
class LoggingStep extends CompileStep {
|
||||
logs:List;
|
||||
constructor(logs) {
|
||||
this.logs = logs;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {describe, beforeEach, it, expect, iit, ddescribe} from 'test_lib/test_lib';
|
||||
import {isPresent, isBlank} from 'facade/lang';
|
||||
import {DOM} from 'facade/dom';
|
||||
import {ListWrapper} from 'facade/collection';
|
||||
import {List, ListWrapper} from 'facade/collection';
|
||||
|
||||
import {ProtoElementInjectorBuilder} from 'core/compiler/pipeline/proto_element_injector_builder';
|
||||
import {CompilePipeline} from 'core/compiler/pipeline/compile_pipeline';
|
||||
@ -10,9 +10,9 @@ import {CompileStep} from 'core/compiler/pipeline/compile_step'
|
||||
import {CompileControl} from 'core/compiler/pipeline/compile_control';
|
||||
import {ProtoView} from 'core/compiler/view';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {Template} from 'core/annotations/template';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Template} from 'core/annotations/annotations';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {ProtoElementInjector} from 'core/compiler/element_injector';
|
||||
|
||||
export function main() {
|
||||
@ -107,6 +107,7 @@ export function main() {
|
||||
|
||||
|
||||
class TestableProtoElementInjectorBuilder extends ProtoElementInjectorBuilder {
|
||||
debugObjects:List;
|
||||
constructor() {
|
||||
this.debugObjects = [];
|
||||
}
|
||||
@ -127,6 +128,7 @@ class TestableProtoElementInjectorBuilder extends ProtoElementInjectorBuilder {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ export function main() {
|
||||
}
|
||||
|
||||
class MockStep extends CompileStep {
|
||||
processClosure:Function;
|
||||
constructor(process) {
|
||||
this.processClosure = process;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {ddescribe, describe, it, iit, expect, beforeEach} from 'test_lib/test_lib';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {AnnotatedType} from 'core/compiler/annotated_type';
|
||||
|
||||
@Decorator({
|
||||
|
@ -2,8 +2,8 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit} from 'test_lib/te
|
||||
import {ProtoView, ElementPropertyMemento, DirectivePropertyMemento} from 'core/compiler/view';
|
||||
import {ProtoElementInjector, ElementInjector} from 'core/compiler/element_injector';
|
||||
import {Reflector} from 'core/compiler/reflector';
|
||||
import {Component} from 'core/annotations/component';
|
||||
import {Decorator} from 'core/annotations/decorator';
|
||||
import {Component} from 'core/annotations/annotations';
|
||||
import {Decorator} from 'core/annotations/annotations';
|
||||
import {ProtoRecordRange} from 'change_detection/record_range';
|
||||
import {ChangeDetector} from 'change_detection/change_detector';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
@ -296,7 +296,7 @@ export function main() {
|
||||
}
|
||||
|
||||
class SomeDirective {
|
||||
@FIELD('prop')
|
||||
prop;
|
||||
constructor() {
|
||||
this.prop = 'foo';
|
||||
}
|
||||
@ -308,6 +308,7 @@ class SomeService {}
|
||||
componentServices: [SomeService]
|
||||
})
|
||||
class SomeComponent {
|
||||
service: SomeService;
|
||||
constructor(service: SomeService) {
|
||||
this.service = service;
|
||||
}
|
||||
@ -317,6 +318,8 @@ class SomeComponent {
|
||||
selector: '[dec]'
|
||||
})
|
||||
class ServiceDependentDecorator {
|
||||
component: SomeComponent;
|
||||
service: SomeService;
|
||||
constructor(component: SomeComponent, service: SomeService) {
|
||||
this.component = component;
|
||||
this.service = service;
|
||||
@ -324,14 +327,14 @@ class ServiceDependentDecorator {
|
||||
}
|
||||
|
||||
class AnotherDirective {
|
||||
@FIELD('prop')
|
||||
prop:string;
|
||||
constructor() {
|
||||
this.prop = 'anotherFoo';
|
||||
}
|
||||
}
|
||||
|
||||
class MyEvaluationContext {
|
||||
@FIELD('foo')
|
||||
foo:string;
|
||||
constructor() {
|
||||
this.foo = 'bar';
|
||||
};
|
||||
|
Reference in New Issue
Block a user