
committed by
Igor Minar

parent
83c1383701
commit
83d207d0a7
@ -84,7 +84,7 @@ describe('ng type checker', () => {
|
||||
});
|
||||
|
||||
describe('type narrowing', () => {
|
||||
const a = (files: MockFiles, options: object = {}) => {
|
||||
const a = (files: MockFiles, options: ng.AngularCompilerOptions = {}) => {
|
||||
accept(files, {fullTemplateTypeCheck: true, ...options});
|
||||
};
|
||||
|
||||
@ -517,7 +517,7 @@ describe('ng type checker', () => {
|
||||
});
|
||||
|
||||
describe('casting $any', () => {
|
||||
const a = (files: MockFiles, options: object = {}) => {
|
||||
const a = (files: MockFiles, options: ng.AngularCompilerOptions = {}) => {
|
||||
accept(
|
||||
{'src/app.component.ts': '', 'src/lib.ts': '', ...files},
|
||||
{fullTemplateTypeCheck: true, ...options});
|
||||
@ -525,7 +525,7 @@ describe('ng type checker', () => {
|
||||
|
||||
const r =
|
||||
(message: string | RegExp, location: RegExp | null, files: MockFiles,
|
||||
options: object = {}) => {
|
||||
options: ng.AngularCompilerOptions = {}) => {
|
||||
reject(
|
||||
message, location, {'src/app.component.ts': '', 'src/lib.ts': '', ...files},
|
||||
{fullTemplateTypeCheck: true, ...options});
|
||||
@ -621,7 +621,7 @@ describe('ng type checker', () => {
|
||||
});
|
||||
|
||||
describe('regressions ', () => {
|
||||
const a = (files: MockFiles, options: object = {}) => {
|
||||
const a = (files: MockFiles, options: ng.AngularCompilerOptions = {}) => {
|
||||
accept(files, {fullTemplateTypeCheck: true, ...options});
|
||||
};
|
||||
|
||||
|
@ -22,38 +22,21 @@ describe('Collector', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
host = new Host(FILES, [
|
||||
'/app/app.component.ts',
|
||||
'/app/cases-data.ts',
|
||||
'/app/error-cases.ts',
|
||||
'/promise.ts',
|
||||
'/unsupported-1.ts',
|
||||
'/unsupported-2.ts',
|
||||
'/unsupported-3.ts',
|
||||
'class-arity.ts',
|
||||
'declarations.d.ts',
|
||||
'import-star.ts',
|
||||
'exported-classes.ts',
|
||||
'exported-functions.ts',
|
||||
'exported-enum.ts',
|
||||
'exported-type.ts',
|
||||
'exported-consts.ts',
|
||||
'local-symbol-ref.ts',
|
||||
'local-function-ref.ts',
|
||||
'local-symbol-ref-func.ts',
|
||||
'local-symbol-ref-func-dynamic.ts',
|
||||
'private-enum.ts',
|
||||
're-exports.ts',
|
||||
're-exports-2.ts',
|
||||
'export-as.d.ts',
|
||||
'named-module.d.ts',
|
||||
'static-field-reference.ts',
|
||||
'static-method.ts',
|
||||
'static-method-call.ts',
|
||||
'static-method-with-if.ts',
|
||||
'static-method-with-default.ts',
|
||||
'class-inheritance.ts',
|
||||
'class-inheritance-parent.ts',
|
||||
'class-inheritance-declarations.d.ts',
|
||||
'/app/app.component.ts', '/app/cases-data.ts',
|
||||
'/app/error-cases.ts', '/promise.ts',
|
||||
'/unsupported-1.ts', '/unsupported-2.ts',
|
||||
'/unsupported-3.ts', 'class-arity.ts',
|
||||
'declarations.d.ts', 'import-star.ts',
|
||||
'exported-classes.ts', 'exported-functions.ts',
|
||||
'exported-enum.ts', 'exported-type.ts',
|
||||
'exported-consts.ts', 'local-symbol-ref.ts',
|
||||
'local-function-ref.ts', 'local-symbol-ref-func.ts',
|
||||
'private-enum.ts', 're-exports.ts',
|
||||
're-exports-2.ts', 'export-as.d.ts',
|
||||
'named-module.d.ts', 'static-field-reference.ts',
|
||||
'static-method.ts', 'static-method-call.ts',
|
||||
'static-method-with-if.ts', 'static-method-with-default.ts',
|
||||
'class-inheritance.ts', 'class-inheritance-parent.ts',
|
||||
'interface-reference.ts'
|
||||
]);
|
||||
service = ts.createLanguageService(host, documentRegistry);
|
||||
|
@ -91,7 +91,8 @@ describe('Symbols', () => {
|
||||
});
|
||||
|
||||
it('should be able to resolve any symbol in core global scope', () => {
|
||||
const core = program.getSourceFiles().find(source => source.fileName.endsWith('lib.d.ts'));
|
||||
const core = (program.getSourceFiles() as ts.SourceFile[])
|
||||
.find(source => source.fileName.endsWith('lib.d.ts'));
|
||||
expect(core).toBeDefined();
|
||||
const visit = (node: ts.Node): boolean => {
|
||||
switch (node.kind) {
|
||||
|
@ -161,6 +161,9 @@ export function expectNoDiagnostics(diagnostics: ts.Diagnostic[]) {
|
||||
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
} else {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
expect(diagnostics.length).toBe(0);
|
||||
|
@ -684,7 +684,7 @@ describe('ngc transformer command-line', () => {
|
||||
expect(exitCode).toEqual(0);
|
||||
const mymodulejs = path.resolve(outDir, 'mymodule.js');
|
||||
const mymoduleSource = fs.readFileSync(mymodulejs, 'utf8');
|
||||
expect(mymoduleSource).toContain(`import { A } from "submodule"`);
|
||||
expect(mymoduleSource).toContain(`import { A } from 'submodule'`);
|
||||
});
|
||||
|
||||
describe('expression lowering', () => {
|
||||
|
@ -166,10 +166,10 @@ class MockWatchHost {
|
||||
nextTimeoutListenerId = 1;
|
||||
timeoutListeners: {[id: string]: (() => void)} = {};
|
||||
fileChangeListeners: Array<((event: FileChangeEvent, fileName: string) => void)|null> = [];
|
||||
diagnostics: ng.Diagnostics = [];
|
||||
diagnostics: ng.Diagnostic[] = [];
|
||||
constructor(public config: ng.ParsedConfiguration) {}
|
||||
|
||||
reportDiagnostics(diags: ng.Diagnostics) { this.diagnostics.push(...diags); }
|
||||
reportDiagnostics(diags: ng.Diagnostics) { this.diagnostics.push(...(diags as ng.Diagnostic[])); }
|
||||
readConfiguration() { return this.config; }
|
||||
createCompilerHost(options: ng.CompilerOptions) { return ng.createCompilerHost({options}); }
|
||||
createEmitCallback() { return undefined; }
|
||||
|
@ -431,14 +431,15 @@ describe('ng program', () => {
|
||||
});
|
||||
const host = ng.createCompilerHost({options});
|
||||
const written = new Map < string, {
|
||||
original: ts.SourceFile[]|undefined;
|
||||
original: ReadonlyArray<ts.SourceFile>|undefined;
|
||||
data: string;
|
||||
}
|
||||
> ();
|
||||
|
||||
host.writeFile =
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean,
|
||||
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]) => {
|
||||
onError: (message: string) => void|undefined,
|
||||
sourceFiles: ReadonlyArray<ts.SourceFile>) => {
|
||||
written.set(fileName, {original: sourceFiles, data});
|
||||
};
|
||||
const program = ng.createProgram(
|
||||
@ -510,9 +511,9 @@ describe('ng program', () => {
|
||||
const host = ng.createCompilerHost({options});
|
||||
const writtenFileNames: string[] = [];
|
||||
const oldWriteFile = host.writeFile;
|
||||
host.writeFile = (fileName, data, writeByteOrderMark) => {
|
||||
host.writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
||||
writtenFileNames.push(fileName);
|
||||
oldWriteFile(fileName, data, writeByteOrderMark);
|
||||
oldWriteFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
||||
};
|
||||
|
||||
compile(/*oldProgram*/ undefined, options, /*rootNames*/ undefined, host);
|
||||
|
Reference in New Issue
Block a user