-
Notifications
You must be signed in to change notification settings - Fork 13.3k
tsc complains require() file path outside of rootDir only when await import() is used #38611
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 4.0.0-dev.20200516
Search Terms: commonjs, esmodule, rootDir
Code
Consider this file:
onst {version: VERSION} = require('../package.json');
console.log(VERSION);
async function foo() {
let obj = {};
console.log(obj);
}
export async function bar() {
console.log('foo');
await foo();
}And this file:
const {version: VERSION} = require('../package.json');
console.log(VERSION);
async function foo() {
let obj = await import('./anotherFile');
console.log(obj);
}
export async function bar() {
console.log('foo');
await foo();
}Expected behavior:
Running tsc to compile them, they should both succeed or both fail?
Actual behavior:
The first file can be compiled smoothly, while the second was complained about error TS6059 and error TS6307.
Playground Link: https://glitch.com/~aromatic-bittersweet-biplane
Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue