Skip to content

Commit 00c110b

Browse files
gkalpakmhevery
authored andcommitted
build: upgrade jasmine (and related typings) to latest version (angular#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]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/566e0394859fdc1dc893658ccec6b06372d56a91/types/jasminewd2/index.d.ts#L9-L15 Fixes angular#23952 Closes angular#24733 PR Close angular#19904
1 parent 1e74ea9 commit 00c110b

File tree

59 files changed

+339
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+339
-290
lines changed

build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ if [[ ${BUILD_ALL} == true && ${TYPECHECK_ALL} == true ]]; then
409409
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
410410
$TSC -p ${TSCONFIG}
411411
travisFoldEnd "tsc -p ${TSCONFIG}"
412+
TSCONFIG="packages/examples/tsconfig.json"
413+
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
414+
$TSC -p ${TSCONFIG}
415+
travisFoldEnd "tsc -p ${TSCONFIG}"
412416
TSCONFIG="modules/tsconfig.json"
413417
travisFoldStart "tsc -p ${TSCONFIG}" "no-xtrace"
414418
$TSC -p ${TSCONFIG}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"compilerOptions": {
33
"outDir": "../dist/e2e",
4-
"types": ["jasmine"],
4+
"types": [
5+
"jasmine",
6+
"jasminewd2"
7+
],
58
"skipLibCheck": true
69
}
710
}

integration/dynamic-compiler/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
},
1919
"license": "MIT",
2020
"devDependencies": {
21-
"@types/jasmine": "file:../../node_modules/@types/jasmine",
2221
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
22+
"@types/jasmine": "file:../../node_modules/@types/jasmine",
23+
"@types/jasminewd2": "file:../../node_modules/@types/jasminewd2",
2324
"concurrently": "3.4.0",
2425
"lite-server": "2.2.2",
2526
"protractor": "file:../../node_modules/protractor",

modules/types.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
// This file contains all ambient imports needed to compile the modules/ source code
1010

11-
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
1211
/// <reference path="../node_modules/@types/hammerjs/index.d.ts" />
1312
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />
13+
/// <reference path="../node_modules/@types/jasminewd2/index.d.ts" />
1414
/// <reference path="../node_modules/@types/node/index.d.ts" />
15-
/// <reference path="../node_modules/@types/selenium-webdriver/index.d.ts" />
15+
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
16+
/// <reference path="../tools/types-ext/jasminewd2.d.ts" />
1617
/// <reference path="./es6-subset.d.ts" />
1718
/// <reference path="./system.d.ts" />

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"@types/diff": "^3.2.2",
4848
"@types/fs-extra": "4.0.2",
4949
"@types/hammerjs": "2.0.35",
50-
"@types/jasmine": "2.2.22-alpha",
50+
"@types/jasmine": "^2.8.8",
51+
"@types/jasminewd2": "^2.0.3",
5152
"@types/minimist": "^1.2.0",
5253
"@types/node": "6.0.88",
5354
"@types/selenium-webdriver": "3.0.7",
@@ -84,8 +85,8 @@
8485
"hammerjs": "2.0.8",
8586
"husky": "^0.14.3",
8687
"incremental-dom": "0.4.1",
87-
"jasmine": "2.4.1",
88-
"jasmine-core": "2.4.1",
88+
"jasmine": "2.8",
89+
"jasmine-core": "2.8",
8990
"jpm": "1.3.1",
9091
"karma": "0.13.20",
9192
"karma-browserstack-launcher": "0.1.9",

packages/bazel/test/ngc-wrapped/test_support.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface TestSupport {
3030
writeFiles(...mockDirs: {[fileName: string]: string}[]): void;
3131
shouldExist(fileName: string): void;
3232
shouldNotExist(fileName: string): void;
33-
runOneBuild(): void;
33+
runOneBuild(): boolean;
3434
}
3535

3636
export function setup(

packages/benchpress/test/metric/user_metric_spec.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ import {Options, PerfLogEvent, PerfLogFeatures, UserMetric, WebDriverAdapter} fr
4848
const metric = createMetric(
4949
[[]], new PerfLogFeatures(),
5050
{userMetrics: {'loadTime': 'time to load', 'content': 'time to see content'}});
51-
metric.beginMeasure()
52-
.then((_) => metric.endMeasure(true))
53-
.then((values: {[key: string]: string}) => {
54-
expect(values['loadTime']).toBe(25);
55-
expect(values['content']).toBe(250);
56-
async.done();
57-
});
51+
metric.beginMeasure().then(() => metric.endMeasure(true)).then(values => {
52+
expect(values['loadTime']).toBe(25);
53+
expect(values['content']).toBe(250);
54+
async.done();
55+
});
5856

5957
wdAdapter.data['loadTime'] = 25;
6058
// Wait before setting 2nd property.

packages/common/test/directives/ng_component_outlet_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
166166
fixture.componentInstance.currentComponent = Module2InjectedComponent;
167167
fixture.detectChanges();
168168

169-
const moduleRef = fixture.componentInstance.ngComponentOutlet['_moduleRef'];
169+
const moduleRef = fixture.componentInstance.ngComponentOutlet['_moduleRef'] !;
170170
spyOn(moduleRef, 'destroy').and.callThrough();
171171

172-
expect(moduleRef !.destroy).not.toHaveBeenCalled();
172+
expect(moduleRef.destroy).not.toHaveBeenCalled();
173173
fixture.destroy();
174-
expect(moduleRef !.destroy).toHaveBeenCalled();
174+
expect(moduleRef.destroy).toHaveBeenCalled();
175175
}));
176176

177177
it('should not re-create moduleRef when it didn\'t actually change', async(() => {

packages/compiler-cli/integrationtest/ngtools_src/feature2/feature2.module.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ export class FeatureComponent {
1616
@NgModule({
1717
declarations: [FeatureComponent],
1818
imports: [RouterModule.forChild([
19-
{path: '', component: FeatureComponent}, {path: 'd', loadChildren: './default.module'} {
20-
path: 'e',
21-
loadChildren: 'feature/feature.module#FeatureModule'
22-
}
19+
{path: '', component: FeatureComponent},
20+
{path: 'd', loadChildren: './default.module'},
21+
{path: 'e', loadChildren: 'feature/feature.module#FeatureModule'},
2322
])]
2423
})
2524
export class Feature2Module {

packages/compiler-cli/src/ngtools_api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import * as ts from 'typescript';
2323

24-
import {CompilerHost, CompilerOptions, LazyRoute} from './transformers/api';
24+
import {CompilerOptions} from './transformers/api';
2525
import {getOriginalReferences} from './transformers/compiler_host';
2626
import {createProgram} from './transformers/entry_points';
2727

packages/compiler-cli/test/diagnostics/expression_diagnostics_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('expression diagnostics', () => {
7676
}
7777
}
7878

79-
function reject(template: string, expected: string | RegExp) {
79+
function reject(template: string, expected: string) {
8080
const info = getDiagnosticTemplateInfo(context, type, 'app/app.component.html', template);
8181
if (info) {
8282
const diagnostics = getTemplateExpressionDiagnostics(info);
@@ -240,4 +240,4 @@ const FILES: Directory = {
240240
`
241241
}
242242
}
243-
};
243+
};

packages/compiler-cli/test/metadata/collector_spec.ts

+30-28
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import * as ts from 'typescript';
1010

1111
import {MetadataCollector} from '../../src/metadata/collector';
12-
import {ClassMetadata, ConstructorMetadata, METADATA_VERSION, MetadataEntry, ModuleMetadata, isClassMetadata, isMetadataGlobalReferenceExpression} from '../../src/metadata/schema';
12+
import {ClassMetadata, ConstructorMetadata, METADATA_VERSION, MetadataEntry, MetadataMap, MetadataSymbolicExpression, ModuleMetadata, isClassMetadata, isMetadataGlobalReferenceExpression} from '../../src/metadata/schema';
1313

1414
import {Directory, Host, expectValidSources} from './typescript.mocks';
1515

@@ -269,9 +269,11 @@ describe('Collector', () => {
269269
it('should provide any reference for an any ctor parameter type', () => {
270270
const casesAny = <ClassMetadata>casesMetadata.metadata['CaseAny'];
271271
expect(casesAny).toBeTruthy();
272-
const ctorData = casesAny.members !['__ctor__'];
273-
expect(ctorData).toEqual(
274-
[{__symbolic: 'constructor', parameters: [{__symbolic: 'reference', name: 'any'}]}]);
272+
const ctorData = casesAny.members !['__ctor__'] as ConstructorMetadata[];
273+
expect(ctorData).toEqual([{
274+
__symbolic: 'constructor',
275+
parameters: [{__symbolic: 'reference', name: 'any'} as MetadataSymbolicExpression]
276+
}]);
275277
});
276278

277279
it('should record annotations on set and get declarations', () => {
@@ -285,7 +287,8 @@ describe('Collector', () => {
285287
arguments: ['firstName']
286288
}]
287289
}]
288-
});
290+
} as any as MetadataMap); // TODO: Review use of `any` here (#19904)
291+
289292
const caseGetProp = <ClassMetadata>casesMetadata.metadata['GetProp'];
290293
expect(caseGetProp.members).toEqual(propertyData(11));
291294
const caseSetProp = <ClassMetadata>casesMetadata.metadata['SetProp'];
@@ -297,8 +300,7 @@ describe('Collector', () => {
297300
it('should record references to parameterized types', () => {
298301
const casesForIn = <ClassMetadata>casesMetadata.metadata['NgFor'];
299302
expect(casesForIn).toEqual({
300-
__symbolic: 'class',
301-
decorators: [{
303+
__symbolic: 'class', decorators: [{
302304
__symbolic: 'call',
303305
expression: {
304306
__symbolic: 'reference',
@@ -308,17 +310,17 @@ describe('Collector', () => {
308310
character: 7
309311
}
310312
}],
311-
members: {
312-
__ctor__: [{
313-
__symbolic: 'constructor',
314-
parameters: [{
315-
__symbolic: 'reference',
316-
name: 'ClassReference',
317-
arguments: [{__symbolic: 'reference', name: 'NgForRow'}]
318-
}]
319-
}]
320-
}
321-
});
313+
members: {
314+
__ctor__: [{
315+
__symbolic: 'constructor',
316+
parameters: [{
317+
__symbolic: 'reference',
318+
name: 'ClassReference',
319+
arguments: [{__symbolic: 'reference', name: 'NgForRow'}]
320+
}]
321+
}]
322+
}
323+
} as any as ClassMetadata); // TODO: Review use of `any` here (#19904)
322324
});
323325

324326
it('should report errors for destructured imports', () => {
@@ -358,9 +360,9 @@ describe('Collector', () => {
358360
const someClass = <ClassMetadata>metadata.metadata['SomeClass'];
359361
const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0];
360362
const parameters = ctor.parameters;
361-
expect(parameters).toEqual([
362-
{__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29}
363-
]);
363+
expect(parameters).toEqual([{
364+
__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29
365+
} as MetadataSymbolicExpression]);
364366
});
365367

366368
it('should record all exported classes', () => {
@@ -443,9 +445,9 @@ describe('Collector', () => {
443445
const someClass = <ClassMetadata>metadata.metadata['SomeClass'];
444446
const ctor = <ConstructorMetadata>someClass.members !['__ctor__'][0];
445447
const parameters = ctor.parameters;
446-
expect(parameters).toEqual([
447-
{__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29}
448-
]);
448+
expect(parameters).toEqual([{
449+
__symbolic: 'reference', module: 'angular2/common', name: 'NgFor', line: 6, character: 29
450+
} as MetadataSymbolicExpression]);
449451
});
450452

451453
it('should be able to collect the value of an enum', () => {
@@ -533,7 +535,7 @@ describe('Collector', () => {
533535
arguments: ['a']
534536
}
535537
}]
536-
}]);
538+
}] as any as MetadataSymbolicExpression[]); // TODO: Review use of `any` here (#19904)
537539
});
538540

539541
it('should be able to collect a static field', () => {
@@ -576,7 +578,7 @@ describe('Collector', () => {
576578
}
577579
}]
578580
}]
579-
}]);
581+
}] as any as MetadataSymbolicExpression[]); // TODO: Review use of `any` here (#19904)
580582
});
581583

582584
it('should be able to collect a method with a conditional expression', () => {
@@ -764,7 +766,7 @@ describe('Collector', () => {
764766
}]],
765767
parameters: [{__symbolic: 'reference', name: 'any'}]
766768
}]
767-
});
769+
} as any as MetadataMap); // TODO: Review use of `any` here (#19904)
768770
});
769771

770772
describe('with interpolations', () => {
@@ -868,7 +870,7 @@ describe('Collector', () => {
868870
{__symbolic: 'reference', module: './foo', name: 'Foo', line: 3, character: 24}
869871
]
870872
}]
871-
});
873+
} as any as MetadataMap); // TODO: Review use of `any` here (#19904)
872874
});
873875

874876
it('should treat exported class expressions as a class', () => {

packages/compiler-cli/test/ngc_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ describe('ngc transformer command-line', () => {
17471747
const exitCode =
17481748
main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message));
17491749
expect(exitCode).toBe(1, 'Compile was expected to fail');
1750-
expect(messages[0]).toContain(['Tagged template expressions are not supported in metadata']);
1750+
expect(messages[0]).toContain('Tagged template expressions are not supported in metadata');
17511751
});
17521752

17531753
// Regression: #20076

packages/compiler-cli/test/transformers/node_emitter_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,15 +502,15 @@ describe('TypeScriptNodeEmitter', () => {
502502
generatedColumn: 0,
503503
originalLine: 1,
504504
originalColumn: 0,
505-
name: null
505+
name: null ! // TODO: Review use of `!` here (#19904)
506506
},
507507
{
508508
source: sourceUrl,
509509
generatedLine: 3,
510510
generatedColumn: 16,
511511
originalLine: 1,
512512
originalColumn: 26,
513-
name: null
513+
name: null ! // TODO: Review use of `!` here (#19904)
514514
}
515515
]);
516516
});

packages/compiler-cli/test/transformers/program_spec.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ describe('ng program', () => {
373373
{rootNames: [path.resolve(testSupport.basePath, 'src/main.ts')], options, host});
374374
program.loadNgStructureAsync().then(() => {
375375
program.emit();
376-
const factory =
377-
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js'));
376+
const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js');
377+
const factory = fs.readFileSync(ngFactoryPath, 'utf8');
378378
expect(factory).toContain('Hello world!');
379379
done();
380380
});
@@ -677,8 +677,9 @@ describe('ng program', () => {
677677
program.listLazyRoutes();
678678
program.emit();
679679

680-
const lazyNgFactory =
681-
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js'));
680+
const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js');
681+
const lazyNgFactory = fs.readFileSync(ngFactoryPath, 'utf8');
682+
682683
expect(lazyNgFactory).toContain('import * as i1 from "./lazy";');
683684
});
684685

@@ -735,8 +736,10 @@ describe('ng program', () => {
735736
expect(normalizeRoutes(program.listLazyRoutes('src/main#MainModule'))).toEqual([
736737
{
737738
module: {name: 'MainModule', filePath: path.resolve(testSupport.basePath, 'src/main.ts')},
738-
referencedModule:
739-
{name: undefined, filePath: path.resolve(testSupport.basePath, 'src/child.ts')},
739+
referencedModule: {
740+
name: undefined as any as string, // TODO: Review use of `any` here (#19904)
741+
filePath: path.resolve(testSupport.basePath, 'src/child.ts')
742+
},
740743
route: './child'
741744
},
742745
]);

0 commit comments

Comments
 (0)