fix(typings): repair broken typechecks
We had the typechecker disabled by accident, and many problems snuck in Fixes #4507 Closes #4508
This commit is contained in:
parent
ae6f549f10
commit
6093e28b61
|
@ -58,7 +58,7 @@ export function CONST_EXPR<T>(expr: T): T {
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CONST(): ClassDecorator {
|
export function CONST(): ClassDecorator & PropertyDecorator {
|
||||||
return (target) => target;
|
return (target) => target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,13 @@ export interface ClassDefinition {
|
||||||
*
|
*
|
||||||
* See {@link Class} for example of usage.
|
* See {@link Class} for example of usage.
|
||||||
*/
|
*/
|
||||||
constructor: (Function | any[]);
|
constructor: Function | any[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other methods on the class. Note that values should have type 'Function' but TS requires
|
||||||
|
* all properties to have a narrower type than the index signature.
|
||||||
|
*/
|
||||||
|
[x: string]: Type | Function | any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw when more than one custom accessor is provided", () => {
|
it("should throw when more than one custom accessor is provided", () => {
|
||||||
var customAccessor = new SpyValueAccessor();
|
var customAccessor: ControlValueAccessor = <any>new SpyValueAccessor();
|
||||||
expect(() => selectValueAccessor(dir, [customAccessor, customAccessor])).toThrowError();
|
expect(() => selectValueAccessor(dir, [customAccessor, customAccessor])).toThrowError();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -156,7 +156,7 @@ export function main() {
|
||||||
{"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
|
{"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
|
||||||
expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}});
|
expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}});
|
||||||
|
|
||||||
g.controls["nested"].controls["two"].updateValue("333");
|
(<Control>(g.controls["nested"].find("two"))).updateValue("333");
|
||||||
|
|
||||||
expect(g.value).toEqual({"one": "111", "nested": {"two": "333"}});
|
expect(g.value).toEqual({"one": "111", "nested": {"two": "333"}});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,7 @@ import {
|
||||||
xit,
|
xit,
|
||||||
Log,
|
Log,
|
||||||
isInInnerZone,
|
isInInnerZone,
|
||||||
browserDetection,
|
browserDetection
|
||||||
TIMEOUT_INTERVAL_FOR_SLOW_BROWSERS
|
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {PromiseCompleter, PromiseWrapper, TimerWrapper} from 'angular2/src/core/facade/async';
|
import {PromiseCompleter, PromiseWrapper, TimerWrapper} from 'angular2/src/core/facade/async';
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {Component, View, LifecycleEvent, ViewEncapsulation, OnChanges} from 'angular2/angular2';
|
import {Component, View, ViewEncapsulation, OnChanges} from 'angular2/angular2';
|
||||||
|
|
||||||
import {TimerWrapper} from 'angular2/src/core/facade/async';
|
import {TimerWrapper} from 'angular2/src/core/facade/async';
|
||||||
import {isPresent} from 'angular2/src/core/facade/lang';
|
import {isPresent} from 'angular2/src/core/facade/lang';
|
||||||
|
|
||||||
|
|
||||||
// TODO(jelbourn): Ink ripples.
|
// TODO(jelbourn): Ink ripples.
|
||||||
// TODO(jelbourn): Make the `isMosueDown` stuff done with one global listener.
|
// TODO(jelbourn): Make the `isMouseDown` stuff done with one global listener.
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: '[md-button]:not(a), [md-fab]:not(a), [md-raised-button]:not(a)',
|
selector: '[md-button]:not(a), [md-fab]:not(a), [md-raised-button]:not(a)',
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import {Directive, Attribute, Host, SkipSelf, AfterContentChecked} from 'angular2/angular2';
|
||||||
Directive,
|
|
||||||
LifecycleEvent,
|
|
||||||
Attribute,
|
|
||||||
Host,
|
|
||||||
SkipSelf,
|
|
||||||
AfterContentChecked
|
|
||||||
} from 'angular2/angular2';
|
|
||||||
|
|
||||||
import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';
|
import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import {Component, View, ViewEncapsulation, Attribute, OnChanges} from 'angular2/angular2';
|
||||||
Component,
|
|
||||||
LifecycleEvent,
|
|
||||||
View,
|
|
||||||
ViewEncapsulation,
|
|
||||||
Attribute,
|
|
||||||
OnChanges
|
|
||||||
} from 'angular2/angular2';
|
|
||||||
import {CONST} from 'angular2/src/core/facade/lang';
|
import {CONST} from 'angular2/src/core/facade/lang';
|
||||||
import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
|
import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
|
||||||
import {Math} from 'angular2/src/core/facade/math';
|
import {Math} from 'angular2/src/core/facade/math';
|
||||||
|
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Component,
|
Component,
|
||||||
View,
|
View,
|
||||||
ViewEncapsulation,
|
ViewEncapsulation,
|
||||||
LifecycleEvent,
|
|
||||||
Host,
|
Host,
|
||||||
SkipSelf,
|
SkipSelf,
|
||||||
Attribute,
|
Attribute,
|
||||||
|
|
|
@ -64,12 +64,11 @@ function measureWrapper(func, desc) {
|
||||||
|
|
||||||
class MultiplyViewResolver extends ViewResolver {
|
class MultiplyViewResolver extends ViewResolver {
|
||||||
_multiplyBy: number;
|
_multiplyBy: number;
|
||||||
_cache: Map<Type, ViewMetadata>;
|
_cache = new Map<Type, ViewMetadata>();
|
||||||
|
|
||||||
constructor(multiple: number, components: Type[]) {
|
constructor(multiple: number, components: Type[]) {
|
||||||
super();
|
super();
|
||||||
this._multiplyBy = multiple;
|
this._multiplyBy = multiple;
|
||||||
this._cache = new Map();
|
|
||||||
ListWrapper.forEach(components, (c) => this._fillCache(c));
|
ListWrapper.forEach(components, (c) => this._fillCache(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export var createElement: Function;
|
export var createElement: Function;
|
||||||
export var render: Function;
|
export var render: Function;
|
||||||
|
export var createClass: Function;
|
||||||
|
|
|
@ -10,9 +10,9 @@ document.getElementById("send_echo")
|
||||||
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
|
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
|
||||||
// TODO(jteplitz602): Replace default constructors with real constructors
|
// TODO(jteplitz602): Replace default constructors with real constructors
|
||||||
// once they're in the .d.ts file (#3926)
|
// once they're in the .d.ts file (#3926)
|
||||||
var args = new UiArguments();
|
var args = new UiArguments("echo");
|
||||||
args.method = "echo";
|
args.method = "echo";
|
||||||
var fnArg = new FnArg();
|
var fnArg = new FnArg(val, PRIMITIVE);
|
||||||
fnArg.value = val;
|
fnArg.value = val;
|
||||||
fnArg.type = PRIMITIVE;
|
fnArg.type = PRIMITIVE;
|
||||||
args.args = [fnArg];
|
args.args = [fnArg];
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
declare namespace angular {
|
||||||
|
function module(prefix: string, dependencies?: string[]);
|
||||||
|
interface IModule {
|
||||||
|
directive(selector: string, factory: any): IModule;
|
||||||
|
value(key: string, value: any): IModule;
|
||||||
|
run(a: any);
|
||||||
|
}
|
||||||
|
interface ICompileService {
|
||||||
|
(element: Element): (IScope) => void;
|
||||||
|
}
|
||||||
|
interface IRootScopeService {
|
||||||
|
$new(): IScope;
|
||||||
|
$watch(expr: any, fn?: (a1?: any, a2?: any) => void);
|
||||||
|
$apply(): any;
|
||||||
|
$apply(exp: string): any;
|
||||||
|
$apply(exp: (scope: IScope) => any): any;
|
||||||
|
}
|
||||||
|
interface IScope extends IRootScopeService {}
|
||||||
|
interface IAngularBootstrapConfig {}
|
||||||
|
interface IDirective {}
|
||||||
|
interface IAttributes {
|
||||||
|
$observe(attr: string, fn: (v: string) => void);
|
||||||
|
}
|
||||||
|
interface ITranscludeFunction {}
|
||||||
|
interface IAugmentedJQuery {
|
||||||
|
bind(name: string, fn: () => void);
|
||||||
|
}
|
||||||
|
interface IParseService {
|
||||||
|
(expression: string): ICompiledExpression;
|
||||||
|
}
|
||||||
|
interface ICompiledExpression {
|
||||||
|
assign(context: any, value: any): any;
|
||||||
|
}
|
||||||
|
function element(e: Element);
|
||||||
|
function bootstrap(e: Element, modules: IModule[], config: IAngularBootstrapConfig);
|
||||||
|
|
||||||
|
namespace auto {
|
||||||
|
interface IInjectorService {
|
||||||
|
get(key: string): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var version: {major: number};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Function {
|
||||||
|
$inject?: string[];
|
||||||
|
}
|
|
@ -26,12 +26,13 @@ export interface AttrProp {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComponentInfo {
|
export interface ComponentInfo {
|
||||||
|
type: Type;
|
||||||
selector: string;
|
selector: string;
|
||||||
inputs: AttrProp[];
|
inputs: AttrProp[];
|
||||||
outputs: AttrProp[];
|
outputs: AttrProp[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getComponentInfo(type: Type): string {
|
export function getComponentInfo(type: Type): ComponentInfo {
|
||||||
var resolvedMetadata: DirectiveMetadata = directiveResolver.resolve(type);
|
var resolvedMetadata: DirectiveMetadata = directiveResolver.resolve(type);
|
||||||
var selector = resolvedMetadata.selector;
|
var selector = resolvedMetadata.selector;
|
||||||
if (!selector.match(COMPONENT_SELECTOR)) {
|
if (!selector.match(COMPONENT_SELECTOR)) {
|
||||||
|
@ -59,7 +60,7 @@ export function parseFields(names: string[]): AttrProp[] {
|
||||||
attr: attr,
|
attr: attr,
|
||||||
bracketAttr: `[${attr}]`,
|
bracketAttr: `[${attr}]`,
|
||||||
parenAttr: `(${attr})`,
|
parenAttr: `(${attr})`,
|
||||||
bracketParenAttr: `[(${attr})]`
|
bracketParenAttr: `[(${attr})]`,
|
||||||
onAttr: `on${capitalAttr}`,
|
onAttr: `on${capitalAttr}`,
|
||||||
bindAttr: `bind${capitalAttr}`,
|
bindAttr: `bind${capitalAttr}`,
|
||||||
bindonAttr: `bindon${capitalAttr}`
|
bindonAttr: `bindon${capitalAttr}`
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
///<reference path="../typings/angularjs/angular.d.ts"/>
|
///<reference path="./angular.d.ts"/>
|
||||||
|
|
||||||
import {
|
import {
|
||||||
platform,
|
platform,
|
||||||
PlatformRef,
|
|
||||||
ApplicationRef,
|
|
||||||
ComponentRef,
|
ComponentRef,
|
||||||
bind,
|
bind,
|
||||||
Directive,
|
Directive,
|
||||||
|
@ -62,7 +60,7 @@ export class UpgradeModule {
|
||||||
this.componentTypes.push(type);
|
this.componentTypes.push(type);
|
||||||
var info: ComponentInfo = getComponentInfo(type);
|
var info: ComponentInfo = getComponentInfo(type);
|
||||||
var factory: Function = ng1ComponentDirective(info, `${this.idPrefix}${info.selector}_c`);
|
var factory: Function = ng1ComponentDirective(info, `${this.idPrefix}${info.selector}_c`);
|
||||||
this.ng1Module.directive(info.selector, <any[]>factory);
|
this.ng1Module.directive(info.selector, <any>factory);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +173,7 @@ function ng1ComponentDirective(info: ComponentInfo, idPrefix: string): Function
|
||||||
class Ng2ComponentFacade {
|
class Ng2ComponentFacade {
|
||||||
component: any = null;
|
component: any = null;
|
||||||
inputChangeCount: number = 0;
|
inputChangeCount: number = 0;
|
||||||
inputChanges: StringMap<string, SimpleChange> = null;
|
inputChanges: {[key: string]: SimpleChange} = null;
|
||||||
hostViewRef: HostViewRef = null;
|
hostViewRef: HostViewRef = null;
|
||||||
changeDetector: ChangeDetectorRef = null;
|
changeDetector: ChangeDetectorRef = null;
|
||||||
componentScope: angular.IScope;
|
componentScope: angular.IScope;
|
||||||
|
@ -215,7 +213,7 @@ class Ng2ComponentFacade {
|
||||||
prevValue = value;
|
prevValue = value;
|
||||||
}
|
}
|
||||||
this.component[prop] = value;
|
this.component[prop] = value;
|
||||||
}
|
};
|
||||||
})(input.prop);
|
})(input.prop);
|
||||||
attrs.$observe(input.attr, observeFn);
|
attrs.$observe(input.attr, observeFn);
|
||||||
} else if (attrs.hasOwnProperty(input.bindAttr)) {
|
} else if (attrs.hasOwnProperty(input.bindAttr)) {
|
||||||
|
@ -284,8 +282,7 @@ class Ng2ComponentFacade {
|
||||||
((getter) => (value) => getter(this.scope, {$event: value}))(getter)
|
((getter) => (value) => getter(this.scope, {$event: value}))(getter)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(`Missing emitter '${output.prop}' on component '${this.info.selector}'!`);
|
||||||
`Missing emitter '${output.prop}' on component '${this.input.selector}'!`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {Component, View, Inject, EventEmitter} from 'angular2/angular2';
|
import {Component, View, Inject, EventEmitter} from 'angular2/angular2';
|
||||||
import {createUpgradeModule, UpgradeModule, bootstrapHybrid} from 'upgrade/upgrade';
|
import {createUpgradeModule, UpgradeModule} from 'upgrade/upgrade';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('upgrade: ng1 to ng2', () => {
|
describe('upgrade: ng1 to ng2', () => {
|
||||||
|
@ -56,7 +56,8 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('scope/component change-detection', () => {
|
describe('scope/component change-detection', () => {
|
||||||
it('should interleve scope and component expressions', inject([AsyncTestCompleter], (async) {
|
it('should interleave scope and component expressions',
|
||||||
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var log = [];
|
var log = [];
|
||||||
var l = function(value) {
|
var l = function(value) {
|
||||||
log.push(value);
|
log.push(value);
|
||||||
|
@ -93,7 +94,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('binding from ng1 to ng2', () => {
|
describe('binding from ng1 to ng2', () => {
|
||||||
it('should bind properties, events', inject([AsyncTestCompleter], (async) {
|
it('should bind properties, events', inject([AsyncTestCompleter], (async) => {
|
||||||
var upgrMod: UpgradeModule = createUpgradeModule();
|
var upgrMod: UpgradeModule = createUpgradeModule();
|
||||||
upgrMod.ng1Module.run(($rootScope) => {
|
upgrMod.ng1Module.run(($rootScope) => {
|
||||||
$rootScope.dataA = 'A';
|
$rootScope.dataA = 'A';
|
||||||
|
@ -133,26 +134,24 @@ export function main() {
|
||||||
this.twoWayBEmitter = new EventEmitter();
|
this.twoWayBEmitter = new EventEmitter();
|
||||||
},
|
},
|
||||||
onChanges: function(changes) {
|
onChanges: function(changes) {
|
||||||
var assert =
|
var assert = (prop, value) => {
|
||||||
(prop, value) => {
|
if (this[prop] != value) {
|
||||||
if (this[prop] != value) {
|
throw new Error(
|
||||||
throw new Error(
|
`Expected: '${prop}' to be '${value}' but was '${this[prop]}'`);
|
||||||
`Expected: '${prop}' to be '${value}' but was '${this[prop]}'`);
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
var assertChange =
|
var assertChange = (prop, value) => {
|
||||||
(prop, value) => {
|
assert(prop, value);
|
||||||
assert(prop, value);
|
if (!changes[prop]) {
|
||||||
if (!changes[prop]) {
|
throw new Error(`Changes record for '${prop}' not found.`);
|
||||||
throw new Error(`Changes record for '${prop}' not found.`);
|
}
|
||||||
}
|
var actValue = changes[prop].currentValue;
|
||||||
var actValue = changes[prop].currentValue;
|
if (actValue != value) {
|
||||||
if (actValue != value) {
|
throw new Error(
|
||||||
throw new Error(
|
`Expected changes record for'${prop}' to be '${value}' but was '${actValue}'`);
|
||||||
`Expected changes record for'${prop}' to be '${value}' but was '${actValue}'`);
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
switch (this.onChangesCount++) {
|
switch (this.onChangesCount++) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "angular/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"angularjs/angular.d.ts": {
|
|
||||||
"commit": "746b9a892629060bc853e792afff536e0ec4655e"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,7 +24,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "node tools/npm/check-node-modules --purge",
|
"preinstall": "node tools/npm/check-node-modules --purge",
|
||||||
"postinstall": "node tools/npm/copy-npm-shrinkwrap && node tools/chromedriverpatch.js && webdriver-manager update && bower install && gulp pubget.dart && tsd reinstall --overwrite --clean --config modules/angular2/tsd.json && tsd reinstall --overwrite --clean --config tools/tsd.json && tsd reinstall --overwrite --config modules/upgrade/tsd.json",
|
"postinstall": "node tools/npm/copy-npm-shrinkwrap && node tools/chromedriverpatch.js && webdriver-manager update && bower install && gulp pubget.dart && tsd reinstall --overwrite --clean --config modules/angular2/tsd.json && tsd reinstall --overwrite --clean --config tools/tsd.json",
|
||||||
"test": "gulp test.all.js && gulp test.all.dart"
|
"test": "gulp test.all.js && gulp test.all.dart"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -118,7 +118,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Use TypeScript to transpile the *.ts files to ES5
|
// Use TypeScript to transpile the *.ts files to ES5
|
||||||
var es5Tree = compileWithTypescript(es5ModulesTree, {
|
var typescriptOptions = {
|
||||||
allowNonTsExtensions: false,
|
allowNonTsExtensions: false,
|
||||||
declaration: false,
|
declaration: false,
|
||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
|
@ -131,7 +131,8 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
sourceRoot: '.',
|
sourceRoot: '.',
|
||||||
target: 'ES5'
|
target: 'ES5'
|
||||||
});
|
};
|
||||||
|
var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions);
|
||||||
|
|
||||||
// Now we add a few more files to the es6 tree that the es5 tree should not see
|
// Now we add a few more files to the es6 tree that the es5 tree should not see
|
||||||
var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: 'angular2'});
|
var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: 'angular2'});
|
||||||
|
|
Loading…
Reference in New Issue