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

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

View File

@ -21,7 +21,7 @@
import * as ts from 'typescript';
import {CompilerHost, CompilerOptions, LazyRoute} from './transformers/api';
import {CompilerOptions} from './transformers/api';
import {getOriginalReferences} from './transformers/compiler_host';
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);
if (info) {
const diagnostics = getTemplateExpressionDiagnostics(info);
@ -240,4 +240,4 @@ const FILES: Directory = {
`
}
}
};
};

View File

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

View File

@ -1747,7 +1747,7 @@ describe('ngc transformer command-line', () => {
const exitCode =
main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message));
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

View File

@ -502,7 +502,7 @@ describe('TypeScriptNodeEmitter', () => {
generatedColumn: 0,
originalLine: 1,
originalColumn: 0,
name: null
name: null ! // TODO: Review use of `!` here (#19904)
},
{
source: sourceUrl,
@ -510,7 +510,7 @@ describe('TypeScriptNodeEmitter', () => {
generatedColumn: 16,
originalLine: 1,
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});
program.loadNgStructureAsync().then(() => {
program.emit();
const factory =
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js'));
const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/main.ngfactory.js');
const factory = fs.readFileSync(ngFactoryPath, 'utf8');
expect(factory).toContain('Hello world!');
done();
});
@ -677,8 +677,9 @@ describe('ng program', () => {
program.listLazyRoutes();
program.emit();
const lazyNgFactory =
fs.readFileSync(path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js'));
const ngFactoryPath = path.resolve(testSupport.basePath, 'built/src/lazy/lazy.ngfactory.js');
const lazyNgFactory = fs.readFileSync(ngFactoryPath, 'utf8');
expect(lazyNgFactory).toContain('import * as i1 from "./lazy";');
});
@ -735,8 +736,10 @@ describe('ng program', () => {
expect(normalizeRoutes(program.listLazyRoutes('src/main#MainModule'))).toEqual([
{
module: {name: 'MainModule', filePath: path.resolve(testSupport.basePath, 'src/main.ts')},
referencedModule:
{name: undefined, filePath: path.resolve(testSupport.basePath, 'src/child.ts')},
referencedModule: {
name: undefined as any as string, // TODO: Review use of `any` here (#19904)
filePath: path.resolve(testSupport.basePath, 'src/child.ts')
},
route: './child'
},
]);