Skip to content

Commit

Permalink
build: TypeScript 3.5 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Jul 25, 2019
1 parent c7542a1 commit e390cda
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 62 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@
"source-map": "^0.6.1",
"source-map-support": "0.5.9",
"systemjs": "0.18.10",
"tsickle": "0.34.3",
"tsickle": "0.36.0",
"tslib": "^1.9.0",
"tslint": "5.7.0",
"typescript": "~3.4.2",
"typescript": "~3.5.3",
"xhr2": "0.1.4",
"yargs": "13.1.0",
"zone.js": "^0.9.1"
Expand Down
16 changes: 8 additions & 8 deletions packages/bazel/test/ng_package/example_package.golden
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export * from './index';

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
Expand All @@ -316,7 +316,7 @@ export { MyModule } from './mymodule';

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
Expand All @@ -337,7 +337,7 @@ MyModule.decorators = [

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
Expand Down Expand Up @@ -371,7 +371,7 @@ export * from './index';

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
Expand Down Expand Up @@ -514,7 +514,7 @@ import { NgModule } from '@angular/core';

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class SecondaryModule {
}
Expand All @@ -526,7 +526,7 @@ const a = 1;

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/

/**
Expand All @@ -549,7 +549,7 @@ import { NgModule } from '@angular/core';

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class MyModule {
}
Expand All @@ -559,7 +559,7 @@ MyModule.decorators = [

/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/benchpress/src/metric/user_metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class UserMetric extends Metric {
endMeasure(restart: boolean): Promise<{[key: string]: any}> {
let resolve: (result: any) => void;
let reject: (error: any) => void;
const promise = new Promise((res, rej) => {
const promise = new Promise < { [key: string]: any; }
> ((res, rej) => {
resolve = res;
reject = rej;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/common/testing/src/mock_platform_location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface MockPlatformLocationConfig {
*
* @publicApi
*/
export const MOCK_PLATFORM_LOCATION_CONFIG = new InjectionToken('MOCK_PLATFORM_LOCATION_CONFIG');
export const MOCK_PLATFORM_LOCATION_CONFIG = new InjectionToken<MockPlatformLocationConfig>('MOCK_PLATFORM_LOCATION_CONFIG');

/**
* Mock implementation of URL state.
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=3.4 <3.5"
"typescript": ">=3.4 <3.6"
},
"engines": {
"node": ">=8.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un
}) =>
// tslint:disable-next-line:no-require-imports only depend on tsickle if requested
require('tsickle').emitWithTsickle(
program, {...tsickleHost, options, host}, host, options, targetSourceFile, writeFile,
cancellationToken, emitOnlyDtsFiles, {
program, {...tsickleHost, options, host, moduleResolutionHost: host}, host, options,
targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {
beforeTs: customTransformers.before,
afterTs: customTransformers.after,
});
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-cli/src/metadata/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface MetadataMap { [name: string]: MemberMetadata[]; }
export interface MemberMetadata {
__symbolic: 'constructor'|'method'|'property';
decorators?: (MetadataSymbolicExpression|MetadataError)[];
parameters?: (MetadataSymbolicExpression|MetadataError|null|undefined)[];
}
export function isMemberMetadata(value: any): value is MemberMetadata {
if (value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/transformers/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const MIN_TS_VERSION = '3.4.0';
* ∀ supported typescript version v, v < MAX_TS_VERSION
* MAX_TS_VERSION is not considered as a supported TypeScript version
*/
const MAX_TS_VERSION = '3.5.0';
const MAX_TS_VERSION = '3.6.0';

class AngularCompilerProgram implements Program {
private rootNames: string[];
Expand Down
6 changes: 0 additions & 6 deletions packages/compiler-cli/test/diagnostics/check_types_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,12 +771,6 @@ describe('ng type checker', () => {
'<div>{{"hello" | aPipe}}</div>',
`Argument of type '"hello"' is not assignable to parameter of type 'number'.`, '0:5');
});
it('should report an index into a map expression', () => {
rejectOnlyWithFullTemplateTypeCheck(
'<div>{{ {a: 1}[name] }}</div>',
`Element implicitly has an 'any' type because type '{ a: number; }' has no index signature.`,
'0:5');
});
it('should report an invalid property on an exportAs directive', () => {
rejectOnlyWithFullTemplateTypeCheck(
'<div aDir #aDir="aDir">{{aDir.fname}}</div>',
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-cli/test/metadata/collector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Collector', () => {
version: METADATA_VERSION,
metadata: {
DeclaredClass: {__symbolic: 'class'},
declaredFn: {__symbolic: 'function'},
declaredFn: {__symbolic: 'function'} as any,
}
});
});
Expand Down Expand Up @@ -433,8 +433,8 @@ describe('Collector', () => {
}
}
},
complexFn: {__symbolic: 'function'},
declaredFn: {__symbolic: 'function'}
complexFn: {__symbolic: 'function'} as any,
declaredFn: {__symbolic: 'function'} as any,
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,7 @@ runInEachFileSystem(os => {
const fileoverview = `
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
`;
expect(trim(jsContents).startsWith(trim(fileoverview))).toBeTruthy();
Expand All @@ -3160,7 +3160,7 @@ runInEachFileSystem(os => {
const fileoverview = `
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
`;
expect(trim(jsContents).startsWith(trim(fileoverview))).toBeTruthy();
Expand Down Expand Up @@ -3192,7 +3192,7 @@ runInEachFileSystem(os => {
* @fileoverview Some Comp overview
* @modName {some_comp}
*
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
`;
expect(trim(jsContents).startsWith(trim(fileoverview))).toBeTruthy();
Expand Down Expand Up @@ -3221,7 +3221,7 @@ runInEachFileSystem(os => {
* @fileoverview Some Comp overview
* @modName {some_comp}
*
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
`;
expect(trim(jsContents).startsWith(trim(fileoverview))).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export declare class CommonModule {
`'does_not_exist' does not exist on type '{ name: string; }'`,
`Expected 2 arguments, but got 3.`,
`Argument of type '"test"' is not assignable to parameter of type 'number'`,
`Argument of type '{ name: string; }' is not assignable to parameter of type '{}[]'`,
`Argument of type '{ name: string; }' is not assignable to parameter of type 'unknown[]'`,
];

for (const error of allErrors) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/event_emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {Subject, Subscription} from 'rxjs';
*
* @publicApi
*/
export class EventEmitter<T> extends Subject<T> {
export class EventEmitter<T extends any> extends Subject<T> {
// TODO: mark this as internal once all the facades are gone
// we can't mark it as internal now because EventEmitter exported via @angular/core would not
// contain this property making it incompatible with all the code that uses EventEmitter via
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/linker/element_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {noop} from '../util/noop';
// Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
// i.e. users have to ask for what they need. With that, we can build better analysis tools
// and could do better codegen in the future.
export class ElementRef<T = any> {
export class ElementRef<T extends any = any> {
/**
* The underlying native element or `null` if direct access to native elements is not supported
* (e.g. when the application runs in a web worker).
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/test/form_array_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {of } from 'rxjs';
function asyncValidator(expected: string, timeouts = {}) {
return (c: AbstractControl) => {
let resolve: (result: any) => void = undefined !;
const promise = new Promise(res => { resolve = res; });
const promise = new Promise<ValidationErrors|null>(res => { resolve = res; });
const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0;
const res = c.value != expected ? {'async': true} : null;

Expand Down
4 changes: 2 additions & 2 deletions packages/forms/test/form_control_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import {EventEmitter} from '@angular/core';
import {fakeAsync, tick} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
import {AbstractControl, AsyncValidatorFn, FormControl, FormGroup, Validators} from '@angular/forms';
import {AbstractControl, AsyncValidatorFn, FormControl, FormGroup, ValidationErrors, Validators} from '@angular/forms';

import {FormArray} from '@angular/forms/src/model';

(function() {
function asyncValidator(expected: string, timeouts = {}): AsyncValidatorFn {
return (c: AbstractControl) => {
let resolve: (result: any) => void = undefined !;
const promise = new Promise(res => { resolve = res; });
const promise = new Promise<ValidationErrors|null>(res => { resolve = res; });
const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0;
const res = c.value != expected ? {'async': true} : null;

Expand Down
2 changes: 1 addition & 1 deletion packages/forms/test/form_group_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {of } from 'rxjs';
function asyncValidator(expected: string, timeouts = {}) {
return (c: AbstractControl) => {
let resolve: (result: any) => void = undefined !;
const promise = new Promise(res => { resolve = res; });
const promise = new Promise<ValidationErrors|null>(res => { resolve = res; });
const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0;
const res = c.value != expected ? {'async': true} : null;

Expand Down
2 changes: 1 addition & 1 deletion packages/forms/test/reactive_integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,7 @@ import {MyInput, MyInputForm} from './value_accessor_integration_spec';
function uniqLoginAsyncValidator(expectedValue: string, timeout: number = 0) {
return (c: AbstractControl) => {
let resolve: (result: any) => void;
const promise = new Promise(res => { resolve = res; });
const promise = new Promise<any>(res => { resolve = res; });
const res = (c.value == expectedValue) ? null : {'uniqLogin': true};
setTimeout(() => resolve(res), timeout);
return promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {MessageBus, MessageBusSink, MessageBusSource} from './message_bus';

// TODO(jteplitz602): Replace this with the definition in lib.webworker.d.ts(#3492)
export interface PostMessageTarget {
postMessage: (message: any, transfer?: [ArrayBuffer]) => void;
postMessage: (message: any, transfer?: [Transferable]) => void;
}

export class PostMessageBusSink implements MessageBusSink {
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-webworker/src/worker_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function errorHandler(): ErrorHandler {

// TODO(jteplitz602): remove this and compile with lib.webworker.d.ts (#3492)
const _postMessage = {
postMessage: (message: any, transferrables?: [ArrayBuffer]) => {
postMessage: (message: any, transferrables: [Transferable]) => {
(<any>postMessage)(message, transferrables);
}
};
Expand Down
5 changes: 4 additions & 1 deletion packages/platform-webworker/src/worker_render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ function createNgZone(): NgZone {
*/
function spawnWebWorker(uri: string, instance: WebWorkerInstance): void {
const webWorker: Worker = new Worker(uri);
const sink = new PostMessageBusSink(webWorker);
// webWorker is casted to any because the lib.d.ts signature changed in TS3.5 to require the
// transfer argument in postMessage method.
// this seems wrong but since all of this code is deprecated it shouldn't matter that much.
const sink = new PostMessageBusSink(webWorker as any);
const source = new PostMessageBusSource(webWorker);
const bus = new PostMessageBus(sink, source);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ class MockPostMessage {
}
}

postMessage(data: any, transfer?: [ArrayBuffer]): void { this._listener(<any>{data: data}); }
postMessage(data: any, transfer?: [Transferable]): void { this._listener(<any>{data: data}); }
}
4 changes: 2 additions & 2 deletions packages/service-worker/config/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function joinUrls(a: string, b: string): string {
}

function withOrderedKeys<T extends{[key: string]: any}>(unorderedObj: T): T {
const orderedObj = {} as T;
const orderedObj = {} as{[key: string]: any};
Object.keys(unorderedObj).sort().forEach(key => orderedObj[key] = unorderedObj[key]);
return orderedObj;
return orderedObj as T;
}
2 changes: 1 addition & 1 deletion packages/service-worker/test/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import {take} from 'rxjs/operators';
scope.clients.getMock('default') !.queue.subscribe(msg => { mock.sendMessage(msg); });

mock.messages.subscribe(msg => { scope.handleMessage(msg, 'default'); });
mock.notificationClicks.subscribe(msg => { scope.handleMessage(msg, 'default'); });
mock.notificationClicks.subscribe((msg: Object) => { scope.handleMessage(msg, 'default'); });

mock.setupSw();
reg = mock.mockRegistration !;
Expand Down
2 changes: 1 addition & 1 deletion packages/service-worker/testing/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class MockServiceWorkerContainer {
mockRegistration: MockServiceWorkerRegistration|null = null;
controller: MockServiceWorker|null = null;
messages = new Subject<any>();
notificationClicks = new Subject();
notificationClicks = new Subject<{}>();

addEventListener(event: 'controllerchange'|'message', handler: Function) {
if (event === 'controllerchange') {
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/common/testing.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<{}>;
export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<unknown>;

export declare class MockLocationStrategy extends LocationStrategy {
internalBaseHref: string;
Expand Down
6 changes: 3 additions & 3 deletions tools/public_api_guard/core/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export interface DoCheck {
ngDoCheck(): void;
}

export declare class ElementRef<T = any> {
export declare class ElementRef<T extends any = any> {
nativeElement: T;
constructor(nativeElement: T);
}
Expand All @@ -325,7 +325,7 @@ export declare class ErrorHandler {
handleError(error: any): void;
}

export declare class EventEmitter<T> extends Subject<T> {
export declare class EventEmitter<T extends any> extends Subject<T> {
__isAsync: boolean;
constructor(isAsync?: boolean);
emit(value?: T): void;
Expand Down Expand Up @@ -1089,7 +1089,7 @@ export declare function ɵɵstylingApply(): void;

export declare function ɵɵtemplate(index: number, templateFn: ComponentTemplate<any> | null, consts: number, vars: number, tagName?: string | null, attrs?: TAttributes | null, localRefs?: string[] | null, localRefExtractor?: LocalRefExtractor): void;

export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: LView): ViewEngine_TemplateRef<{}> | null;
export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: LView): ViewEngine_TemplateRef<unknown> | null;

export declare function ɵɵtext(index: number, value?: any): void;

Expand Down

0 comments on commit e390cda

Please sign in to comment.