build: upgrade jasmine (and related typings) to latest version (#19904)

With these changes, the types are a little stricter now and also not
compatible with Protractor's jasmine-like syntax. So, we have to also
use `@types/jasminewd2` for e2e tests (but not for non-e2e tests).

I also had to "augment" `@types/jasminewd2`, because the latest
typings from [DefinitelyTyped][1] do not reflect the fact that the
`jasminewd2` version (v2.1.0) currently used by Protractor supports
passing a `done` callback to a spec.

[1]: 566e039485/types/jasminewd2/index.d.ts (L9-L15)

Fixes #23952
Closes #24733

PR Close #19904
This commit is contained in:
George Kalpakas 2017-10-24 14:54:08 +03:00 committed by Miško Hevery
parent 1e74ea9e60
commit 00c110b055
59 changed files with 332 additions and 283 deletions

View File

@ -409,6 +409,10 @@ if [[ ${BUILD_ALL} == true && ${TYPECHECK_ALL} == true ]]; then
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace" travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
$TSC -p ${TSCONFIG} $TSC -p ${TSCONFIG}
travisFoldEnd "tsc -p ${TSCONFIG}" travisFoldEnd "tsc -p ${TSCONFIG}"
TSCONFIG="packages/examples/tsconfig.json"
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
$TSC -p ${TSCONFIG}
travisFoldEnd "tsc -p ${TSCONFIG}"
TSCONFIG="modules/tsconfig.json" TSCONFIG="modules/tsconfig.json"
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace" travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
$TSC -p ${TSCONFIG} $TSC -p ${TSCONFIG}

View File

@ -1,7 +1,10 @@
{ {
"compilerOptions": { "compilerOptions": {
"outDir": "../dist/e2e", "outDir": "../dist/e2e",
"types": ["jasmine"], "types": [
"jasmine",
"jasminewd2"
],
"skipLibCheck": true "skipLibCheck": true
} }
} }

View File

@ -18,8 +18,9 @@
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/jasmine": "file:../../node_modules/@types/jasmine",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@types/jasmine": "file:../../node_modules/@types/jasmine",
"@types/jasminewd2": "file:../../node_modules/@types/jasminewd2",
"concurrently": "3.4.0", "concurrently": "3.4.0",
"lite-server": "2.2.2", "lite-server": "2.2.2",
"protractor": "file:../../node_modules/protractor", "protractor": "file:../../node_modules/protractor",

5
modules/types.d.ts vendored
View File

@ -8,10 +8,11 @@
// This file contains all ambient imports needed to compile the modules/ source code // This file contains all ambient imports needed to compile the modules/ source code
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
/// <reference path="../node_modules/@types/hammerjs/index.d.ts" /> /// <reference path="../node_modules/@types/hammerjs/index.d.ts" />
/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> /// <reference path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/jasminewd2/index.d.ts" />
/// <reference path="../node_modules/@types/node/index.d.ts" /> /// <reference path="../node_modules/@types/node/index.d.ts" />
/// <reference path="../node_modules/@types/selenium-webdriver/index.d.ts" /> /// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
/// <reference path="../tools/types-ext/jasminewd2.d.ts" />
/// <reference path="./es6-subset.d.ts" /> /// <reference path="./es6-subset.d.ts" />
/// <reference path="./system.d.ts" /> /// <reference path="./system.d.ts" />

View File

@ -47,7 +47,8 @@
"@types/diff": "^3.2.2", "@types/diff": "^3.2.2",
"@types/fs-extra": "4.0.2", "@types/fs-extra": "4.0.2",
"@types/hammerjs": "2.0.35", "@types/hammerjs": "2.0.35",
"@types/jasmine": "2.2.22-alpha", "@types/jasmine": "^2.8.8",
"@types/jasminewd2": "^2.0.3",
"@types/minimist": "^1.2.0", "@types/minimist": "^1.2.0",
"@types/node": "6.0.88", "@types/node": "6.0.88",
"@types/selenium-webdriver": "3.0.7", "@types/selenium-webdriver": "3.0.7",
@ -84,8 +85,8 @@
"hammerjs": "2.0.8", "hammerjs": "2.0.8",
"husky": "^0.14.3", "husky": "^0.14.3",
"incremental-dom": "0.4.1", "incremental-dom": "0.4.1",
"jasmine": "2.4.1", "jasmine": "2.8",
"jasmine-core": "2.4.1", "jasmine-core": "2.8",
"jpm": "1.3.1", "jpm": "1.3.1",
"karma": "0.13.20", "karma": "0.13.20",
"karma-browserstack-launcher": "0.1.9", "karma-browserstack-launcher": "0.1.9",

View File

@ -30,7 +30,7 @@ export interface TestSupport {
writeFiles(...mockDirs: {[fileName: string]: string}[]): void; writeFiles(...mockDirs: {[fileName: string]: string}[]): void;
shouldExist(fileName: string): void; shouldExist(fileName: string): void;
shouldNotExist(fileName: string): void; shouldNotExist(fileName: string): void;
runOneBuild(): void; runOneBuild(): boolean;
} }
export function setup( export function setup(

View File

@ -48,13 +48,11 @@ import {Options, PerfLogEvent, PerfLogFeatures, UserMetric, WebDriverAdapter} fr
const metric = createMetric( const metric = createMetric(
[[]], new PerfLogFeatures(), [[]], new PerfLogFeatures(),
{userMetrics: {'loadTime': 'time to load', 'content': 'time to see content'}}); {userMetrics: {'loadTime': 'time to load', 'content': 'time to see content'}});
metric.beginMeasure() metric.beginMeasure().then(() => metric.endMeasure(true)).then(values => {
.then((_) => metric.endMeasure(true)) expect(values['loadTime']).toBe(25);
.then((values: {[key: string]: string}) => { expect(values['content']).toBe(250);
expect(values['loadTime']).toBe(25); async.done();
expect(values['content']).toBe(250); });
async.done();
});
wdAdapter.data['loadTime'] = 25; wdAdapter.data['loadTime'] = 25;
// Wait before setting 2nd property. // Wait before setting 2nd property.

View File

@ -166,12 +166,12 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
fixture.componentInstance.currentComponent = Module2InjectedComponent; fixture.componentInstance.currentComponent = Module2InjectedComponent;
fixture.detectChanges(); fixture.detectChanges();
const moduleRef = fixture.componentInstance.ngComponentOutlet['_moduleRef']; const moduleRef = fixture.componentInstance.ngComponentOutlet['_moduleRef'] !;
spyOn(moduleRef, 'destroy').and.callThrough(); spyOn(moduleRef, 'destroy').and.callThrough();
expect(moduleRef !.destroy).not.toHaveBeenCalled(); expect(moduleRef.destroy).not.toHaveBeenCalled();
fixture.destroy(); fixture.destroy();
expect(moduleRef !.destroy).toHaveBeenCalled(); expect(moduleRef.destroy).toHaveBeenCalled();
})); }));
it('should not re-create moduleRef when it didn\'t actually change', async(() => { it('should not re-create moduleRef when it didn\'t actually change', async(() => {

View File

@ -16,10 +16,9 @@ export class FeatureComponent {
@NgModule({ @NgModule({
declarations: [FeatureComponent], declarations: [FeatureComponent],
imports: [RouterModule.forChild([ imports: [RouterModule.forChild([
{path: '', component: FeatureComponent}, {path: 'd', loadChildren: './default.module'} { {path: '', component: FeatureComponent},
path: 'e', {path: 'd', loadChildren: './default.module'},
loadChildren: 'feature/feature.module#FeatureModule' {path: 'e', loadChildren: 'feature/feature.module#FeatureModule'},
}
])] ])]
}) })
export class Feature2Module { export class Feature2Module {

View File

@ -21,7 +21,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {CompilerHost, CompilerOptions, LazyRoute} from './transformers/api'; import {CompilerOptions} from './transformers/api';
import {getOriginalReferences} from './transformers/compiler_host'; import {getOriginalReferences} from './transformers/compiler_host';
import {createProgram} from './transformers/entry_points'; import {createProgram} from './transformers/entry_points';

View File

@ -76,7 +76,7 @@ describe('expression diagnostics', () => {
} }
} }
function reject(template: string, expected: string | RegExp) { function reject(template: string, expected: string) {
const info = getDiagnosticTemplateInfo(context, type, 'app/app.component.html', template); const info = getDiagnosticTemplateInfo(context, type, 'app/app.component.html', template);
if (info) { if (info) {
const diagnostics = getTemplateExpressionDiagnostics(info); const diagnostics = getTemplateExpressionDiagnostics(info);
@ -240,4 +240,4 @@ const FILES: Directory = {
` `
} }
} }
}; };

View File

@ -9,7 +9,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {MetadataCollector} from '../../src/metadata/collector'; import {MetadataCollector} from '../../src/metadata/collector';
import {ClassMetadata, ConstructorMetadata, METADATA_VERSION, MetadataEntry, ModuleMetadata, isClassMetadata, isMetadataGlobalReferenceExpression} from '../../src/metadata/schema'; import {ClassMetadata, ConstructorMetadata, METADATA_VERSION, MetadataEntry, MetadataMap, MetadataSymbolicExpression, ModuleMetadata, isClassMetadata, isMetadataGlobalReferenceExpression} from '../../src/metadata/schema';
import {Directory, Host, expectValidSources} from './typescript.mocks'; import {Directory, Host, expectValidSources} from './typescript.mocks';
@ -269,9 +269,11 @@ describe('Collector', () => {
it('should provide any reference for an any ctor parameter type', () => { it('should provide any reference for an any ctor parameter type', () => {
const casesAny = <ClassMetadata>casesMetadata.metadata['CaseAny']; const casesAny = <ClassMetadata>casesMetadata.metadata['CaseAny'];
expect(casesAny).toBeTruthy(); expect(casesAny).toBeTruthy();
const ctorData = casesAny.members !['__ctor__']; const ctorData = casesAny.members !['__ctor__'] as ConstructorMetadata[];
expect(ctorData).toEqual( expect(ctorData).toEqual([{
[{__symbolic: 'constructor', parameters: [{__symbolic: 'reference', name: 'any'}]}]); __symbolic: 'constructor',
parameters: [{__symbolic: 'reference', name: 'any'} as MetadataSymbolicExpression]
}]);
}); });
it('should record annotations on set and get declarations', () => { it('should record annotations on set and get declarations', () => {
@ -285,7 +287,8 @@ describe('Collector', () => {
arguments: ['firstName'] arguments: ['firstName']
}] }]
}] }]
}); } as any as MetadataMap); // TODO: Review use of `any` here (#19904)
const caseGetProp = <ClassMetadata>casesMetadata.metadata['GetProp']; const caseGetProp = <ClassMetadata>casesMetadata.metadata['GetProp'];
expect(caseGetProp.members).toEqual(propertyData(11)); expect(caseGetProp.members).toEqual(propertyData(11));
const caseSetProp = <ClassMetadata>casesMetadata.metadata['SetProp']; const caseSetProp = <ClassMetadata>casesMetadata.metadata['SetProp'];
@ -297,8 +300,7 @@ describe('Collector', () => {
it('should record references to parameterized types', () => { it('should record references to parameterized types', () => {
const casesForIn = <ClassMetadata>casesMetadata.metadata['NgFor']; const casesForIn = <ClassMetadata>casesMetadata.metadata['NgFor'];
expect(casesForIn).toEqual({ expect(casesForIn).toEqual({
__symbolic: 'class', __symbolic: 'class', decorators: [{
decorators: [{
__symbolic: 'call', __symbolic: 'call',
expression: { expression: {
__symbolic: 'reference', __symbolic: 'reference',
@ -308,17 +310,17 @@ describe('Collector', () => {
character: 7 character: 7
} }
}], }],
members: { members: {
__ctor__: [{ __ctor__: [{
__symbolic: 'constructor', __symbolic: 'constructor',
parameters: [{ parameters: [{
__symbolic: 'reference', __symbolic: 'reference',
name: 'ClassReference', name: 'ClassReference',
arguments: [{__symbolic: 'reference', name: 'NgForRow'}] arguments: [{__symbolic: 'reference', name: 'NgForRow'}]
}] }]
}] }]
} }
}); } as any as ClassMetadata); // TODO: Review use of `any` here (#19904)
}); });
it('should report errors for destructured imports', () => { it('should report errors for destructured imports', () => {
@ -358,9 +360,9 @@ describe('Collector', () => {
const someClass = <ClassMetadata>metadata.metadata['SomeClass']; const someClass = <ClassMetadata>metadata.metadata['SomeClass'];
const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0]; const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0];
const parameters = ctor.parameters; const parameters = ctor.parameters;
expect(parameters).toEqual([ expect(parameters).toEqual([{
{__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29} __symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29
]); } as MetadataSymbolicExpression]);
}); });
it('should record all exported classes', () => { it('should record all exported classes', () => {
@ -443,9 +445,9 @@ describe('Collector', () => {
const someClass = <ClassMetadata>metadata.metadata['SomeClass']; const someClass = <ClassMetadata>metadata.metadata['SomeClass'];
const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0]; const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0];
const parameters = ctor.parameters; const parameters = ctor.parameters;
expect(parameters).toEqual([ expect(parameters).toEqual([{
{__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29} __symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29
]); } as MetadataSymbolicExpression]);
}); });
it('should be able to collect the value of an enum', () => { it('should be able to collect the value of an enum', () => {
@ -533,7 +535,7 @@ describe('Collector', () => {
arguments: ['a'] arguments: ['a']
} }
}] }]
}]); }] as any as MetadataSymbolicExpression[]); // TODO: Review use of `any` here (#19904)
}); });
it('should be able to collect a static field', () => { it('should be able to collect a static field', () => {
@ -576,7 +578,7 @@ describe('Collector', () => {
} }
}] }]
}] }]
}]); }] as any as MetadataSymbolicExpression[]); // TODO: Review use of `any` here (#19904)
}); });
it('should be able to collect a method with a conditional expression', () => { it('should be able to collect a method with a conditional expression', () => {
@ -764,7 +766,7 @@ describe('Collector', () => {
}]], }]],
parameters: [{__symbolic: 'reference', name: 'any'}] parameters: [{__symbolic: 'reference', name: 'any'}]
}] }]
}); } as any as MetadataMap); // TODO: Review use of `any` here (#19904)
}); });
describe('with interpolations', () => { describe('with interpolations', () => {
@ -868,7 +870,7 @@ describe('Collector', () => {
{__symbolic: 'reference', module: './foo', name: 'Foo', line: 3, character: 24} {__symbolic: 'reference', module: './foo', name: 'Foo', line: 3, character: 24}
] ]
}] }]
}); } as any as MetadataMap); // TODO: Review use of `any` here (#19904)
}); });
it('should treat exported class expressions as a class', () => { it('should treat exported class expressions as a class', () => {

View File

@ -1747,7 +1747,7 @@ describe('ngc transformer command-line', () => {
const exitCode = const exitCode =
main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message)); main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message));
expect(exitCode).toBe(1, 'Compile was expected to fail'); expect(exitCode).toBe(1, 'Compile was expected to fail');
expect(messages[0]).toContain(['Tagged template expressions are not supported in metadata']); expect(messages[0]).toContain('Tagged template expressions are not supported in metadata');
}); });
// Regression: #20076 // Regression: #20076

View File

@ -502,7 +502,7 @@ describe('TypeScriptNodeEmitter', () => {
generatedColumn: 0, generatedColumn: 0,
originalLine: 1, originalLine: 1,
originalColumn: 0, originalColumn: 0,
name: null name: null ! // TODO: Review use of `!` here (#19904)
}, },
{ {
source: sourceUrl, source: sourceUrl,
@ -510,7 +510,7 @@ describe('TypeScriptNodeEmitter', () => {
generatedColumn: 16, generatedColumn: 16,
originalLine: 1, originalLine: 1,
originalColumn: 26, originalColumn: 26,
name: null name: null ! // TODO: Review use of `!` here (#19904)
} }
]); ]);
}); });

View File

@ -373,8 +373,8 @@ describe('ng program', () => {
{rootNames: [path.resolve(testSupport.basePath, 'src/main.ts')], options, host}); {rootNames: [path.resolve(testSupport.basePath, 'src/main.ts')], options, host});
program.loadNgStructureAsync().then(() => { program.loadNgStructureAsync().then(() => {
program.emit(); program.emit();
const factory = const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js');
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js')); const factory = fs.readFileSync(ngFactoryPath, 'utf8');
expect(factory).toContain('Hello world!'); expect(factory).toContain('Hello world!');
done(); done();
}); });
@ -677,8 +677,9 @@ describe('ng program', () => {
program.listLazyRoutes(); program.listLazyRoutes();
program.emit(); program.emit();
const lazyNgFactory = const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js');
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js')); const lazyNgFactory = fs.readFileSync(ngFactoryPath, 'utf8');
expect(lazyNgFactory).toContain('import * as i1 from "./lazy";'); expect(lazyNgFactory).toContain('import * as i1 from "./lazy";');
}); });
@ -735,8 +736,10 @@ describe('ng program', () => {
expect(normalizeRoutes(program.listLazyRoutes('src/main#MainModule'))).toEqual([ expect(normalizeRoutes(program.listLazyRoutes('src/main#MainModule'))).toEqual([
{ {
module: {name: 'MainModule', filePath: path.resolve(testSupport.basePath, 'src/main.ts')}, module: {name: 'MainModule', filePath: path.resolve(testSupport.basePath, 'src/main.ts')},
referencedModule: referencedModule: {
{name: undefined, filePath: path.resolve(testSupport.basePath, 'src/child.ts')}, name: undefined as any as string, // TODO: Review use of `any` here (#19904)
filePath: path.resolve(testSupport.basePath, 'src/child.ts')
},
route: './child' route: './child'
}, },
]); ]);

View File

@ -103,83 +103,86 @@ import * as core from '@angular/core';
}); });
it('const enums should be equal', () => { it('const enums should be equal', () => {
expect(compilerCore.NodeFlags.None).toBe(core.ɵNodeFlags.None); const expectToBe = (val1: any, val2: any) => expect(val1).toBe(val2);
expect(compilerCore.NodeFlags.TypeElement).toBe(core.ɵNodeFlags.TypeElement);
expect(compilerCore.NodeFlags.TypeText).toBe(core.ɵNodeFlags.TypeText);
expect(compilerCore.NodeFlags.ProjectedTemplate).toBe(core.ɵNodeFlags.ProjectedTemplate);
expect(compilerCore.NodeFlags.CatRenderNode).toBe(core.ɵNodeFlags.CatRenderNode);
expect(compilerCore.NodeFlags.TypeNgContent).toBe(core.ɵNodeFlags.TypeNgContent);
expect(compilerCore.NodeFlags.TypePipe).toBe(core.ɵNodeFlags.TypePipe);
expect(compilerCore.NodeFlags.TypePureArray).toBe(core.ɵNodeFlags.TypePureArray);
expect(compilerCore.NodeFlags.TypePureObject).toBe(core.ɵNodeFlags.TypePureObject);
expect(compilerCore.NodeFlags.TypePurePipe).toBe(core.ɵNodeFlags.TypePurePipe);
expect(compilerCore.NodeFlags.CatPureExpression).toBe(core.ɵNodeFlags.CatPureExpression);
expect(compilerCore.NodeFlags.TypeValueProvider).toBe(core.ɵNodeFlags.TypeValueProvider);
expect(compilerCore.NodeFlags.TypeClassProvider).toBe(core.ɵNodeFlags.TypeClassProvider);
expect(compilerCore.NodeFlags.TypeFactoryProvider).toBe(core.ɵNodeFlags.TypeFactoryProvider);
expect(compilerCore.NodeFlags.TypeUseExistingProvider)
.toBe(core.ɵNodeFlags.TypeUseExistingProvider);
expect(compilerCore.NodeFlags.LazyProvider).toBe(core.ɵNodeFlags.LazyProvider);
expect(compilerCore.NodeFlags.PrivateProvider).toBe(core.ɵNodeFlags.PrivateProvider);
expect(compilerCore.NodeFlags.TypeDirective).toBe(core.ɵNodeFlags.TypeDirective);
expect(compilerCore.NodeFlags.Component).toBe(core.ɵNodeFlags.Component);
expect(compilerCore.NodeFlags.CatProviderNoDirective)
.toBe(core.ɵNodeFlags.CatProviderNoDirective);
expect(compilerCore.NodeFlags.CatProvider).toBe(core.ɵNodeFlags.CatProvider);
expect(compilerCore.NodeFlags.OnInit).toBe(core.ɵNodeFlags.OnInit);
expect(compilerCore.NodeFlags.OnDestroy).toBe(core.ɵNodeFlags.OnDestroy);
expect(compilerCore.NodeFlags.DoCheck).toBe(core.ɵNodeFlags.DoCheck);
expect(compilerCore.NodeFlags.OnChanges).toBe(core.ɵNodeFlags.OnChanges);
expect(compilerCore.NodeFlags.AfterContentInit).toBe(core.ɵNodeFlags.AfterContentInit);
expect(compilerCore.NodeFlags.AfterContentChecked).toBe(core.ɵNodeFlags.AfterContentChecked);
expect(compilerCore.NodeFlags.AfterViewInit).toBe(core.ɵNodeFlags.AfterViewInit);
expect(compilerCore.NodeFlags.AfterViewChecked).toBe(core.ɵNodeFlags.AfterViewChecked);
expect(compilerCore.NodeFlags.EmbeddedViews).toBe(core.ɵNodeFlags.EmbeddedViews);
expect(compilerCore.NodeFlags.ComponentView).toBe(core.ɵNodeFlags.ComponentView);
expect(compilerCore.NodeFlags.TypeContentQuery).toBe(core.ɵNodeFlags.TypeContentQuery);
expect(compilerCore.NodeFlags.TypeViewQuery).toBe(core.ɵNodeFlags.TypeViewQuery);
expect(compilerCore.NodeFlags.StaticQuery).toBe(core.ɵNodeFlags.StaticQuery);
expect(compilerCore.NodeFlags.DynamicQuery).toBe(core.ɵNodeFlags.DynamicQuery);
expect(compilerCore.NodeFlags.CatQuery).toBe(core.ɵNodeFlags.CatQuery);
expect(compilerCore.NodeFlags.Types).toBe(core.ɵNodeFlags.Types);
expect(compilerCore.DepFlags.None).toBe(core.ɵDepFlags.None); expectToBe(compilerCore.NodeFlags.None, core.ɵNodeFlags.None);
expect(compilerCore.DepFlags.SkipSelf).toBe(core.ɵDepFlags.SkipSelf); expectToBe(compilerCore.NodeFlags.TypeElement, core.ɵNodeFlags.TypeElement);
expect(compilerCore.DepFlags.Optional).toBe(core.ɵDepFlags.Optional); expectToBe(compilerCore.NodeFlags.TypeText, core.ɵNodeFlags.TypeText);
expect(compilerCore.DepFlags.Value).toBe(core.ɵDepFlags.Value); expectToBe(compilerCore.NodeFlags.ProjectedTemplate, core.ɵNodeFlags.ProjectedTemplate);
expectToBe(compilerCore.NodeFlags.CatRenderNode, core.ɵNodeFlags.CatRenderNode);
expectToBe(compilerCore.NodeFlags.TypeNgContent, core.ɵNodeFlags.TypeNgContent);
expectToBe(compilerCore.NodeFlags.TypePipe, core.ɵNodeFlags.TypePipe);
expectToBe(compilerCore.NodeFlags.TypePureArray, core.ɵNodeFlags.TypePureArray);
expectToBe(compilerCore.NodeFlags.TypePureObject, core.ɵNodeFlags.TypePureObject);
expectToBe(compilerCore.NodeFlags.TypePurePipe, core.ɵNodeFlags.TypePurePipe);
expectToBe(compilerCore.NodeFlags.CatPureExpression, core.ɵNodeFlags.CatPureExpression);
expectToBe(compilerCore.NodeFlags.TypeValueProvider, core.ɵNodeFlags.TypeValueProvider);
expectToBe(compilerCore.NodeFlags.TypeClassProvider, core.ɵNodeFlags.TypeClassProvider);
expectToBe(compilerCore.NodeFlags.TypeFactoryProvider, core.ɵNodeFlags.TypeFactoryProvider);
expectToBe(
compilerCore.NodeFlags.TypeUseExistingProvider, core.ɵNodeFlags.TypeUseExistingProvider);
expectToBe(compilerCore.NodeFlags.LazyProvider, core.ɵNodeFlags.LazyProvider);
expectToBe(compilerCore.NodeFlags.PrivateProvider, core.ɵNodeFlags.PrivateProvider);
expectToBe(compilerCore.NodeFlags.TypeDirective, core.ɵNodeFlags.TypeDirective);
expectToBe(compilerCore.NodeFlags.Component, core.ɵNodeFlags.Component);
expectToBe(
compilerCore.NodeFlags.CatProviderNoDirective, core.ɵNodeFlags.CatProviderNoDirective);
expectToBe(compilerCore.NodeFlags.CatProvider, core.ɵNodeFlags.CatProvider);
expectToBe(compilerCore.NodeFlags.OnInit, core.ɵNodeFlags.OnInit);
expectToBe(compilerCore.NodeFlags.OnDestroy, core.ɵNodeFlags.OnDestroy);
expectToBe(compilerCore.NodeFlags.DoCheck, core.ɵNodeFlags.DoCheck);
expectToBe(compilerCore.NodeFlags.OnChanges, core.ɵNodeFlags.OnChanges);
expectToBe(compilerCore.NodeFlags.AfterContentInit, core.ɵNodeFlags.AfterContentInit);
expectToBe(compilerCore.NodeFlags.AfterContentChecked, core.ɵNodeFlags.AfterContentChecked);
expectToBe(compilerCore.NodeFlags.AfterViewInit, core.ɵNodeFlags.AfterViewInit);
expectToBe(compilerCore.NodeFlags.AfterViewChecked, core.ɵNodeFlags.AfterViewChecked);
expectToBe(compilerCore.NodeFlags.EmbeddedViews, core.ɵNodeFlags.EmbeddedViews);
expectToBe(compilerCore.NodeFlags.ComponentView, core.ɵNodeFlags.ComponentView);
expectToBe(compilerCore.NodeFlags.TypeContentQuery, core.ɵNodeFlags.TypeContentQuery);
expectToBe(compilerCore.NodeFlags.TypeViewQuery, core.ɵNodeFlags.TypeViewQuery);
expectToBe(compilerCore.NodeFlags.StaticQuery, core.ɵNodeFlags.StaticQuery);
expectToBe(compilerCore.NodeFlags.DynamicQuery, core.ɵNodeFlags.DynamicQuery);
expectToBe(compilerCore.NodeFlags.CatQuery, core.ɵNodeFlags.CatQuery);
expectToBe(compilerCore.NodeFlags.Types, core.ɵNodeFlags.Types);
expect(compilerCore.InjectFlags.Default).toBe(core.InjectFlags.Default); expectToBe(compilerCore.DepFlags.None, core.ɵDepFlags.None);
expect(compilerCore.InjectFlags.SkipSelf).toBe(core.InjectFlags.SkipSelf); expectToBe(compilerCore.DepFlags.SkipSelf, core.ɵDepFlags.SkipSelf);
expect(compilerCore.InjectFlags.Self).toBe(core.InjectFlags.Self); expectToBe(compilerCore.DepFlags.Optional, core.ɵDepFlags.Optional);
expectToBe(compilerCore.DepFlags.Value, core.ɵDepFlags.Value);
expect(compilerCore.ArgumentType.Inline).toBe(core.ɵArgumentType.Inline); expectToBe(compilerCore.InjectFlags.Default, core.InjectFlags.Default);
expect(compilerCore.ArgumentType.Dynamic).toBe(core.ɵArgumentType.Dynamic); expectToBe(compilerCore.InjectFlags.SkipSelf, core.InjectFlags.SkipSelf);
expectToBe(compilerCore.InjectFlags.Self, core.InjectFlags.Self);
expect(compilerCore.BindingFlags.TypeElementAttribute)
.toBe(core.ɵBindingFlags.TypeElementAttribute);
expect(compilerCore.BindingFlags.TypeElementClass).toBe(core.ɵBindingFlags.TypeElementClass);
expect(compilerCore.BindingFlags.TypeElementStyle).toBe(core.ɵBindingFlags.TypeElementStyle);
expect(compilerCore.BindingFlags.TypeProperty).toBe(core.ɵBindingFlags.TypeProperty);
expect(compilerCore.BindingFlags.SyntheticProperty)
.toBe(core.ɵBindingFlags.SyntheticProperty);
expect(compilerCore.BindingFlags.SyntheticHostProperty)
.toBe(core.ɵBindingFlags.SyntheticHostProperty);
expect(compilerCore.BindingFlags.CatSyntheticProperty)
.toBe(core.ɵBindingFlags.CatSyntheticProperty);
expect(compilerCore.BindingFlags.Types).toBe(core.ɵBindingFlags.Types);
expect(compilerCore.QueryBindingType.First).toBe(core.ɵQueryBindingType.First); expectToBe(compilerCore.ArgumentType.Inline, core.ɵArgumentType.Inline);
expect(compilerCore.QueryBindingType.All).toBe(core.ɵQueryBindingType.All); expectToBe(compilerCore.ArgumentType.Dynamic, core.ɵArgumentType.Dynamic);
expect(compilerCore.QueryValueType.ElementRef).toBe(core.ɵQueryValueType.ElementRef); expectToBe(
expect(compilerCore.QueryValueType.RenderElement).toBe(core.ɵQueryValueType.RenderElement); compilerCore.BindingFlags.TypeElementAttribute, core.ɵBindingFlags.TypeElementAttribute);
expect(compilerCore.QueryValueType.TemplateRef).toBe(core.ɵQueryValueType.TemplateRef); expectToBe(compilerCore.BindingFlags.TypeElementClass, core.ɵBindingFlags.TypeElementClass);
expect(compilerCore.QueryValueType.ViewContainerRef) expectToBe(compilerCore.BindingFlags.TypeElementStyle, core.ɵBindingFlags.TypeElementStyle);
.toBe(core.ɵQueryValueType.ViewContainerRef); expectToBe(compilerCore.BindingFlags.TypeProperty, core.ɵBindingFlags.TypeProperty);
expect(compilerCore.QueryValueType.Provider).toBe(core.ɵQueryValueType.Provider); expectToBe(compilerCore.BindingFlags.SyntheticProperty, core.ɵBindingFlags.SyntheticProperty);
expectToBe(
compilerCore.BindingFlags.SyntheticHostProperty,
core.ɵBindingFlags.SyntheticHostProperty);
expectToBe(
compilerCore.BindingFlags.CatSyntheticProperty, core.ɵBindingFlags.CatSyntheticProperty);
expectToBe(compilerCore.BindingFlags.Types, core.ɵBindingFlags.Types);
expect(compilerCore.ViewFlags.None).toBe(core.ɵViewFlags.None); expectToBe(compilerCore.QueryBindingType.First, core.ɵQueryBindingType.First);
expect(compilerCore.ViewFlags.OnPush).toBe(core.ɵViewFlags.OnPush); expectToBe(compilerCore.QueryBindingType.All, core.ɵQueryBindingType.All);
expectToBe(compilerCore.QueryValueType.ElementRef, core.ɵQueryValueType.ElementRef);
expectToBe(compilerCore.QueryValueType.RenderElement, core.ɵQueryValueType.RenderElement);
expectToBe(compilerCore.QueryValueType.TemplateRef, core.ɵQueryValueType.TemplateRef);
expectToBe(
compilerCore.QueryValueType.ViewContainerRef, core.ɵQueryValueType.ViewContainerRef);
expectToBe(compilerCore.QueryValueType.Provider, core.ɵQueryValueType.Provider);
expectToBe(compilerCore.ViewFlags.None, core.ɵViewFlags.None);
expectToBe(compilerCore.ViewFlags.OnPush, core.ɵViewFlags.OnPush);
}); });
}); });
} }

View File

@ -274,7 +274,7 @@ import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawM
it('should throw an error if a selector is being parsed while in the wrong mode', () => { it('should throw an error if a selector is being parsed while in the wrong mode', () => {
const cssCode = '.class > tag'; const cssCode = '.class > tag';
let capturedMessage: string = undefined !; let capturedMessage: string|null = null;
try { try {
tokenize(cssCode, false, CssLexerMode.STYLE_BLOCK); tokenize(cssCode, false, CssLexerMode.STYLE_BLOCK);
} catch (e) { } catch (e) {
@ -282,8 +282,8 @@ import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawM
} }
expect(capturedMessage).toMatch(/Unexpected character \[\>\] at column 0:7 in expression/g); expect(capturedMessage).toMatch(/Unexpected character \[\>\] at column 0:7 in expression/g);
capturedMessage = null !;
capturedMessage = null;
try { try {
tokenize(cssCode, false, CssLexerMode.SELECTOR); tokenize(cssCode, false, CssLexerMode.SELECTOR);
} catch (e) { } catch (e) {

View File

@ -170,21 +170,22 @@ function _getCaptureAst(capture: any[], index = 0): CssAst {
expect(captures.length).toEqual(3); expect(captures.length).toEqual(3);
const rule1 = <CssSelectorRuleAst>_getCaptureAst(captures, 0); const rule1 = <CssSelectorRuleAst>_getCaptureAst(captures, 0);
expect(rule1).toEqual(ast.rules[0]); expect(rule1).toEqual(ast.rules[0] as CssSelectorRuleAst);
const firstSelector = rule1.selectors[0]; const firstSelector = rule1.selectors[0];
const firstSimpleSelector = firstSelector.selectorParts[0]; const firstSimpleSelector = firstSelector.selectorParts[0];
_assertTokens(firstSimpleSelector.tokens, ['.', 'rule1']); _assertTokens(firstSimpleSelector.tokens, ['.', 'rule1']);
const rule2 = <CssSelectorRuleAst>_getCaptureAst(captures, 1); const rule2 = <CssSelectorRuleAst>_getCaptureAst(captures, 1);
expect(rule2).toEqual(ast.rules[1]); expect(rule2).toEqual(ast.rules[1] as CssSelectorRuleAst);
const secondSelector = rule2.selectors[0]; const secondSelector = rule2.selectors[0];
const secondSimpleSelector = secondSelector.selectorParts[0]; const secondSimpleSelector = secondSelector.selectorParts[0];
_assertTokens(secondSimpleSelector.tokens, ['.', 'rule2']); _assertTokens(secondSimpleSelector.tokens, ['.', 'rule2']);
const rule3 = <CssSelectorRuleAst>_getCaptureAst(captures, 2); const rule3 = <CssSelectorRuleAst>_getCaptureAst(captures, 2);
expect(rule3).toEqual((<CssMediaQueryRuleAst>ast.rules[2]).block.entries[0]); expect(rule3).toEqual(
(ast.rules[2] as CssSelectorRuleAst).block.entries[0] as CssSelectorRuleAst);
const thirdSelector = rule3.selectors[0]; const thirdSelector = rule3.selectors[0];
const thirdSimpleSelector = thirdSelector.selectorParts[0]; const thirdSimpleSelector = thirdSelector.selectorParts[0];

View File

@ -547,7 +547,7 @@ function fakeNoTranslate(
function extract( function extract(
html: string, implicitTags: string[] = [], html: string, implicitTags: string[] = [],
implicitAttrs: {[k: string]: string[]} = {}): [string[], string, string][] { implicitAttrs: {[k: string]: string[]} = {}): [string[], string, string, string][] {
const result = const result =
extractMessages(parseHtml(html), DEFAULT_INTERPOLATION_CONFIG, implicitTags, implicitAttrs); extractMessages(parseHtml(html), DEFAULT_INTERPOLATION_CONFIG, implicitTags, implicitAttrs);
@ -558,7 +558,7 @@ function extract(
// clang-format off // clang-format off
// https://github.com/angular/clang-format/issues/35 // https://github.com/angular/clang-format/issues/35
return result.messages.map( return result.messages.map(
message => [serializeI18nNodes(message.nodes), message.meaning, message.description, message.id]) as [string[], string, string][]; message => [serializeI18nNodes(message.nodes), message.meaning, message.description, message.id]) as [string[], string, string, string][];
// clang-format on // clang-format on
} }

View File

@ -116,9 +116,10 @@ function expectMap(
const sm = ctx.toSourceMapGenerator('o.ts').toJSON() !; const sm = ctx.toSourceMapGenerator('o.ts').toJSON() !;
const genPosition = {line: genLine + 1, column: genCol}; const genPosition = {line: genLine + 1, column: genCol};
const origPosition = originalPositionFor(sm, genPosition); const origPosition = originalPositionFor(sm, genPosition);
expect(origPosition.source).toEqual(source); // TODO: Review use of `any` here (#19904)
expect(origPosition.line).toEqual(srcLine === null ? null : srcLine + 1); expect(origPosition.source as any).toEqual(source);
expect(origPosition.column).toEqual(srcCol); expect(origPosition.line as any).toEqual(srcLine === null ? null : srcLine + 1);
expect(origPosition.column as any).toEqual(srcCol);
} }
// returns the number of segments per line // returns the number of segments per line

View File

@ -36,4 +36,4 @@ export function extractSourceMap(source: string): SourceMap|null {
function decodeB64String(s: string): string { function decodeB64String(s: string): string {
return b64.toByteArray(s).reduce((s: string, c: number) => s + String.fromCharCode(c), ''); return b64.toByteArray(s).reduce((s: string, c: number) => s + String.fromCharCode(c), '');
} }

View File

@ -20,7 +20,13 @@ import {ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/testing'
let resourceLoader: MockResourceLoader; let resourceLoader: MockResourceLoader;
beforeEach(() => { beforeEach(() => {
// Jasmine relies on methods on `Function.prototype`, so restore the prototype on the spy.
// Work around for: https://github.com/jasmine/jasmine/issues/1573
// TODO: Figure out a better way to retrieve the JIT sources, without spying on `Function`.
const originalProto = ɵglobal.Function.prototype;
jitSpy = spyOn(ɵglobal, 'Function').and.callThrough(); jitSpy = spyOn(ɵglobal, 'Function').and.callThrough();
ɵglobal.Function.prototype = originalProto;
resourceLoader = new MockResourceLoader(); resourceLoader = new MockResourceLoader();
TestBed.configureCompiler({providers: [{provide: ResourceLoader, useValue: resourceLoader}]}); TestBed.configureCompiler({providers: [{provide: ResourceLoader, useValue: resourceLoader}]});
}); });

View File

@ -35,12 +35,13 @@ function mockSystem(modules: {[module: string]: any}) {
it('loads a default factory by appending the factory suffix', async(() => { it('loads a default factory by appending the factory suffix', async(() => {
const loader = new SystemJsNgModuleLoader(new Compiler()); const loader = new SystemJsNgModuleLoader(new Compiler());
loader.load('test').then(contents => { expect(contents).toBe('test module factory'); }); loader.load('test').then(
contents => { expect(contents).toBe('test module factory' as any); });
})); }));
it('loads a named factory by appending the factory suffix', async(() => { it('loads a named factory by appending the factory suffix', async(() => {
const loader = new SystemJsNgModuleLoader(new Compiler()); const loader = new SystemJsNgModuleLoader(new Compiler());
loader.load('test#Named').then(contents => { loader.load('test#Named').then(contents => {
expect(contents).toBe('test NamedNgFactory'); expect(contents).toBe('test NamedNgFactory' as any);
}); });
})); }));
it('loads a named factory with a configured prefix and suffix', async(() => { it('loads a named factory with a configured prefix and suffix', async(() => {
@ -49,7 +50,7 @@ function mockSystem(modules: {[module: string]: any}) {
factoryPathSuffix: '/suffixed', factoryPathSuffix: '/suffixed',
}); });
loader.load('test#Named').then(contents => { loader.load('test#Named').then(contents => {
expect(contents).toBe('test module factory'); expect(contents).toBe('test module factory' as any);
}); });
})); }));
}); });

View File

@ -315,7 +315,7 @@ class TestObj {
// But we should still get an array of the right length based on function.length. // But we should still get an array of the right length based on function.length.
expect(reflector.parameters(ChildWithCtorNoDecorator)).toEqual([ expect(reflector.parameters(ChildWithCtorNoDecorator)).toEqual([
undefined, undefined, undefined undefined, undefined, undefined
]); ] as any[]); // TODO: Review use of `any` here (#19904)
expect(reflector.parameters(NoDecorators)).toEqual([]); expect(reflector.parameters(NoDecorators)).toEqual([]);
expect(reflector.parameters(<any>{})).toEqual([]); expect(reflector.parameters(<any>{})).toEqual([]);

View File

@ -1203,8 +1203,8 @@ describe('di', () => {
describe('@Attribute', () => { describe('@Attribute', () => {
it('should inject attribute', () => { it('should inject attribute', () => {
let exist: string|undefined = 'wrong'; let exist = 'wrong' as string | undefined;
let nonExist: string|undefined = 'wrong'; let nonExist = 'wrong' as string | undefined;
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) { const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) { if (rf & RenderFlags.Create) {
@ -1221,8 +1221,8 @@ describe('di', () => {
// https://stackblitz.com/edit/angular-8ytqkp?file=src%2Fapp%2Fapp.component.ts // https://stackblitz.com/edit/angular-8ytqkp?file=src%2Fapp%2Fapp.component.ts
it('should not inject attributes representing bindings and outputs', () => { it('should not inject attributes representing bindings and outputs', () => {
let exist: string|undefined = 'wrong'; let exist = 'wrong' as string | undefined;
let nonExist: string|undefined = 'wrong'; let nonExist = 'wrong' as string | undefined;
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) { const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) { if (rf & RenderFlags.Create) {
@ -1238,8 +1238,8 @@ describe('di', () => {
}); });
it('should not accidentally inject attributes representing bindings and outputs', () => { it('should not accidentally inject attributes representing bindings and outputs', () => {
let exist: string|undefined = 'wrong'; let exist = 'wrong' as string | undefined;
let nonExist: string|undefined = 'wrong'; let nonExist = 'wrong' as string | undefined;
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) { const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) { if (rf & RenderFlags.Create) {
@ -1415,7 +1415,7 @@ describe('di', () => {
// so that we have smaller HelloWorld. // so that we have smaller HelloWorld.
(parent.tNode as{parent: any}).parent = undefined; (parent.tNode as{parent: any}).parent = undefined;
const injector = getOrCreateNodeInjector(); const injector: any = getOrCreateNodeInjector(); // TODO: Review use of `any` here (#19904)
expect(injector).not.toBe(null); expect(injector).not.toBe(null);
} finally { } finally {
leaveView(oldView); leaveView(oldView);

View File

@ -259,7 +259,7 @@ describe('NgOnChangesFeature', () => {
it('correctly computes firstChange', () => { it('correctly computes firstChange', () => {
class MyDirective implements OnChanges { class MyDirective implements OnChanges {
public log: Array<string|SimpleChange> = []; public log: Array<string|SimpleChange|undefined> = [];
public valA: string = 'initValue'; public valA: string = 'initValue';
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
public valB !: string; public valB !: string;

View File

@ -112,7 +112,7 @@ describe('elementProperty', () => {
class OtherDir { class OtherDir {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
id !: boolean; id !: number;
clickStream = new EventEmitter(); clickStream = new EventEmitter();
static ngDirectiveDef = defineDirective({ static ngDirectiveDef = defineDirective({
@ -138,7 +138,7 @@ describe('elementProperty', () => {
class IdDir { class IdDir {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
idNumber !: number; idNumber !: string;
static ngDirectiveDef = defineDirective({ static ngDirectiveDef = defineDirective({
type: IdDir, type: IdDir,
@ -347,15 +347,14 @@ describe('elementProperty', () => {
} }
} }
expect(renderToHtml(Template, {condition: true, id1: 'one', id2: 'two', id3: 'three'}, deps)) expect(renderToHtml(Template, {condition: true, id1: 'one', id2: 'two', id3: 3}, deps))
.toEqual(`<button iddir="">Click me</button><button id="two">Click me too</button>`); .toEqual(`<button iddir="">Click me</button><button id="two">Click me too</button>`);
expect(idDir !.idNumber).toEqual('one'); expect(idDir !.idNumber).toEqual('one');
expect( expect(renderToHtml(Template, {condition: false, id1: 'four', id2: 'two', id3: 3}, deps))
renderToHtml(Template, {condition: false, id1: 'four', id2: 'two', id3: 'three'}, deps))
.toEqual(`<button iddir="">Click me</button><button otherdir="">Click me too</button>`); .toEqual(`<button iddir="">Click me</button><button otherdir="">Click me too</button>`);
expect(idDir !.idNumber).toEqual('four'); expect(idDir !.idNumber).toEqual('four');
expect(otherDir !.id).toEqual('three'); expect(otherDir !.id).toEqual(3);
}); });
}); });

View File

@ -293,11 +293,11 @@ describe('array literals', () => {
const e0_ff = const e0_ff =
(v0: any, v1: any, v2: any, v3: any, v4: any, v5: any, v6: any, v7: any, (v0: any, v1: any, v2: any, v3: any, v4: any, v5: any, v6: any, v7: any,
v8: any) => ['start', v0, v1, v2, v3, v4, v5, v6, v7, v8, 'end']; v8: any) => ['start', v0, v1, v2, v3, v4, v5, v6, v7, v8, 'end'];
const e0_ff_1 = (v: any) => { return {name: v}; }; const e0_ff_1 = (v: any) => `modified_${v}`;
renderToHtml(Template, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives); renderToHtml(Template, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives);
/** /**
* <my-comp [names]="['start', v0, v1, v2, v3, {name: v4}, v5, v6, v7, v8, 'end']"> * <my-comp [names]="['start', v0, v1, v2, v3, `modified_${v4}`, v5, v6, v7, v8, 'end']">
* </my-comp> * </my-comp>
*/ */
function Template(rf: RenderFlags, c: any) { function Template(rf: RenderFlags, c: any) {
@ -315,17 +315,17 @@ describe('array literals', () => {
} }
expect(myComp !.names).toEqual([ expect(myComp !.names).toEqual([
'start', 'a', 'b', 'c', 'd', {name: 'e'}, 'f', 'g', 'h', 'i', 'end' 'start', 'a', 'b', 'c', 'd', 'modified_e', 'f', 'g', 'h', 'i', 'end'
]); ]);
renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives); renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives);
expect(myComp !.names).toEqual([ expect(myComp !.names).toEqual([
'start', 'a1', 'b', 'c', 'd', {name: 'e'}, 'f', 'g', 'h', 'i', 'end' 'start', 'a1', 'b', 'c', 'd', 'modified_e', 'f', 'g', 'h', 'i', 'end'
]); ]);
renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e5', 'f', 'g', 'h', 'i'], directives); renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e5', 'f', 'g', 'h', 'i'], directives);
expect(myComp !.names).toEqual([ expect(myComp !.names).toEqual([
'start', 'a1', 'b', 'c', 'd', {name: 'e5'}, 'f', 'g', 'h', 'i', 'end' 'start', 'a1', 'b', 'c', 'd', 'modified_e5', 'f', 'g', 'h', 'i', 'end'
]); ]);
}); });

View File

@ -18,7 +18,7 @@ import {callMostRecentEventListenerHandler, compViewDef, createAndGetRootNodes,
* We map addEventListener to the Zones internal name. This is because we want to be fast * We map addEventListener to the Zones internal name. This is because we want to be fast
* and bypass the zone bookkeeping. We know that we can do the bookkeeping faster. * and bypass the zone bookkeeping. We know that we can do the bookkeeping faster.
*/ */
const addEventListener = '__zone_symbol__addEventListener'; const addEventListener = '__zone_symbol__addEventListener' as 'addEventListener';
{ {
describe(`Component Views`, () => { describe(`Component Views`, () => {

View File

@ -20,8 +20,8 @@ import {ARG_TYPE_VALUES, callMostRecentEventListenerHandler, checkNodeInlineOrDy
* We map addEventListener to the Zones internal name. This is because we want to be fast * We map addEventListener to the Zones internal name. This is because we want to be fast
* and bypass the zone bookkeeping. We know that we can do the bookkeeping faster. * and bypass the zone bookkeeping. We know that we can do the bookkeeping faster.
*/ */
const addEventListener = '__zone_symbol__addEventListener'; const addEventListener = '__zone_symbol__addEventListener' as 'addEventListener';
const removeEventListener = '__zone_symbol__removeEventListener'; const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEventListener';
{ {
describe(`View Elements`, () => { describe(`View Elements`, () => {

View File

@ -23,7 +23,7 @@ export const proxy: ClassDecorator = (t: any) => t;
const _global = <any>(typeof window === 'undefined' ? global : window); const _global = <any>(typeof window === 'undefined' ? global : window);
export const afterEach: Function = _global.afterEach; export const afterEach: Function = _global.afterEach;
export const expect: (actual: any) => jasmine.Matchers = _global.expect; export const expect: <T>(actual: T) => jasmine.Matchers<T> = _global.expect;
const jsmBeforeEach = _global.beforeEach; const jsmBeforeEach = _global.beforeEach;
const jsmDescribe = _global.describe; const jsmDescribe = _global.describe;

View File

@ -15,7 +15,7 @@ describe('testability example', () => {
describe('using task tracking', () => { describe('using task tracking', () => {
const URL = '/core/testability/ts/whenStable/'; const URL = '/core/testability/ts/whenStable/';
it('times out with a list of tasks', (done) => { it('times out with a list of tasks', (done: DoneFn) => {
browser.get(URL); browser.get(URL);
browser.ignoreSynchronization = true; browser.ignoreSynchronization = true;

View File

@ -11,13 +11,13 @@
"rxjs/*": ["../../node_modules/rxjs/*"] "rxjs/*": ["../../node_modules/rxjs/*"]
}, },
"outDir": "../../dist/examples", "outDir": "../../dist/examples",
"types": ["jasmine", "node", "angular", "systemjs"] "types": ["angular"]
}, },
"include": [ "include": [
"./**/*.ts", "../../node_modules/@types/jasminewd2/index.d.ts",
"../../node_modules/zone.js/dist/zone.js.d.ts", "../../tools/types-ext/jasminewd2.d.ts",
// TODO(i): we can't use protractor's built-in typings because they contain lots of ambient definitions "../types.d.ts",
"../../node_modules/@types/protractor/index.d.ts" "**/*.ts"
] ]
} }

View File

@ -0,0 +1,19 @@
// WARNING:
// This file is used to build the e2e tests only.
// The rest of the files are included in `/packages/tsconfig.json`.
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": []
},
"include": [
"../../node_modules/@types/jasminewd2/index.d.ts",
"../../tools/types-ext/jasminewd2.d.ts",
"../types.d.ts",
"**/e2e_test/*"
],
"exclude": []
}

View File

@ -50,4 +50,4 @@ describe('upgrade/static (full)', () => {
firstHero = element.all(by.css('ng1-hero')).get(0); firstHero = element.all(by.css('ng1-hero')).get(0);
expect(firstHero.element(by.css('h2')).getText()).toEqual('Wonder Woman'); expect(firstHero.element(by.css('h2')).getText()).toEqual('Wonder Woman');
}); });
}); });

View File

@ -10,7 +10,7 @@ import {ElementFinder, by} from 'protractor';
declare global { declare global {
namespace jasmine { namespace jasmine {
interface Matchers { interface Matchers<T> {
toBeAHero(): Promise<void>; toBeAHero(): Promise<void>;
toHaveName(exectedName: string): Promise<void>; toHaveName(exectedName: string): Promise<void>;
} }

View File

@ -92,14 +92,14 @@ function asyncValidator(expected: any, timeout = 0) {
}); });
it('should return custom accessor when provided', () => { it('should return custom accessor when provided', () => {
const customAccessor = new SpyValueAccessor(); const customAccessor: ControlValueAccessor = new SpyValueAccessor() as any;
const checkboxAccessor = new CheckboxControlValueAccessor(null !, null !); const checkboxAccessor = new CheckboxControlValueAccessor(null !, null !);
expect(selectValueAccessor(dir, <any>[defaultAccessor, customAccessor, checkboxAccessor])) expect(selectValueAccessor(dir, <any>[defaultAccessor, customAccessor, checkboxAccessor]))
.toEqual(customAccessor); .toEqual(customAccessor);
}); });
it('should return custom accessor when provided with select multiple', () => { it('should return custom accessor when provided with select multiple', () => {
const customAccessor = new SpyValueAccessor(); const customAccessor: ControlValueAccessor = new SpyValueAccessor() as any;
const selectMultipleAccessor = new SelectMultipleControlValueAccessor(null !, null !); const selectMultipleAccessor = new SelectMultipleControlValueAccessor(null !, null !);
expect(selectValueAccessor( expect(selectValueAccessor(
dir, <any>[defaultAccessor, customAccessor, selectMultipleAccessor])) dir, <any>[defaultAccessor, customAccessor, selectMultipleAccessor]))

View File

@ -207,7 +207,7 @@ import {MyInput, MyInputForm} from './value_accessor_integration_spec';
fixture.detectChanges(); fixture.detectChanges();
emailInput = fixture.debugElement.query(By.css('[formControlName="email"]')); emailInput = fixture.debugElement.query(By.css('[formControlName="email"]'));
expect(emailInput).toBe(null); expect(emailInput as any).toBe(null); // TODO: Review use of `any` here (#19904)
}); });
it('should strip array controls that are not found', () => { it('should strip array controls that are not found', () => {
@ -1393,7 +1393,7 @@ import {MyInput, MyInputForm} from './value_accessor_integration_spec';
fixture.componentInstance.form = formGroup; fixture.componentInstance.form = formGroup;
fixture.detectChanges(); fixture.detectChanges();
const values: string[] = []; const values: any[] = [];
const streams = merge( const streams = merge(
control.valueChanges, control.statusChanges, formGroup.valueChanges, control.valueChanges, control.statusChanges, formGroup.valueChanges,
formGroup.statusChanges); formGroup.statusChanges);
@ -1430,7 +1430,7 @@ import {MyInput, MyInputForm} from './value_accessor_integration_spec';
fixture.componentInstance.form = formGroup; fixture.componentInstance.form = formGroup;
fixture.detectChanges(); fixture.detectChanges();
const values: string[] = []; const values: (string | {[key: string]: string})[] = [];
const streams = merge( const streams = merge(
control.valueChanges, control.statusChanges, formGroup.valueChanges, control.valueChanges, control.statusChanges, formGroup.valueChanges,
formGroup.statusChanges); formGroup.statusChanges);

View File

@ -460,7 +460,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
const values: string[] = []; const values: any[] = [];
const form = fixture.debugElement.children[0].injector.get(NgForm); const form = fixture.debugElement.children[0].injector.get(NgForm);
const sub = merge(form.valueChanges !, form.statusChanges !) const sub = merge(form.valueChanges !, form.statusChanges !)
@ -748,7 +748,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
it('should reset properly', fakeAsync(() => { it('should reset properly', fakeAsync(() => {
const fixture = initTest(NgModelForm); const fixture = initTest(NgModelForm);
fixture.componentInstance.name = 'Nancy'; fixture.componentInstance.name = 'Nancy' as string | null;
fixture.componentInstance.options = {updateOn: 'submit'}; fixture.componentInstance.options = {updateOn: 'submit'};
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
@ -792,7 +792,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
const values: string[] = []; const values: any[] = [];
const form = fixture.debugElement.children[0].injector.get(NgForm); const form = fixture.debugElement.children[0].injector.get(NgForm);
const sub = merge(form.valueChanges !, form.statusChanges !) const sub = merge(form.valueChanges !, form.statusChanges !)
@ -1028,7 +1028,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
it('should reset the form to empty when reset event is fired', fakeAsync(() => { it('should reset the form to empty when reset event is fired', fakeAsync(() => {
const fixture = initTest(NgModelForm); const fixture = initTest(NgModelForm);
fixture.componentInstance.name = 'should be cleared'; fixture.componentInstance.name = 'should be cleared' as string | null;
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
@ -1654,7 +1654,7 @@ class StandaloneNgModel {
}) })
class NgModelForm { class NgModelForm {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
name !: string; name !: string | null;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
event !: Event; event !: Event;
options = {}; options = {};

View File

@ -327,7 +327,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
const fixture = initTest(NgModelSelectWithNullForm); const fixture = initTest(NgModelSelectWithNullForm);
const comp = fixture.componentInstance; const comp = fixture.componentInstance;
comp.cities = [{'name': 'SF'}, {'name': 'NYC'}]; comp.cities = [{'name': 'SF'}, {'name': 'NYC'}];
comp.selectedCity = null !; comp.selectedCity = null;
fixture.detectChanges(); fixture.detectChanges();
const select = fixture.debugElement.query(By.css('select')); const select = fixture.debugElement.query(By.css('select'));
@ -336,7 +336,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
dispatchEvent(select.nativeElement, 'change'); dispatchEvent(select.nativeElement, 'change');
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
expect(comp.selectedCity['name']).toEqual('NYC'); expect(comp.selectedCity !['name']).toEqual('NYC');
select.nativeElement.value = '0: null'; select.nativeElement.value = '0: null';
dispatchEvent(select.nativeElement, 'change'); dispatchEvent(select.nativeElement, 'change');
@ -1231,7 +1231,7 @@ class NgModelSelectForm {
` `
}) })
class NgModelSelectWithNullForm { class NgModelSelectWithNullForm {
selectedCity: {[k: string]: string} = {}; selectedCity: {[k: string]: string}|null = {};
cities: any[] = []; cities: any[] = [];
} }

View File

@ -80,14 +80,14 @@ import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
it('supports setting and accessing value \'false\' via get', () => { it('supports setting and accessing value \'false\' via get', () => {
const transferState: TransferState = TestBed.get(TransferState); const transferState: TransferState = TestBed.get(TransferState);
transferState.set(TEST_KEY, false); transferState.set(TEST_KEY, false);
expect(transferState.get(TEST_KEY, 20)).toBe(false); expect(transferState.get(TEST_KEY, true)).toBe(false);
expect(transferState.hasKey(TEST_KEY)).toBe(true); expect(transferState.hasKey(TEST_KEY)).toBe(true);
}); });
it('supports setting and accessing value \'null\' via get', () => { it('supports setting and accessing value \'null\' via get', () => {
const transferState: TransferState = TestBed.get(TransferState); const transferState: TransferState = TestBed.get(TransferState);
transferState.set(TEST_KEY, null); transferState.set(TEST_KEY, null);
expect(transferState.get(TEST_KEY, 20)).toBe(null); expect(transferState.get(TEST_KEY, 20 as any)).toBe(null);
expect(transferState.hasKey(TEST_KEY)).toBe(true); expect(transferState.hasKey(TEST_KEY)).toBe(true);
}); });
@ -130,4 +130,4 @@ import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
expect(unescapedObj['testString']).toBe(testString); expect(unescapedObj['testString']).toBe(testString);
}); });
}); });
})(); })();

View File

@ -809,7 +809,7 @@ class CompWithUrlTemplate {
describe('errors', () => { describe('errors', () => {
let originalJasmineIt: (description: string, func: () => void) => jasmine.Spec; let originalJasmineIt: (description: string, func: () => void) => jasmine.Spec;
let originalJasmineBeforeEach: (beforeEachFunction: () => void) => void; let originalJasmineBeforeEach: (beforeEachFunction: (done: DoneFn) => void) => void;
const patchJasmineIt = () => { const patchJasmineIt = () => {
let resolve: (result: any) => void; let resolve: (result: any) => void;

View File

@ -15,7 +15,7 @@ import {ɵgetDOM as getDOM} from '@angular/platform-browser';
/** /**
* Jasmine matchers that check Angular specific conditions. * Jasmine matchers that check Angular specific conditions.
*/ */
export interface NgMatchers extends jasmine.Matchers { export interface NgMatchers extends jasmine.Matchers<any> {
/** /**
* Expect the value to be a `Promise`. * Expect the value to be a `Promise`.
* *

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {PRIMARY_OUTLET, ParamMap, convertToParamMap} from './shared'; import {PRIMARY_OUTLET, ParamMap, Params, convertToParamMap} from './shared';
import {forEach, shallowEqual} from './utils/collection'; import {forEach, shallowEqual} from './utils/collection';
export function createEmptyUrlTree() { export function createEmptyUrlTree() {
@ -23,8 +23,8 @@ export function containsTree(container: UrlTree, containee: UrlTree, exact: bool
containsSegmentGroup(container.root, containee.root); containsSegmentGroup(container.root, containee.root);
} }
function equalQueryParams( function equalQueryParams(container: Params, containee: Params): boolean {
container: {[k: string]: string}, containee: {[k: string]: string}): boolean { // TODO: This does not handle array params correctly.
return shallowEqual(container, containee); return shallowEqual(container, containee);
} }
@ -38,8 +38,8 @@ function equalSegmentGroups(container: UrlSegmentGroup, containee: UrlSegmentGro
return true; return true;
} }
function containsQueryParams( function containsQueryParams(container: Params, containee: Params): boolean {
container: {[k: string]: string}, containee: {[k: string]: string}): boolean { // TODO: This does not handle array params correctly.
return Object.keys(containee).length <= Object.keys(container).length && return Object.keys(containee).length <= Object.keys(container).length &&
Object.keys(containee).every(key => containee[key] === container[key]); Object.keys(containee).every(key => containee[key] === container[key]);
} }
@ -112,7 +112,7 @@ export class UrlTree {
/** The root segment group of the URL tree */ /** The root segment group of the URL tree */
public root: UrlSegmentGroup, public root: UrlSegmentGroup,
/** The query params of the URL */ /** The query params of the URL */
public queryParams: {[key: string]: string}, public queryParams: Params,
/** The fragment of the URL */ /** The fragment of the URL */
public fragment: string|null) {} public fragment: string|null) {}
@ -446,8 +446,8 @@ class UrlParser {
return new UrlSegmentGroup([], this.parseChildren()); return new UrlSegmentGroup([], this.parseChildren());
} }
parseQueryParams(): {[key: string]: any} { parseQueryParams(): Params {
const params: {[key: string]: any} = {}; const params: Params = {};
if (this.consumeOptional('?')) { if (this.consumeOptional('?')) {
do { do {
this.parseQueryParam(params); this.parseQueryParam(params);
@ -534,7 +534,7 @@ class UrlParser {
} }
// Parse a single query parameter `name[=value]` // Parse a single query parameter `name[=value]`
private parseQueryParam(params: {[key: string]: any}): void { private parseQueryParam(params: Params): void {
const key = matchQueryParams(this.remaining); const key = matchQueryParams(this.remaining);
if (!key) { if (!key) {
return; return;

View File

@ -210,7 +210,7 @@ describe('bootstrap', () => {
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => { platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router); const router = res.injector.get(Router);
spyOn(router, 'resetRootComponentType').and.callThrough(); spyOn(router as any, 'resetRootComponentType').and.callThrough();
const appRef: ApplicationRef = res.injector.get(ApplicationRef); const appRef: ApplicationRef = res.injector.get(ApplicationRef);
appRef.bootstrap(SecondRootCmp); appRef.bootstrap(SecondRootCmp);
@ -236,7 +236,7 @@ describe('bootstrap', () => {
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => { platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router); const router = res.injector.get(Router);
spyOn(router, 'resetRootComponentType').and.callThrough(); spyOn(router as any, 'resetRootComponentType').and.callThrough();
const appRef: ApplicationRef = res.injector.get(ApplicationRef); const appRef: ApplicationRef = res.injector.get(ApplicationRef);
appRef.components[0].onDestroy(() => { appRef.components[0].onDestroy(() => {

View File

@ -131,7 +131,7 @@ function checkActivatedRoute(
if (actual === null) { if (actual === null) {
expect(actual).toBeDefined(); expect(actual).toBeDefined();
} else { } else {
expect(actual.component).toBe(cmp); expect(actual.component as any).toBe(cmp);
expect(actual.outlet).toEqual(outlet); expect(actual.outlet).toEqual(outlet);
} }
} }

View File

@ -799,7 +799,7 @@ function checkActivatedRoute(
} else { } else {
expect(actual.url.map(s => s.path).join('/')).toEqual(url); expect(actual.url.map(s => s.path).join('/')).toEqual(url);
expect(actual.params).toEqual(params); expect(actual.params).toEqual(params);
expect(actual.component).toBe(cmp); expect(actual.component as any).toBe(cmp);
expect(actual.outlet).toEqual(outlet); expect(actual.outlet).toEqual(outlet);
} }
} }

View File

@ -9,12 +9,12 @@
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {TestBed, inject} from '@angular/core/testing'; import {TestBed, inject} from '@angular/core/testing';
import {ResolveData} from '../src/config'; import {Routes} from '../src/config';
import {ChildActivationStart} from '../src/events'; import {ChildActivationStart} from '../src/events';
import {PreActivation} from '../src/pre_activation'; import {PreActivation} from '../src/pre_activation';
import {Router} from '../src/router'; import {Router} from '../src/router';
import {ChildrenOutletContexts} from '../src/router_outlet_context'; import {ChildrenOutletContexts} from '../src/router_outlet_context';
import {ActivatedRouteSnapshot, RouterStateSnapshot, createEmptyStateSnapshot} from '../src/router_state'; import {RouterStateSnapshot, createEmptyStateSnapshot} from '../src/router_state';
import {DefaultUrlSerializer} from '../src/url_tree'; import {DefaultUrlSerializer} from '../src/url_tree';
import {TreeNode} from '../src/utils/tree'; import {TreeNode} from '../src/utils/tree';
import {RouterTestingModule} from '../testing/src/router_testing_module'; import {RouterTestingModule} from '../testing/src/router_testing_module';
@ -30,14 +30,17 @@ describe('Router', () => {
it('should copy config to avoid mutations of user-provided objects', () => { it('should copy config to avoid mutations of user-provided objects', () => {
const r: Router = TestBed.get(Router); const r: Router = TestBed.get(Router);
const configs = [{ const configs: Routes = [{
path: 'a', path: 'a',
component: TestComponent, component: TestComponent,
children: [{path: 'b', component: TestComponent}, {path: 'c', component: TestComponent}] children: [{path: 'b', component: TestComponent}, {path: 'c', component: TestComponent}]
}]; }];
const children = configs[0].children !;
r.resetConfig(configs); r.resetConfig(configs);
let rConfigs = r.config; const rConfigs = r.config;
const rChildren = rConfigs[0].children !;
// routes array and shallow copy // routes array and shallow copy
expect(configs).not.toBe(rConfigs); expect(configs).not.toBe(rConfigs);
@ -46,11 +49,11 @@ describe('Router', () => {
expect(configs[0].component).toBe(rConfigs[0].component); expect(configs[0].component).toBe(rConfigs[0].component);
// children should be new array and routes shallow copied // children should be new array and routes shallow copied
expect(configs[0].children).not.toBe(rConfigs[0].children); expect(children).not.toBe(rChildren);
expect(configs[0].children[0]).not.toBe(rConfigs[0].children ![0]); expect(children[0]).not.toBe(rChildren[0]);
expect(configs[0].children[0].path).toBe(rConfigs[0].children ![0].path); expect(children[0].path).toBe(rChildren[0].path);
expect(configs[0].children[1]).not.toBe(rConfigs[0].children ![1]); expect(children[1]).not.toBe(rChildren[1]);
expect(configs[0].children[1].path).toBe(rConfigs[0].children ![1].path); expect(children[1].path).toBe(rChildren[1].path);
}); });
}); });

View File

@ -125,41 +125,41 @@ describe('RouterState & Snapshot', () => {
} }
it('should return false when params are different', () => { it('should return false when params are different', () => {
expect(equalParamsAndUrlSegments(createSnapshot({a: 1}, []), createSnapshot({a: 2}, []))) expect(equalParamsAndUrlSegments(createSnapshot({a: '1'}, []), createSnapshot({a: '2'}, [])))
.toEqual(false); .toEqual(false);
}); });
it('should return false when urls are different', () => { it('should return false when urls are different', () => {
expect(equalParamsAndUrlSegments( expect(equalParamsAndUrlSegments(
createSnapshot({a: 1}, [new UrlSegment('a', {})]), createSnapshot({a: '1'}, [new UrlSegment('a', {})]),
createSnapshot({a: 1}, [new UrlSegment('b', {})]))) createSnapshot({a: '1'}, [new UrlSegment('b', {})])))
.toEqual(false); .toEqual(false);
}); });
it('should return true othewise', () => { it('should return true othewise', () => {
expect(equalParamsAndUrlSegments( expect(equalParamsAndUrlSegments(
createSnapshot({a: 1}, [new UrlSegment('a', {})]), createSnapshot({a: '1'}, [new UrlSegment('a', {})]),
createSnapshot({a: 1}, [new UrlSegment('a', {})]))) createSnapshot({a: '1'}, [new UrlSegment('a', {})])))
.toEqual(true); .toEqual(true);
}); });
it('should return false when upstream params are different', () => { it('should return false when upstream params are different', () => {
const [snapshot1, snapshot2] = const [snapshot1, snapshot2] =
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {c: 1}], ['a', 'a']); createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {c: '1'}], ['a', 'a']);
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false); expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false);
}); });
it('should return false when upstream urls are different', () => { it('should return false when upstream urls are different', () => {
const [snapshot1, snapshot2] = const [snapshot1, snapshot2] =
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {b: 1}], ['a', 'b']); createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {b: '1'}], ['a', 'b']);
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false); expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false);
}); });
it('should return true when upstream urls and params are equal', () => { it('should return true when upstream urls and params are equal', () => {
const [snapshot1, snapshot2] = const [snapshot1, snapshot2] =
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {b: 1}], ['a', 'a']); createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {b: '1'}], ['a', 'a']);
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(true); expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(true);
}); });
@ -184,8 +184,8 @@ describe('RouterState & Snapshot', () => {
} }
it('should call change observers', () => { it('should call change observers', () => {
const firstPlace = createSnapshot({a: 1}, []); const firstPlace = createSnapshot({a: '1'}, []);
const secondPlace = createSnapshot({a: 2}, []); const secondPlace = createSnapshot({a: '2'}, []);
route.snapshot = firstPlace; route.snapshot = firstPlace;
(route as any)._futureSnapshot = secondPlace; (route as any)._futureSnapshot = secondPlace;

View File

@ -23,7 +23,7 @@ describe('SpyNgModuleFactoryLoader', () => {
}); });
it('should return the created promise', () => { it('should return the created promise', () => {
const expected = Promise.resolve('returned'); const expected: any = Promise.resolve('returned');
const compiler: any = {compileModuleAsync: () => expected}; const compiler: any = {compileModuleAsync: () => expected};
const r = new SpyNgModuleFactoryLoader(<any>compiler); const r = new SpyNgModuleFactoryLoader(<any>compiler);

View File

@ -387,35 +387,35 @@ import {async_fit, async_it} from './async';
}); });
it('processes update availability notifications when sent', (done: DoneFn) => { it('processes update availability notifications when sent', (done: DoneFn) => {
update.available.subscribe(event => { update.available.subscribe(event => {
expect(event.current).toEqual({version: 'A'}); expect(event.current).toEqual({hash: 'A'});
expect(event.available).toEqual({version: 'B'}); expect(event.available).toEqual({hash: 'B'});
expect(event.type).toEqual('UPDATE_AVAILABLE'); expect(event.type).toEqual('UPDATE_AVAILABLE');
done(); done();
}); });
mock.sendMessage({ mock.sendMessage({
type: 'UPDATE_AVAILABLE', type: 'UPDATE_AVAILABLE',
current: { current: {
version: 'A', hash: 'A',
}, },
available: { available: {
version: 'B', hash: 'B',
}, },
}); });
}); });
it('processes update activation notifications when sent', (done: DoneFn) => { it('processes update activation notifications when sent', (done: DoneFn) => {
update.activated.subscribe(event => { update.activated.subscribe(event => {
expect(event.previous).toEqual({version: 'A'}); expect(event.previous).toEqual({hash: 'A'});
expect(event.current).toEqual({version: 'B'}); expect(event.current).toEqual({hash: 'B'});
expect(event.type).toEqual('UPDATE_ACTIVATED'); expect(event.type).toEqual('UPDATE_ACTIVATED');
done(); done();
}); });
mock.sendMessage({ mock.sendMessage({
type: 'UPDATE_ACTIVATED', type: 'UPDATE_ACTIVATED',
previous: { previous: {
version: 'A', hash: 'A',
}, },
current: { current: {
version: 'B', hash: 'B',
}, },
}); });
}); });

View File

@ -30,10 +30,11 @@
}, },
"exclude": [ "exclude": [
"bazel", "bazel",
"compiler-cli/integrationtest",
"platform-server/integrationtest",
"common/locales", "common/locales",
"elements/schematics" "compiler-cli/integrationtest",
"elements/schematics",
"examples/**/e2e_test/*",
"platform-server/integrationtest"
] ]
} }

7
packages/types.d.ts vendored
View File

@ -8,20 +8,19 @@
// This file contains all ambient imports needed to compile the modules/ source code // This file contains all ambient imports needed to compile the modules/ source code
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
/// <reference path="../node_modules/@types/hammerjs/index.d.ts" /> /// <reference path="../node_modules/@types/hammerjs/index.d.ts" />
/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> /// <reference path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/node/index.d.ts" /> /// <reference path="../node_modules/@types/node/index.d.ts" />
/// <reference path="../node_modules/@types/selenium-webdriver/index.d.ts" /> /// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
/// <reference path="./es6-subset.d.ts" /> /// <reference path="./es6-subset.d.ts" />
/// <reference path="./system.d.ts" />
/// <reference path="./goog.d.ts" /> /// <reference path="./goog.d.ts" />
/// <reference path="./system.d.ts" />
declare let isNode: boolean; declare let isNode: boolean;
declare let isBrowser: boolean; declare let isBrowser: boolean;
declare namespace jasmine { declare namespace jasmine {
interface Matchers { interface Matchers<T> {
toHaveProperties(obj: any): boolean; toHaveProperties(obj: any): boolean;
} }
} }

View File

@ -787,7 +787,7 @@ withEachNg1Version(() => {
childMod.componentFactoryResolver.resolveComponentFactory(LazyLoadedComponent) !; childMod.componentFactoryResolver.resolveComponentFactory(LazyLoadedComponent) !;
const lazyCmp = cmpFactory.create(componentInjector); const lazyCmp = cmpFactory.create(componentInjector);
expect(lazyCmp.instance.module).toBe(childMod.injector); expect(lazyCmp.instance.module.injector).toBe(childMod.injector);
}); });
})); }));

View File

@ -60,5 +60,6 @@ travisFoldEnd "tsc tools"
travisFoldStart "tsc all" travisFoldStart "tsc all"
node dist/tools/@angular/compiler-cli/src/main -p packages/tsconfig-metadata.json node dist/tools/@angular/compiler-cli/src/main -p packages/tsconfig-metadata.json
$(npm bin)/tsc -p packages $(npm bin)/tsc -p packages
$(npm bin)/tsc -p packages/examples
$(npm bin)/tsc -p modules $(npm bin)/tsc -p modules
travisFoldEnd "tsc all" travisFoldEnd "tsc all"

View File

@ -533,9 +533,7 @@ export declare abstract class UrlSerializer {
export declare class UrlTree { export declare class UrlTree {
fragment: string | null; fragment: string | null;
readonly queryParamMap: ParamMap; readonly queryParamMap: ParamMap;
queryParams: { queryParams: Params;
[key: string]: string;
};
root: UrlSegmentGroup; root: UrlSegmentGroup;
toString(): string; toString(): string;
} }

View File

@ -40,10 +40,7 @@ const BaseConfig = {
}; };
if (platform == 'node') { if (platform == 'node') {
const specFiles = [ const specFiles = ['@angular/**/*_spec.js'];
'@angular/**/*_spec.js', '@angular/compiler-cli/test/**/*_spec.js',
'@angular/benchpress/test/**/*_spec.js'
];
tscWatch = new TscWatch(Object.assign( tscWatch = new TscWatch(Object.assign(
{ {
tsconfig: 'packages/tsconfig.json', tsconfig: 'packages/tsconfig.json',

28
tools/types-ext/jasminewd2.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Extended typings for `jasminewd2`.
*
* The currently used `jasminewd2` version (v2.1.0), supports passing a `done` callback to a spec,
* but the latest typings on [DefinitelyTyped][1] do not reflect that.
* Overwrite the relevant function signatures to add a `done` callback.
*
* [1]:
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/566e0394859fdc1dc893658ccec6b06372d56a91/types/jasminewd2/index.d.ts#L9-L15
*/
declare function it(
expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function fit(
expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function xit(
expectation: string, assertion?: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function beforeEach(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function afterEach(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function beforeAll(action: (done: DoneFn) => Promise<void>, timeout?: number): void;
declare function afterAll(action: (done: DoneFn) => Promise<void>, timeout?: number): void;

View File

@ -96,9 +96,15 @@
version "2.0.35" version "2.0.35"
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.35.tgz#7b7c950c7d54593e23bffc8d2b4feba9866a7277" resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.35.tgz#7b7c950c7d54593e23bffc8d2b4feba9866a7277"
"@types/jasmine@2.2.22-alpha": "@types/jasmine@*", "@types/jasmine@^2.8.8":
version "2.2.22-alpha" version "2.8.8"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.22-alpha.tgz#eecaee43fe42ef6b5cfefad1bcc370c433f485bf" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.8.tgz#bf53a7d193ea8b03867a38bfdb4fbb0e0bf066c9"
"@types/jasminewd2@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/jasminewd2/-/jasminewd2-2.0.3.tgz#0d2886b0cbdae4c0eeba55e30792f584bf040a95"
dependencies:
"@types/jasmine" "*"
"@types/minimatch@*": "@types/minimatch@*":
version "3.0.3" version "3.0.3"
@ -2517,13 +2523,6 @@ glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glo
once "^1.3.0" once "^1.3.0"
path-is-absolute "^1.0.0" path-is-absolute "^1.0.0"
glob@^3.2.11:
version "3.2.11"
resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d"
dependencies:
inherits "2"
minimatch "0.3"
glob@^4.3.1: glob@^4.3.1:
version "4.5.3" version "4.5.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f"
@ -3256,11 +3255,7 @@ isstream@~0.1.1, isstream@~0.1.2:
version "0.1.2" version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
jasmine-core@2.4.1, jasmine-core@~2.4.0: jasmine-core@2.8, jasmine-core@~2.8.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.4.1.tgz#6f83ab3a0f16951722ce07d206c773d57cc838be"
jasmine-core@~2.8.0:
version "2.8.0" version "2.8.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e"
@ -3270,15 +3265,7 @@ jasmine-diff@^0.1.3:
dependencies: dependencies:
diff "^3.2.0" diff "^3.2.0"
jasmine@2.4.1: jasmine@2.8, jasmine@^2.5.3:
version "2.4.1"
resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.4.1.tgz#9016dda453213d27ac6d43dc4ea97315a189085e"
dependencies:
exit "^0.1.2"
glob "^3.2.11"
jasmine-core "~2.4.0"
jasmine@^2.5.3:
version "2.8.0" version "2.8.0"
resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.8.0.tgz#6b089c0a11576b1f16df11b80146d91d4e8b8a3e" resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.8.0.tgz#6b089c0a11576b1f16df11b80146d91d4e8b8a3e"
dependencies: dependencies:
@ -3993,13 +3980,6 @@ mimic-fn@^1.0.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
minimatch@0.3:
version "0.3.0"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd"
dependencies:
lru-cache "2"
sigmund "~1.0.0"
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: "minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4:
version "3.0.4" version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"