mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:55:10 -05:00
Add test when require is just a function in external module
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
16
tests/cases/compiler/requireAsFunctionInExternalModule.ts
Normal file
16
tests/cases/compiler/requireAsFunctionInExternalModule.ts
Normal 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();
|
||||
Reference in New Issue
Block a user