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

TypeScript - tsconfig.json paths resolve wildcards #12563

Closed
beckend opened this issue Sep 24, 2016 · 9 comments
Closed

TypeScript - tsconfig.json paths resolve wildcards #12563

beckend opened this issue Sep 24, 2016 · 9 comments
Assignees
Labels
typescript Typescript support issues

Comments

@beckend
Copy link

beckend commented Sep 24, 2016

  • VSCode Version: 1.5.3
  • OS Version: OSX El Capitan 10.11.6

Steps to Reproduce:

  1. tsconfig.json
{
  "compilerOptions": {
    "strictNullChecks": false,
    "noEmitHelpers": true,
    "listFiles": true,
    "target": "es2015",
    "outDir": "./tmp",
    "module": "commonjs",
    "moduleResolution": "node",
    "pretty": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "removeComments": false,
    "jsx": "react",
    "baseUrl": ".",
    "paths": {
      "*": [
        "app/*"
      ]
    }
  },
  "files": [],
  "include": [
    "custom-typings/index.d.ts",
    "app/**/*.{ts,tsx}",
    "shared/**/*.{ts,tsx}",
    "test/**/*.{ts,tsx}"
  ],
  "exclude": [],
  "filesGlob": [
    "custom-typings/index.d.ts",
    "node_modules/@types/**/*.d.ts",
    "app/**/*.{ts,tsx}",
    "shared/**/*.{ts,tsx}",
    "test/**/*.{ts,tsx}"
  ],
  "awesomeTypescriptLoaderOptions": {
    "resolveGlobs": true,
    "forkChecker":  true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}
  1. Does not resolve:
    screen shot 2016-09-24 at 23 28 01

A sidenote: it does not seem to include custom-typings/index.d.ts which will declare the webpack require correctly either...

I'm using this tsconfig in atom editor and everything works fine.

@beckend beckend changed the title tsconfig.json paths resolve wildcards TypeScript - tsconfig.json paths resolve wildcards Sep 24, 2016
@beckend
Copy link
Author

beckend commented Sep 26, 2016

Ran tsc with --traceResolution and it seems like it does not respect paths at all.

"paths": {
      "*": [
        "app/*"
      ]
    }

Always trying to resolve with "node_modules" in prefix and ultimately will fail.
Then maybe this issue is better suited in typescript issue tracker, if it's not intended behaviour.

@beckend
Copy link
Author

beckend commented Sep 26, 2016

Another debug phase, stumbled upon #10321.
So in order for this to work at the moment, I had to remove all 3 properties from compilerOptions, 1 or two did not cut it.
These are:
files, include, exclude

@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug typescript Typescript support issues labels Sep 26, 2016
@waderyan
Copy link

@beckend thank you for opening this issue and for helping us identify the crux of the issue so we can fix it.

  1. Can you provide me with code I can copy and paste or clone on my own machine? The smaller and simpler the code example the better for isolating the issue.
  2. Can you reduce what you have in tsconfig.json to get to the smallest configuration that reproduces the issue?

@waderyan waderyan added the info-needed Issue requires more information from poster label Sep 26, 2016
@beckend
Copy link
Author

beckend commented Sep 27, 2016

Here is the minimal repo.
For vscode the culprits props are include and files, I have no idea what logic hierarchy applies and would love to know their priorities where they apply.

VSCODE:

  • tsconfig.json is the only working one
  • the rest of tsconfigs will all fail.

TSC:
tsc app/index.ts --outDir ./trace --traceResolution > ./trace/tsconfig.txt

  • None of the configs was able to resolve

@waderyan waderyan removed the info-needed Issue requires more information from poster label Sep 27, 2016
@waderyan
Copy link

Hmm... seems to be working in the latest bits (VS Code Insiders 1.6).

  1. I cloned the repo
  2. I opened index.ts and expected to see errors highlighted for the modules as you indicated in your screenshot. Instead I see:

image

I can also cmd+click into the module and am navigated to the correct location.

@waderyan waderyan added the info-needed Issue requires more information from poster label Sep 27, 2016
@beckend
Copy link
Author

beckend commented Sep 28, 2016

There are several tsconfig.json(s).
The default one is demonstrating a working one. Simply use any other ones included in the repo by renaming them. You might need to restart vscode to use a new tsconfig but I'm not sure since I always restart.

@waderyan waderyan removed the info-needed Issue requires more information from poster label Sep 28, 2016
@waderyan
Copy link

This seems to be the intended behavior. If includes or files is empty than the TypeScript project is empty. tsconfig.json is indicating that the files in the workspace are not part of the TypeScript project and so they should not be included in the TS language service's code navigation, linting, intellisense, etc.

@mhegazy can you correct me if I am misunderstanding? OP has a minimal repo you can pull down and test really simply here

@waderyan waderyan added the info-needed Issue requires more information from poster label Sep 28, 2016
@mhegazy
Copy link

mhegazy commented Sep 28, 2016

You are correct @waderyan. an tsconfig.json with empty files or empty include loads no files. a quick way to diagnose that is using tsc --listFiles. so:

c:\test\12563\typescript-tsconfig-paths-issue>tsc --listFiles --p tsconfig-include.json
C:/Users/mhegazy/AppData/Roaming/npm/node_modules/typescript/lib/lib.d.ts

c:\test\12563\typescript-tsconfig-paths-issue>tsc --listFiles --p tsconfig-files.json
C:/Users/mhegazy/AppData/Roaming/npm/node_modules/typescript/lib/lib.d.ts

@beckend
Copy link
Author

beckend commented Sep 29, 2016

Then we are done here, thanks for the clarifications.

@beckend beckend closed this as completed Sep 29, 2016
@ramya-rao-a ramya-rao-a removed bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster labels Sep 29, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

5 participants