Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Matter what I do, auto import ONLY suggests dist paths... #39928

Closed
bradennapier opened this issue Jul 22, 2020 · 4 comments
Closed

No Matter what I do, auto import ONLY suggests dist paths... #39928

bradennapier opened this issue Jul 22, 2020 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@bradennapier
Copy link

bradennapier commented Jul 22, 2020

TS Template added by @mjbvz

TypeScript Version: 4.0.0

Search Terms

  • auto import
  • exclude

Version: 1.48.0-insider
Commit: 0a7364f
Date: 2020-07-22T05:43:52.797Z
Electron: 9.1.0
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 20.0.0

Info

This is driving me loony! I can not figure out why this is happening and I have spent at least 6 hours now messing with every single setting I can find or try. I have recently moved to project references, but I do not believe this started until after - I could be wrong? How can I debug where these auto imports are from and why they are resolving here?

  • It only suggests imports in the dist folder, not in the correct place while typing:

image

  • It suggests both the correct path and the incorrect path when checking the auto fix, but it prioritizes the dist path no matter what I do:

image

  • No matter what I do, I can not exclude dist, I have added every form of dist I can think of in the exclude path of the tsconfig.json, tsconfig.eslint.json, tsconfig.base.json, and all others that exist. I can not figure out why it is included.

  • I made absolutely certain nothing ever imports from the dist folder in the src folder

tsconfig.json

{
  "files": [],
  "include": [],
  // added this recently trying to fix this, before the excludes were only at higher level
  "exclude": ["node_modules", "**/node_modules/*", "**/dist/*", "**/dist/**", "./dist"],
  "references": [
    // services
    // includes all to ./src/services/*
  ]
}

src/tsconfig.base.json

{
  // this wasnt here previously but trying to get it to exclude the dist folder
  "exclude": ["node_modules", "dist", "**/dist/*", "**/node_modules", "../dist", "../../dist"],
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "baseUrl": ".",
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "lib": [
      "es2017",
      "es2018",
      "es2019"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "newLine": "lf",
    "noImplicitAny": true,
    "noImplicitThis": true,
    "noEmitOnError": true,
    "preserveConstEnums": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": false,
    "sourceMap": true,
    "target": "es2019",
    "typeRoots": ["../types", "../node_modules/@types"],
    "paths": {
      "core/*": ["./core/*"],
      "services/*": ["./services/*"]
    },
  // tried without this as well
    "plugins": [
      {
        "transform": "@zerollup/ts-transform-paths"
      }
    ]
  },
  
}

src/services/{name}/tsconfig.json

For a service, they extend the base.json

{
  "extends": "../../tsconfig.base.json",
  "include": ["./**/*.ts"],
  // tried with and without this and every variation
  "exclude": ["**/dist/**", "**/dist/*", "dist", "../../../dist/**"],
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "../../../dist/services/{name}"
  },
  "references": [{ "path": "../../core" }]
}

Steps to Reproduce:

My only thought is that it somehow has to do with the fact outDir is set to dist for all of them so it generates all the dist in the dist dir?

Does this issue occur when all extensions are disabled?: Yes

@bradennapier
Copy link
Author

bradennapier commented Jul 22, 2020

Can confirm now, it appears using outDir automatically will auto import from the outDir and ignore the actual settings no matter what you do.

I have created a repro example where this is happening:

https://github.com/bradennapier/typescript-auto-import-bug

I have also tried typescript@beta as FYI

@mjbvz mjbvz transferred this issue from microsoft/vscode Aug 5, 2020
@bodinsamuel
Copy link

Same issue here, it makes references build a bit painful.

@andrewbranch
Copy link
Member

Duplicate of #38856, although this is a better repro. Thanks for the example repo; that’s always helpful.

@andrewbranch andrewbranch added the Duplicate An existing issue was already created label Aug 12, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants