Skip to content

Unable to resolve path when import uses path relative to baseUrl #68

Closed
@OliverJAsh

Description

@OliverJAsh

This is a difficult one to describe but here is a failing test: OliverJAsh@e26fed2

Essentially the issue occurs when we import using a path that is relative to the baseUrl, e.g. given:

tests/withPaths2/tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "root/",
    "paths": {
      "other/*": ["../other/*"]
    }
  },
  "files": ["root/foo.ts", "other/bar.ts"]
}

tests/withPaths2/root/foo.ts:

// import using tsconfig.json path mapping
import 'other/bar'

tests/withPaths2/other/bar.ts:

// import using tsconfig.json `baseUrl`
// This one fails ❌
import 'foo'

This fails with the following error:

/Users/oliverash/Development/eslint-import-resolver-typescript/tests/withPaths2/other/bar.ts
  2:8  error  Unable to resolve path to module 'foo'  import/no-unresolved

This is a valid import—TypeScript understands it so I think this resolver should also understand it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions