Skip to content

Automatically exclude outDir from import suggestions in source codeΒ #47184

Closed
@lgarron

Description

@lgarron

Bug Report

πŸ”Ž Search Terms

prevent suggest autocomplete import path out dist build exclude filter only πŸ€·β€β™€οΈ

#35395 is the closest related issue, but it hasn't seen much progress. I'm filing this new issue per:

As a general rule, if auto-imports is doing something that objectively makes no sense, please file a new issue instead of commenting on this one for better visibility. This thread is about excluding things that we really have no way of knowing to exclude without the user telling us explicitly, like #35395 (comment). Thanks!

πŸ•— Version & Regression Information

Has been a bug as long as I can remember. 😒

⏯ Repro

git clone https://github.com/cubing/cubing.js && cd cubing.js
git checkout 0314f2789a796ff57d40b567cc674baf5c1a6cc7
npm install && make build # Populate `dist` dir
code . ./src/sites/experiments.cubing.net/cubing.js/stub/index.ts

Then wait for TS to initialize and type new TwistyPlayer to get an import suggestion.

(I'm sorry, I've had trouble creating a smaller repro. But those shell commands should reliably create a repro state.)

πŸ™ Actual behavior

The top import suggestion is TwistyPlayer from ../../../../../dist/types/twisty, ahead of ../../../../cubing/twisty.

Screen Shot 2021-12-17 at 17 26 07

πŸ™‚ Expected behavior

The top (and only exact string match) import suggestion is for TwistyPlayer from ../../../../cubing/twisty.


The compiler options in tsconfig.json include "outDir": "./dist". I've spent quite some time trying to tweak the outDir, rootDir, include, exclude, fields in package.json, etc. Nothing seems to change the fact that dist is prioritized for the import suggestion. Given that the out dir is the output for my source code, I never want to import it in my source code. I find the current behaviour surprising, and have not been able to work around it after multiple attempts of several hours each. πŸ˜•

Any workarounds or TypeScript features to prevent dist from showing up would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions