X Tutup
Skip to content

Commit 19d8b22

Browse files
committed
fix(typings): test our .d.ts with --noImplicitAny
This matches how DefinitelyTyped tests it, so we are one step closer to publishing the same file we generate. See #3195
1 parent 345fa52 commit 19d8b22

File tree

12 files changed

+26
-26
lines changed

12 files changed

+26
-26
lines changed

docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
type SetterFn = typeof Function;
1515
type int = number;
1616
interface Type extends Function {
17-
new (...args);
17+
new (...args: any[]): Type;
1818
}
1919

2020
// See https://github.com/Microsoft/TypeScript/issues/1168

docs/typescript-package/services/tsParser/getExportDocType.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@ module.exports = function getExportDocType(log) {
3838
file: ts.getSourceFileOfNode(symbol.declarations[0]).fileName
3939
});
4040
return 'unknown';
41-
}
41+
};
4242

4343
function getBlockScopedVariableDocType(symbol) {
4444

4545
var node = symbol.valueDeclaration;
4646
while(node) {
4747
if ( node.flags & 0x2000 /* const */) {
48-
// DefinitelyTyped is still TS 1.4 so const is not allowed.
49-
// https://github.com/borisyankov/DefinitelyTyped/issues/4564
50-
return 'var'; // change to const when targetting TS 1.5
48+
return 'const';
5149
}
5250
node = node.parent;
5351
}
5452
return 'let';
5553
}
56-
};
54+
};

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ gulp.task('!pre.test.typings', ['docs/typings'], function() {
712712
gulp.task('test.typings', ['!pre.test.typings'], function() {
713713
return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/angular2.d.ts'])
714714
.pipe(tsc({target: 'ES5', module: 'commonjs',
715+
noImplicitAny: true,
715716
// Don't use the version of typescript that gulp-typescript depends on, we need 1.5
716717
// see https://github.com/ivogabe/gulp-typescript#typescript-version
717718
typescript: require('typescript')}));

modules/angular2/src/change_detection/constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
* CHECK_ONCE means that after calling detectChanges the mode of the change detector
55
* will become CHECKED.
66
*/
7-
export const CHECK_ONCE = "CHECK_ONCE";
7+
export const CHECK_ONCE: string = "CHECK_ONCE";
88

99
/**
1010
* CHECKED means that the change detector should be skipped until its mode changes to
1111
* CHECK_ONCE or CHECK_ALWAYS.
1212
*/
13-
export const CHECKED = "CHECKED";
13+
export const CHECKED: string = "CHECKED";
1414

1515
/**
1616
* CHECK_ALWAYS means that after calling detectChanges the mode of the change detector
1717
* will remain CHECK_ALWAYS.
1818
*/
19-
export const CHECK_ALWAYS = "ALWAYS_CHECK";
19+
export const CHECK_ALWAYS: string = "ALWAYS_CHECK";
2020

2121
/**
2222
* DETACHED means that the change detector sub tree is not a part of the main tree and
2323
* should be skipped.
2424
*/
25-
export const DETACHED = "DETACHED";
25+
export const DETACHED: string = "DETACHED";
2626

2727
/**
2828
* ON_PUSH means that the change detector's mode will be set to CHECK_ONCE during hydration.
2929
*/
30-
export const ON_PUSH = "ON_PUSH";
30+
export const ON_PUSH: string = "ON_PUSH";
3131

3232
/**
3333
* DEFAULT means that the change detector's mode will be set to CHECK_ALWAYS during hydration.
3434
*/
35-
export const DEFAULT = "DEFAULT";
35+
export const DEFAULT: string = "DEFAULT";

modules/angular2/src/core/application_common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ export function createNgZone(handler: ExceptionHandler): NgZone {
278278
* Returns a `Promise` of {@link ApplicationRef}.
279279
*/
280280
export function commonBootstrap(
281-
appComponentType: Type, componentInjectableBindings: List<Type | Binding | List<any>> = null):
282-
Promise<ApplicationRef> {
281+
appComponentType: /*Type*/ any,
282+
componentInjectableBindings: List<Type | Binding | List<any>> = null): Promise<ApplicationRef> {
283283
BrowserDomAdapter.makeCurrent();
284284
var bootstrapProcess = PromiseWrapper.completer();
285285

modules/angular2/src/core/application_tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<C
2222
*
2323
* ```
2424
*/
25-
export const appComponentTypeToken = CONST_EXPR(new OpaqueToken('RootComponent'));
25+
export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent'));

modules/angular2/src/core/compiler/query_list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class QueryList<T> implements IQueryList<T> {
3838
get first(): T { return ListWrapper.first(this._results); }
3939
get last(): T { return ListWrapper.last(this._results); }
4040

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

4343
[Symbol.iterator](): any { return this._results[Symbol.iterator](); }
4444
}

modules/angular2/src/di/injector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ const _notFound = CONST_EXPR(new Object());
2121
// Threshold for the dynamic version
2222
const _MAX_CONSTRUCTION_COUNTER = 10;
2323

24-
export const undefinedValue = CONST_EXPR(new Object());
24+
export const undefinedValue: Object = CONST_EXPR(new Object());
2525

26-
export const PUBLIC = 1;
27-
export const PRIVATE = 2;
28-
export const PUBLIC_AND_PRIVATE = 3;
26+
export const PUBLIC: number = 1;
27+
export const PRIVATE: number = 2;
28+
export const PUBLIC_AND_PRIVATE: number = 3;
2929

3030
export interface ProtoInjectorStrategy {
3131
getBindingAtIndex(index: number): ResolvedBinding;

modules/angular2/src/di/metadata.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ export class UnboundedMetadata extends VisibilityMetadata {
196196
toString(): string { return `@Unbounded(self: ${this.includeSelf}})`; }
197197
}
198198

199-
export const DEFAULT_VISIBILITY = CONST_EXPR(new UnboundedMetadata({self: true}));
199+
export const DEFAULT_VISIBILITY: VisibilityMetadata =
200+
CONST_EXPR(new UnboundedMetadata({self: true}));

modules/angular2/src/forms/directives/checkbox_value_accessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ export class CheckboxControlValueAccessor implements ControlValueAccessor {
5454
return isPresent(this.cd.control) ? !this.cd.control.valid : false;
5555
}
5656

57-
registerOnChange(fn: (_) => {}): void { this.onChange = fn; }
57+
registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; }
5858
registerOnTouched(fn: () => {}): void { this.onTouched = fn; }
5959
}

0 commit comments

Comments
 (0)
X Tutup