Skip to content

Differentiate "." from "./" in module resolution #9690

Closed
@ghost

Description

In my sample node.js project:

a.js:

module.exports = "a.js";

a/index.js:

module.exports = "a/index.js"

We will load a different one of these modules depending on whether the imported module ends in a /.

For example:

a/test.js:

console.log([require("."), require("./")]);

Prints: [ 'a.js', 'a/index.js' ]

Also, if we have:

a/b/test2.js:

console.log([require(".."), require("../")]);

We get: [ 'a.js', 'a/index.js' ]

TypeScript's node.js module resolution should reflect this behavior, but currently does not.
See tests\cases\compiler\relativeModuleWithoutSlash.ts.

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