From 0401553810be4f08d3ea148effc755363f0fff1a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 8 May 2015 13:58:20 -0700 Subject: [PATCH] Type check all files when emitting a file under -out --- src/compiler/program.ts | 7 +++++- .../reference/getEmitOutputOut.baseline | 12 ++++++++++ tests/cases/fourslash/getEmitOutputOut.ts | 23 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/getEmitOutputOut.baseline create mode 100644 tests/cases/fourslash/getEmitOutputOut.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 1e628326ba..3bd4bdc7ac 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -219,7 +219,12 @@ module ts { // Create the emit resolver outside of the "emitTime" tracking code below. That way // any cost associated with it (like type checking) are appropriate associated with // the type-checking counter. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); let start = new Date().getTime(); diff --git a/tests/baselines/reference/getEmitOutputOut.baseline b/tests/baselines/reference/getEmitOutputOut.baseline new file mode 100644 index 0000000000..9508b6d557 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputOut.baseline @@ -0,0 +1,12 @@ +EmitSkipped: false +FileName : out.js +/// +var foo; +(function (foo) { + var bar; + (function (bar) { + var baz1 = bar.Baz.prototype; // Should emit as bar.Baz.prototype + })(bar = foo.bar || (foo.bar = {})); +})(foo || (foo = {})); +var x; + diff --git a/tests/cases/fourslash/getEmitOutputOut.ts b/tests/cases/fourslash/getEmitOutputOut.ts new file mode 100644 index 0000000000..077b257e4d --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputOut.ts @@ -0,0 +1,23 @@ +/// + +// @BaselineFile: getEmitOutputOut.baseline +// @out: out.js + +// @Filename: my.d.ts +// @emitThisFile: false +////declare module foo.bar { +//// class Baz { } +////} + +// @Filename: input0.ts +// @emitThisFile: false +/////// +////module foo.bar { +//// var baz1 = Baz.prototype; // Should emit as bar.Baz.prototype +////} + +// @Filename: input1.ts +// @emitThisFile: true +////var x; + +verify.baselineGetEmitOutput(); \ No newline at end of file