Skip to content

Incorrect behavior for moduleResolution classic with relative paths #7051

@use-strict

Description

@use-strict

When using "moduleResolution" set to "classic", relative paths appear to be resolved in the same way as module paths, by looking at the parent folder. This behavior is incorrect and generates invalid paths.

Example:

// <root>/A.ts
export default class A {
    test() { console.log("hello world"); }
}
// <root>/some/B.ts
import A from "./A"; // <- this should error

let x = new B();
x.test();

This example should not compile. Tested with:
tsc 1.5.3 => doesn't compile (as expected)
tsc 1.6.2, 1.7.5 (moduleResolution = classic) => compiles
tsc 1.6.2, 1.7.5 (moduleResolution = node) => doesn't compile (as expected)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions