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.

Don't include full paths in module names in error messages

See original GitHub issue

TypeScript Version: 4.0.5 (also tested with typescript@next)

Search Terms: namespace has no exported member error

Description

Currently certain error messages shows full file paths. For example:

Namespace ‘“y:/projects/opf/portal/OPF.Portal.Web/Content/Scripts/DinSide/App/Store/index”’ has no exported member ‘All’. ts(2694)

Could not find a declaration file for module ‘shortid’. ‘y:/projects/opf/portal/OPF.Portal.Web/node_modules/shortid/index.js’ implicitly has an ‘any’ type. Try npm install @types/shortid if it exists or add a new declaration (.d.ts) file containing declare module 'shortid'; ts(7016)

Our project was started without strict: true (and few @typescript-eslint rules), so the code base includes several thousand errors. To be able to gradually fix them, we have started to use betterer, which includes committing a snapshot of all the current errors. Snapshot is then used to report report when we fix errors, and fail our build if we add new errors. But because of certain Typescript errors using full file paths, we’re getting unnecessary diffs in this snapshot.

Would it be possible to use file paths relative to the project/tsconfig.json root in the error messages instead?

So, with tsconfig.json in y:/projects/opf/portal/OPF.Portal.Web/, the error message would instead be:

Namespace ‘“Content/Scripts/DinSide/App/Store/index”’ has no exported member ‘All’. ts(2694)

An alternative solution could be to change betterer instead, make it auto-replace file paths with relative paths, or something like that. But figured I could at least ask her, especially since it could maybe be an issue for other tools as well.

Related Issues: Couldn’t find any

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
RyanCavanaughcommented, Nov 4, 2020

It’s any time we reference the name of a module, which are internally represented by their full disk path. During error message construction we should convert them back to tsconfig-relative paths

2reactions
RyanCavanaughcommented, Nov 4, 2020

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

python3: Don't show full directory path on error message
I created my own module with your code. So i just need one line to import this module and have no code overhead....
Read more >
Error message when you open or save a file in ...
Cause. This error message occurs when you save or open a file if the path to the file (including the file name) exceeds...
Read more >
os — Miscellaneous operating system interfaces
All functions in this module raise OSError (or subclasses thereof) in the case of invalid or inaccessible file names and paths, or other...
Read more >
Traps for the Unwary in Python's Import System
This has changed in Python 3.3: now any directory on sys.path with a name that ... some existing code would have broken when...
Read more >
JavaScript modules - MDN Web Docs
Fast forward a few years and we now have complete applications ... If you don't, you'll get a strict MIME type checking error...
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