Skip to content

Commit cd72993

Browse files
committed
Merge pull request #3094 from Microsoft/getEmitOutputOut
Type check all files when emitting a file under -out
2 parents b6979d8 + 0401553 commit cd72993

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/compiler/program.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ module ts {
219219
// Create the emit resolver outside of the "emitTime" tracking code below. That way
220220
// any cost associated with it (like type checking) are appropriate associated with
221221
// the type-checking counter.
222-
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile);
222+
//
223+
// If the -out option is specified, we should not pass the source file to getEmitResolver.
224+
// This is because in the -out scenario all files need to be emitted, and therefore all
225+
// files need to be type checked. And the way to specify that all files need to be type
226+
// checked is to not pass the file to getEmitResolver.
227+
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile);
223228

224229
let start = new Date().getTime();
225230

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
EmitSkipped: false
2+
FileName : out.js
3+
/// <reference path='my.d.ts' />
4+
var foo;
5+
(function (foo) {
6+
var bar;
7+
(function (bar) {
8+
var baz1 = bar.Baz.prototype; // Should emit as bar.Baz.prototype
9+
})(bar = foo.bar || (foo.bar = {}));
10+
})(foo || (foo = {}));
11+
var x;
12+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @BaselineFile: getEmitOutputOut.baseline
4+
// @out: out.js
5+
6+
// @Filename: my.d.ts
7+
// @emitThisFile: false
8+
////declare module foo.bar {
9+
//// class Baz { }
10+
////}
11+
12+
// @Filename: input0.ts
13+
// @emitThisFile: false
14+
/////// <reference path='my.d.ts' />
15+
////module foo.bar {
16+
//// var baz1 = <any>Baz.prototype; // Should emit as bar.Baz.prototype
17+
////}
18+
19+
// @Filename: input1.ts
20+
// @emitThisFile: true
21+
////var x;
22+
23+
verify.baselineGetEmitOutput();

0 commit comments

Comments
 (0)