question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript - TSConfig path is not taken into account

See original GitHub issue

Feature Request

Expected Behavior

I want to create the dependency graph of my project.

My project structure is like this: src/

  • main.ts
    • core/
      • magicalFile.ts

I am using in the “paths” option the TSConfig.json to create shortcuts for my imports.

relevant parts of tsconfig.json:

{
  ...
    "baseUrl": "src",
    "paths": {
      "@core/*": ["core/*"],
    }
...
}

in my main file “main.ts” i am importing other files with the shortcut. import { MagicalClass } from '@core/magicalFile'

Now i try to create a dependency table. dependency-cruiser -v -T html -f dependencyGraph.html ./src/main.ts

I would expect, that dependency-cruiser will take those settings in the tsconfig.json into account and follow the import shortcuts.

Current Behavior

Dependency-cruiser does not take the tsconfig settings into account and try´s to find @core/magicalFile.ts in the directory @core. Which does not exist. As a result the dependency graph ends at main.ts and only shows some not resolvable imports.

Possible Solution

It would be nice if, for typescript files, the path option in the tsconfig.json would be taken into account.

Context

For projects wit a certain size, the path-option helps to reduce the length of import statements and to make them more readable.

Your Environment

  • Version used: 4.3.2
  • Node version: 8
  • Operating System and version: Windows 10

Thank you in advance and warm regards

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Bisdowcommented, Aug 13, 2018

Works like a charm.

1reaction
sverweijcommented, Aug 12, 2018

Version 4.4.0, which contains the merged PR’s now is on npm. I assume this closes the issue - let me know if you think otherwise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are these tsconfig paths not working? - Stack Overflow
In case anyone is using VSCode and having trouble getting the /* solution to work. Try Cmd+Shift+P > Typescript: Restart TS Server. –...
Read more >
paths - TSConfig Option - TypeScript
TypeScript in 5 minutes. An overview of building a TypeScript web app. TSConfig Options. All the configuration options for a project.
Read more >
Typescript — How to solve the problem with unresolved path ...
Generally, what should be done can be summarized as follows: Take a look into tsconfig.json and check if there are path aliases defined...
Read more >
Tsconfig paths cannot find module
Luckily, TypeScript provides us with a paths-option in the tsconfig. vue'. ... are not taking any effect in the ionic app (but are...
Read more >
Typescript: "paths" tsconfig - YouTube
typescript #tscHere's a thing that might help you with staying focused on features by setting a permanent "components" path in your tsconfig ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found