ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.76k stars 69 forks source link

VSCode resolution failing for "excluded" files #58

Closed jplew closed 5 years ago

jplew commented 5 years ago

Hi: VS Code path resolution and auto-completion work great with all my project files that have been explicitly "included", but fail for any files that have been excluded.

The relevant bits of my tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "~/*": ["./*"]
    }
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "src/__test__/**/*"
  ]
}

In my case, I want path aliasing functionality in my test files, but I don't want my tests transpiled and output to my outDir.

Is it possible to take advantage of module aliases in a file, while simultaneously excluding it from transpilation?

Screenshot for reference:

image

Kehrlann commented 5 years ago

Hi @jplew,

If I understand correctly, you're using only the typescript compiler for path aliasing as of today. So you are not using module-alias yet, correct ? If I understand correctly so far: as your typescript config does not work with excluded file, you would like to use module-alias instead, to have path resolution working. That might not be the best thing, please check the discussion on #19

Let me know if it helps.

jplew commented 5 years ago

@Kehrlann thanks for the reply, and sorry if I was unclear. I already have module-alias installed and running in the above example.

The library works fine for all the files in my src directory, but VS Code fails to autocomplete or recognize the aliases in my src/__test__ directory.

I did read the thread you linked to. I'm not having the same problem as the OP, as VS Code plays nicely with module-alias, but only for the files specified in my include glob pattern.

Just wondering if it's possible for aliases to resolve in a file which is intentionally excluded from the compiler.

Kehrlann commented 5 years ago

I see you've found an answer in #19 :+1: It's not something we plan to address anytime soon - I'll close this issue.