Add test when require is just a function in external module

This commit is contained in:
Sheetal Nandi
2016-10-04 12:08:58 -07:00
parent e38f8c9c31
commit a70624d415
3 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
tests/cases/compiler/m2.ts(1,10): error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'.
==== tests/cases/compiler/c.js (0 errors) ====
export default function require(a) { }
export function has(a) { return true }
==== tests/cases/compiler/m.js (0 errors) ====
import require, { has } from "./c"
export function hello() { }
if (has('ember-debug')) {
require('ember-debug');
}
==== tests/cases/compiler/m2.ts (1 errors) ====
import { hello } from "./m";
~~~~~
!!! error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'.
hello();

View File

@@ -0,0 +1,37 @@
//// [tests/cases/compiler/requireAsFunctionInExternalModule.ts] ////
//// [c.js]
export default function require(a) { }
export function has(a) { return true }
//// [m.js]
import require, { has } from "./c"
export function hello() { }
if (has('ember-debug')) {
require('ember-debug');
}
//// [m2.ts]
import { hello } from "./m";
hello();
//// [c.js]
"use strict";
function require(a) { }
exports.__esModule = true;
exports["default"] = require;
function has(a) { return true; }
exports.has = has;
//// [m.js]
"use strict";
var c_1 = require("./c");
function hello() { }
exports.hello = hello;
if (c_1.has('ember-debug')) {
c_1["default"]('ember-debug');
}
//// [m2.js]
"use strict";
var m_1 = require("./m");
m_1.hello();

View File

@@ -0,0 +1,16 @@
// @allowjs: true
// @outDir: dist
// @Filename: c.js
export default function require(a) { }
export function has(a) { return true }
// @Filename: m.js
import require, { has } from "./c"
export function hello() { }
if (has('ember-debug')) {
require('ember-debug');
}
// @Filename: m2.ts
import { hello } from "./m";
hello();