You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tsc complains require() file path outside of rootDir only when await import() is used #38611
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
declare const require: any;
// Bug occurs when an import() is in the file
const a: typeof import('./other') = null as any
function foo() {
const a = require('../outside-of-rootdir/foo'); // Semantic error: File ... is not under 'rootDir' ...
const {other}: {other: string} = require('./other'); // No error here, even though is semantically invalid, because `other` is of type `number`.
// It appears as though the resolver is trying to locate the targets of require() calls, but the typechecker does not care.
}
Activity
cspotcode commentedon May 17, 2020
I am seeing this bug triggered by a slightly different reason: adding an
import()type annotation.I have created a minimal reproduction here: https://github.com/TypeStrong/ts-node-repros/tree/ts-38611
It executed here: https://github.com/TypeStrong/ts-node-repros/runs/682702614
sheetalkamat commentedon Jul 15, 2020
ychi your repro link seems to be not working, Can you please share the repro again. Thanks
sheetalkamat commentedon Jul 15, 2020
Actually Andrew Bradley (@cspotcode) repro seems to be working.. Thanks.
Do not resolve require calls in typescript files even if it contains …
Do not resolve require calls in typescript files even if it contains …