Merge pull request #8223 from Microsoft/typeReferenceDirectives

[Transforms] Fix type reference directive tests by adding --module amd
This commit is contained in:
Sheetal Nandi 2016-04-20 16:17:09 -07:00
commit 3667b300ec
10 changed files with 50 additions and 9 deletions

View File

@ -2076,7 +2076,10 @@ namespace ts {
}
// Cannot specify module gen that isn't amd or system with --out
if (outFile && options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
// Report this error if user specified --module moduleKind
// or if there is external module in compilation which defaults to commonjs
const emitModuleKind = getEmitModuleKind(options);
if (outFile && (options.module || firstExternalModuleSourceFile) && !(emitModuleKind === ModuleKind.AMD || emitModuleKind === ModuleKind.System)) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
}

View File

@ -1,8 +1,10 @@
error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided.
!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
==== tests/cases/compiler/file1.ts (0 errors) ====
export var x;

View File

@ -0,0 +1,7 @@
error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
==== tests/cases/compiler/optionsOutAndNoModuleGen.ts (0 errors) ====
export var x = 10;

View File

@ -15,6 +15,15 @@ import {foo} from "./mod1";
export const bar = foo();
//// [output.js]
define("mod1", ["require", "exports"], function (require, exports) {
"use strict";
function foo() { return { x: 1 }; }
exports.foo = foo;
});
define("mod2", ["require", "exports", "mod1"], function (require, exports, mod1_1) {
"use strict";
exports.bar = mod1_1.foo();
});
//// [output.d.ts]

View File

@ -5,8 +5,7 @@
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"Module resolution kind is not specified, using 'Classic'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========"
]

View File

@ -34,7 +34,26 @@ export const foo = new Cls().foo();
export const bar = Cls.bar();
//// [output.js]
define("main", ["require", "exports"], function (require, exports) {
"use strict";
var Cls = (function () {
function Cls() {
}
return Cls;
}());
exports.Cls = Cls;
});
/// <reference types="lib" />
define("mod1", ["require", "exports", "main"], function (require, exports, main_1) {
"use strict";
main_1.Cls.prototype.foo = function () { return undefined; };
});
define("mod2", ["require", "exports", "main", "mod1"], function (require, exports, main_2) {
"use strict";
exports.cls = main_2.Cls;
exports.foo = new main_2.Cls().foo();
exports.bar = main_2.Cls.bar();
});
//// [output.d.ts]

View File

@ -1,12 +1,10 @@
[
"======== Resolving module './main' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"Module resolution kind is not specified, using 'Classic'.",
"File '/main.ts' exist - use it as a name resolution result.",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"Module resolution kind is not specified, using 'Classic'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/'. ========",
@ -15,8 +13,7 @@
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving module './main' from '/mod1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"Module resolution kind is not specified, using 'Classic'.",
"File '/main.ts' exist - use it as a name resolution result.",
"======== Module name './main' was successfully resolved to '/main.ts'. ========"
]

View File

@ -0,0 +1,3 @@
// @out: output.js
export var x = 10;

View File

@ -4,6 +4,7 @@
// @traceResolution: true
// @types: lib
// @out: output.js
// @module: amd
// @filename: /types/lib/index.d.ts

View File

@ -3,6 +3,7 @@
// @typesRoot: /
// @traceResolution: true
// @out: output.js
// @module: amd
// @filename: /types/lib/index.d.ts