Skip to content

Commit

Permalink
fix(typings): test our .d.ts with --noImplicitAny
Browse files Browse the repository at this point in the history
This matches how DefinitelyTyped tests it, so we are
one step closer to publishing the same file we generate.

See #3195
  • Loading branch information
alexeagle committed Jul 24, 2015
1 parent 345fa52 commit 19d8b22
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
type SetterFn = typeof Function;
type int = number;
interface Type extends Function {
new (...args);
new (...args: any[]): Type;

This comment has been minimized.

Copy link
@NathanWalker

NathanWalker Jul 26, 2015

Contributor

@alexeagle This causes all sorts of problems :(

Shouldn't it be:
new (...args: any[]): any;
?

Everyone now ends up with compile errors/warnings like...

WARNING in ./someClass.ts
(29,24): Argument of type 'typeof SomeClass' is not assignable to parameter of type 'Type'.
  Type 'SomeClass' is not assignable to type 'Type'.
    Property 'apply' is missing in type 'SomeClass'. (2345)

When doing something like...

bind(SomeClass).toClass(SomeClass)

Please help here.

This comment has been minimized.

Copy link
@NathanWalker

NathanWalker Jul 26, 2015

Contributor
}

// See https://github.com/Microsoft/TypeScript/issues/1168
Expand Down
8 changes: 3 additions & 5 deletions docs/typescript-package/services/tsParser/getExportDocType.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ module.exports = function getExportDocType(log) {
file: ts.getSourceFileOfNode(symbol.declarations[0]).fileName
});
return 'unknown';
}
};

function getBlockScopedVariableDocType(symbol) {

var node = symbol.valueDeclaration;
while(node) {
if ( node.flags & 0x2000 /* const */) {
// DefinitelyTyped is still TS 1.4 so const is not allowed.
// https://github.com/borisyankov/DefinitelyTyped/issues/4564
return 'var'; // change to const when targetting TS 1.5
return 'const';
}
node = node.parent;
}
return 'let';
}
};
};
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ gulp.task('!pre.test.typings', ['docs/typings'], function() {
gulp.task('test.typings', ['!pre.test.typings'], function() {
return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/angular2.d.ts'])
.pipe(tsc({target: 'ES5', module: 'commonjs',
noImplicitAny: true,
// Don't use the version of typescript that gulp-typescript depends on, we need 1.5
// see https://github.com/ivogabe/gulp-typescript#typescript-version
typescript: require('typescript')}));
Expand Down
12 changes: 6 additions & 6 deletions modules/angular2/src/change_detection/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
* CHECK_ONCE means that after calling detectChanges the mode of the change detector
* will become CHECKED.
*/
export const CHECK_ONCE = "CHECK_ONCE";
export const CHECK_ONCE: string = "CHECK_ONCE";

/**
* CHECKED means that the change detector should be skipped until its mode changes to
* CHECK_ONCE or CHECK_ALWAYS.
*/
export const CHECKED = "CHECKED";
export const CHECKED: string = "CHECKED";

/**
* CHECK_ALWAYS means that after calling detectChanges the mode of the change detector
* will remain CHECK_ALWAYS.
*/
export const CHECK_ALWAYS = "ALWAYS_CHECK";
export const CHECK_ALWAYS: string = "ALWAYS_CHECK";

/**
* DETACHED means that the change detector sub tree is not a part of the main tree and
* should be skipped.
*/
export const DETACHED = "DETACHED";
export const DETACHED: string = "DETACHED";

/**
* ON_PUSH means that the change detector's mode will be set to CHECK_ONCE during hydration.
*/
export const ON_PUSH = "ON_PUSH";
export const ON_PUSH: string = "ON_PUSH";

/**
* DEFAULT means that the change detector's mode will be set to CHECK_ALWAYS during hydration.
*/
export const DEFAULT = "DEFAULT";
export const DEFAULT: string = "DEFAULT";
4 changes: 2 additions & 2 deletions modules/angular2/src/core/application_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ export function createNgZone(handler: ExceptionHandler): NgZone {
* Returns a `Promise` of {@link ApplicationRef}.
*/
export function commonBootstrap(
appComponentType: Type, componentInjectableBindings: List<Type | Binding | List<any>> = null):
Promise<ApplicationRef> {
appComponentType: /*Type*/ any,
componentInjectableBindings: List<Type | Binding | List<any>> = null): Promise<ApplicationRef> {
BrowserDomAdapter.makeCurrent();
var bootstrapProcess = PromiseWrapper.completer();

Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/application_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<C
*
* ```
*/
export const appComponentTypeToken = CONST_EXPR(new OpaqueToken('RootComponent'));
export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent'));
2 changes: 1 addition & 1 deletion modules/angular2/src/core/compiler/query_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class QueryList<T> implements IQueryList<T> {
get first(): T { return ListWrapper.first(this._results); }
get last(): T { return ListWrapper.last(this._results); }

map<U>(fn: (T) => U): U[] { return this._results.map(fn); }
map<U>(fn: (item: T) => U): U[] { return this._results.map(fn); }

[Symbol.iterator](): any { return this._results[Symbol.iterator](); }
}
8 changes: 4 additions & 4 deletions modules/angular2/src/di/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const _notFound = CONST_EXPR(new Object());
// Threshold for the dynamic version
const _MAX_CONSTRUCTION_COUNTER = 10;

export const undefinedValue = CONST_EXPR(new Object());
export const undefinedValue: Object = CONST_EXPR(new Object());

export const PUBLIC = 1;
export const PRIVATE = 2;
export const PUBLIC_AND_PRIVATE = 3;
export const PUBLIC: number = 1;
export const PRIVATE: number = 2;
export const PUBLIC_AND_PRIVATE: number = 3;

export interface ProtoInjectorStrategy {
getBindingAtIndex(index: number): ResolvedBinding;
Expand Down
3 changes: 2 additions & 1 deletion modules/angular2/src/di/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@ export class UnboundedMetadata extends VisibilityMetadata {
toString(): string { return `@Unbounded(self: ${this.includeSelf}})`; }
}

export const DEFAULT_VISIBILITY = CONST_EXPR(new UnboundedMetadata({self: true}));
export const DEFAULT_VISIBILITY: VisibilityMetadata =
CONST_EXPR(new UnboundedMetadata({self: true}));
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ export class CheckboxControlValueAccessor implements ControlValueAccessor {
return isPresent(this.cd.control) ? !this.cd.control.valid : false;
}

registerOnChange(fn: (_) => {}): void { this.onChange = fn; }
registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; }
registerOnTouched(fn: () => {}): void { this.onTouched = fn; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class DefaultValueAccessor implements ControlValueAccessor {
return isPresent(this.cd.control) ? !this.cd.control.valid : false;
}

registerOnChange(fn: (_) => void): void { this.onChange = fn; }
registerOnChange(fn: (_: any) => void): void { this.onChange = fn; }

registerOnTouched(fn: () => void): void { this.onTouched = fn; }
}
6 changes: 3 additions & 3 deletions modules/angular2/src/render/dom/dom_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import {
RenderViewWithFragments
} from '../api';

export const DOCUMENT_TOKEN = CONST_EXPR(new OpaqueToken('DocumentToken'));
export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES =
export const DOCUMENT_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken('DocumentToken'));
export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken =
CONST_EXPR(new OpaqueToken('DomReflectPropertiesAsAttributes'));
const REFLECT_PREFIX = 'ng-reflect-';
const REFLECT_PREFIX: string = 'ng-reflect-';

@Injectable()
export class DomRenderer extends Renderer {
Expand Down

0 comments on commit 19d8b22

Please sign in to comment.