Skip to content

Auto-import suggestions still given for absolute imports without baseUrl #40713

@jakebailey

Description

@jakebailey

TypeScript Version: 4.1.0-dev.20200921

Search Terms:

auto-import paths, auto-import suggestions without baseUrl

Code

Here is a repo with a reproduction. It's a cut down version of a monorepo I redesigned to use paths (then hit the unfortunate auto-import behavior pre-4.1).

https://github.com/jakebailey/ts-41-autoimport-paths

The main file to look at is https://github.com/jakebailey/ts-41-autoimport-paths/blob/master/packages/test-package-1/src/something/index.ts where I've described the different behaviors.

Expected behavior:

When no baseUrl is specified, auto-import suggestions should not be offered for paths like src/foo/bar if they aren't valid. This should work as a result of #40546 and associated changes, and is mentioned in the TS 4.1 beta blog post. In this example, I expect there to be no absolute import because baseUrl is missing, no absolute import via paths as I have not defined one for the current package, leaving me with a relative path suggestion (what I want for consistency with the codebase).

Actual behavior:

These suggestions are still offered. When accepted, TS immediately marks the import as invalid.

image

image

Playground Link:

I'm not sure the playground would allow me to have multiple files, hence the repro repo.

Related Issues:

#31869 is related, but I believe my issue to be a bug in that implementation.

cc @andrewbranch

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions