Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit b2407a6

Browse files
committed
stop typechecking tsickle output
Summary: We need to be able to generate invalid TypeScript. Drop typechecking of tsickle output from the test suite. Note that we still Closure-compile the tsickle output so the output is still checked; it's just that sometimes we're gonna want to do things that TypeScript disallows, like reach past a "private" modifier, to make Closure work. See issue #189. Reviewers: rkirov Reviewed By: rkirov Subscribers: typescript-eng Differential Revision: https://reviews.angular.io/D214
1 parent 34ecdf7 commit b2407a6

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

test/test_support.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as tsickle from '../src/tsickle';
1010
const compilerOptions: ts.CompilerOptions = {
1111
target: ts.ScriptTarget.ES6,
1212
skipDefaultLibCheck: true,
13-
noEmitOnError: true,
1413
experimentalDecorators: true,
1514
emitDecoratorMetadata: true,
1615
noEmitHelpers: true,
@@ -28,7 +27,7 @@ const {cachedLibPath, cachedLib} = (function() {
2827
return {cachedLibPath: p, cachedLib: host.getSourceFile(fn, ts.ScriptTarget.ES6)};
2928
})();
3029

31-
/** Creates a ts.Program from a set of input files. Throws an exception on errors. */
30+
/** Creates a ts.Program from a set of input files. */
3231
export function createProgram(sources: {[fileName: string]: string}): ts.Program {
3332
let host = ts.createCompilerHost(compilerOptions);
3433

@@ -53,23 +52,17 @@ export function createProgram(sources: {[fileName: string]: string}): ts.Program
5352
throw new Error('unexpected file read of ' + fileName + ' not in ' + Object.keys(sources));
5453
};
5554

56-
let program = ts.createProgram(Object.keys(sources), compilerOptions, host);
57-
let diagnostics = ts.getPreEmitDiagnostics(program);
58-
if (diagnostics.length) {
59-
throw new Error(tsickle.formatDiagnostics(diagnostics));
60-
}
61-
62-
return program;
55+
return ts.createProgram(Object.keys(sources), compilerOptions, host);
6356
}
6457

6558
/** Emits transpiled output with tsickle postprocessing. Throws an exception on errors. */
66-
export function emit(program: ts.Program): {[fileName: string]: string} {
59+
export function emit(program: ts.Program, checkErrors = true): {[fileName: string]: string} {
6760
let transformed: {[fileName: string]: string} = {};
6861
let emitRes = program.emit(undefined, (fileName: string, data: string) => {
6962
transformed[fileName] =
7063
tsickle.convertCommonJsToGoogModule(fileName, data, cliSupport.pathToModuleName).output;
7164
});
72-
if (emitRes.diagnostics.length) {
65+
if (checkErrors && emitRes.diagnostics.length) {
7366
throw new Error(tsickle.formatDiagnostics(emitRes.diagnostics));
7467
}
7568
return transformed;

test/tsickle_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('golden tests', () => {
138138
// Run tsickled TypeScript through TypeScript compiler
139139
// and compare against goldens.
140140
program = testSupport.createProgram(tsickleSources);
141-
let jsSources = testSupport.emit(program);
141+
let jsSources = testSupport.emit(program, /* ignore errors */ false);
142142
for (let jsPath of Object.keys(jsSources)) {
143143
compareAgainstGolden(jsSources[jsPath], jsPath);
144144
}

0 commit comments

Comments
 (0)