fix: build and test fixes for TS 2.1 (#13294)
This commit is contained in:
@ -68,7 +68,7 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
.then((_) => this._driver.logs('performance'))
|
||||
.then((entries) => {
|
||||
const events: PerfLogEvent[] = [];
|
||||
entries.forEach(entry => {
|
||||
entries.forEach((entry: any) => {
|
||||
const message = JSON.parse(entry['message'])['message'];
|
||||
if (message['method'] === 'Tracing.dataCollected') {
|
||||
events.push(message['params']);
|
||||
|
@ -40,7 +40,7 @@ export class IOsDriverExtension extends WebDriverExtension {
|
||||
.then((_) => this._driver.logs('performance'))
|
||||
.then((entries) => {
|
||||
const records: any[] = [];
|
||||
entries.forEach(entry => {
|
||||
entries.forEach((entry: any) => {
|
||||
const message = JSON.parse(entry['message'])['message'];
|
||||
if (message['method'] === 'Timeline.eventRecorded') {
|
||||
records.push(message['params']['record']);
|
||||
|
@ -154,7 +154,8 @@ describe('compiler-cli', () => {
|
||||
expect(mockConsole.error)
|
||||
.toHaveBeenCalledWith(
|
||||
'Error at ' + path.join(basePath, 'test.ts') +
|
||||
':3:7: Cannot invoke an expression whose type lacks a call signature.');
|
||||
':3:7: Cannot invoke an expression whose type lacks a call signature. ' +
|
||||
'Type \'String\' has no compatible call signatures.');
|
||||
expect(mockConsole.error).not.toHaveBeenCalledWith('Compilation failed');
|
||||
expect(exitCode).toEqual(1);
|
||||
done();
|
||||
|
@ -294,6 +294,8 @@ class _Scanner {
|
||||
buffer += input.substring(marker, this.index);
|
||||
this.advance();
|
||||
let unescapedCode: number;
|
||||
// Workaround for TS2.1-introduced type strictness
|
||||
this.peek = this.peek;
|
||||
if (this.peek == chars.$u) {
|
||||
// 4 character hex code for unicode character.
|
||||
const hex: string = input.substring(this.index + 1, this.index + 5);
|
||||
|
@ -16,7 +16,7 @@ import {GetterFn, MethodFn, SetterFn} from './types';
|
||||
* Attention: This regex has to hold even if the code is minified!
|
||||
*/
|
||||
export const DELEGATE_CTOR =
|
||||
/^function\s+\S+\(\)\s*{\s*("use strict";)?\s*(return\s+)?\S+\.apply\(this,\s*arguments\)/;
|
||||
/^function\s+\S+\(\)\s*{\s*("use strict";)?\s*(return\s+)?(\S+\s+!==\s+null\s+&&\s+)?\S+\.apply\(this,\s*arguments\)/;
|
||||
|
||||
export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
private _reflect: any;
|
||||
|
@ -115,6 +115,7 @@ class Ng2AppModule {
|
||||
// #docregion Angular 1 Stuff
|
||||
// #docregion ng1-module
|
||||
// This Angular 1 module represents the AngularJS pieces of the application
|
||||
declare var angular: ng.IAngularStatic;
|
||||
const ng1AppModule = angular.module('ng1AppModule', []);
|
||||
// #enddocregion
|
||||
|
||||
|
@ -54,7 +54,12 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
|
||||
const results = ls.getCompletionsAt(fileName, position);
|
||||
if (results && results.length) {
|
||||
if (base === undefined) {
|
||||
base = {isMemberCompletion: false, isNewIdentifierLocation: false, entries: []};
|
||||
base = {
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: []
|
||||
};
|
||||
}
|
||||
for (const entry of results) {
|
||||
base.entries.push(completionToEntry(entry));
|
||||
@ -78,7 +83,8 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
|
||||
documentation: [],
|
||||
kind: 'angular',
|
||||
kindModifiers: 'what does this do?',
|
||||
textSpan: {start: ours.span.start, length: ours.span.end - ours.span.start}
|
||||
textSpan: {start: ours.span.start, length: ours.span.end - ours.span.start},
|
||||
tags: [],
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ import {EmptyError} from 'rxjs/util/EmptyError';
|
||||
|
||||
import {Route, Routes} from './config';
|
||||
import {LoadedRouterConfig, RouterConfigLoader} from './router_config_loader';
|
||||
import {NavigationCancelingError, PRIMARY_OUTLET, Params, defaultUrlMatcher} from './shared';
|
||||
import {PRIMARY_OUTLET, Params, defaultUrlMatcher, navigationCancelingError} from './shared';
|
||||
import {UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree} from './url_tree';
|
||||
import {andObservables, forEach, merge, waitForMap, wrapIntoObservable} from './utils/collection';
|
||||
|
||||
@ -50,7 +50,7 @@ function namedOutletsRedirect(redirectTo: string): Observable<any> {
|
||||
|
||||
function canLoadFails(route: Route): Observable<LoadedRouterConfig> {
|
||||
return new Observable<LoadedRouterConfig>(
|
||||
(obs: Observer<LoadedRouterConfig>) => obs.error(new NavigationCancelingError(
|
||||
(obs: Observer<LoadedRouterConfig>) => obs.error(navigationCancelingError(
|
||||
`Cannot load children because the guard of the route "path: '${route.path}'" returned false`)));
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import {DetachedRouteHandle, DetachedRouteHandleInternal, RouteReuseStrategy} fr
|
||||
import {LoadedRouterConfig, RouterConfigLoader} from './router_config_loader';
|
||||
import {RouterOutletMap} from './router_outlet_map';
|
||||
import {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot, advanceActivatedRoute, createEmptyState, equalParamsAndUrlSegments, inheritedParamsDataResolve} from './router_state';
|
||||
import {NavigationCancelingError, PRIMARY_OUTLET, Params} from './shared';
|
||||
import {PRIMARY_OUTLET, Params, isNavigationCancelingError} from './shared';
|
||||
import {DefaultUrlHandlingStrategy, UrlHandlingStrategy} from './url_handling_strategy';
|
||||
import {UrlSerializer, UrlTree, containsTree, createEmptyUrlTree} from './url_tree';
|
||||
import {andObservables, forEach, merge, waitForMap, wrapIntoObservable} from './utils/collection';
|
||||
@ -802,7 +802,7 @@ export class Router {
|
||||
}
|
||||
},
|
||||
(e: any) => {
|
||||
if (e instanceof NavigationCancelingError) {
|
||||
if (isNavigationCancelingError(e)) {
|
||||
this.resetUrlToCurrentUrlTree();
|
||||
this.navigated = true;
|
||||
this.routerEvents.next(
|
||||
|
@ -27,13 +27,16 @@ export type Params = {
|
||||
[key: string]: any
|
||||
};
|
||||
|
||||
export class NavigationCancelingError extends Error {
|
||||
public stack: any;
|
||||
constructor(public message: string) {
|
||||
super(message);
|
||||
this.stack = (<any>new Error(message)).stack;
|
||||
}
|
||||
toString(): string { return this.message; }
|
||||
const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
|
||||
|
||||
export function navigationCancelingError(message: string) {
|
||||
const error = Error('NavigationCancelingError: ' + message);
|
||||
(error as any)[NAVIGATION_CANCELING_ERROR] = true;
|
||||
return error;
|
||||
}
|
||||
|
||||
export function isNavigationCancelingError(error: Error) {
|
||||
return (error as any)[NAVIGATION_CANCELING_ERROR];
|
||||
}
|
||||
|
||||
export function defaultUrlMatcher(
|
||||
|
@ -214,7 +214,7 @@ describe('applyRedirects', () => {
|
||||
() => { throw 'Should not reach'; },
|
||||
(e) => {
|
||||
expect(e.message).toEqual(
|
||||
`Cannot load children because the guard of the route "path: 'a'" returned false`);
|
||||
`NavigationCancelingError: Cannot load children because the guard of the route "path: 'a'" returned false`);
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user