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.

Go to Definition for Non JS/TS File Imports

See original GitHub issue

From https://github.com/Microsoft/vscode/issues/24276

Issue Users of tools such as webpack often load non js/ts assets, such as css or images, using require or import:

require('./main.css');
import './image.png'
...

Operations such as go to definition currently do not work on these paths

Proposal go to definition on these resource paths should try to open the corresponding resource in the editor.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:62
  • Comments:33 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
jpike88commented, Apr 19, 2018

Additionally TypeScript should be checking the path of EVERY import that occurs (module or otherwise) and raise an appropriate error. A hacky workaround silences an error that an html file isn’t a module, but an incorrect relative path doesn’t re-flag an error. So I’m stuck guessing that my import paths are hopefully correct.

https://github.com/Microsoft/vscode/issues/48025#issuecomment-382623046

I don’t get the argument regarding strict ES6 spec compliance. This is something webpack, fusebox and pretty much every bundler out there allows and encourages. I’d imagine this has plenty of devs out there using it. Widespread real-world use cases matter, so the meaning of what is and isn’t ‘compliant’ needs to be re-evaluated in this case.

Besides if this needs to be supported by the core, and maybe just have an appropriate .tsconfig flag turned off by default, why not just do it?

5reactions
chkpntcommented, Sep 16, 2021

Yes, go to definition works. But how can I get rid of the warning “Cannot find module ‘…/img/bla.png’ or its corresponding type declarations.ts(2307)” while preserving this feature?

If I declare module '*.png' in global.d.ts the warning disappears, but then I’m again unable to use go-to-definition.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vscode "Intellisense" and "Go to definition" for not js/ts files
We import such files using both aliases an relative paths. Example: import brandsQuery from '~/graphql/queries/brands.gql'; import ...
Read more >
Enabling VSCode's "Go to Definition" for JSX imports
This lets you hover over any variable/class/object/etc and be taken to the place where it is defined, even if it's in another file....
Read more >
ATA Carnet Frequently Asked Question (FAQ's)
Why use an ATA Carnet? · Why not use Temporary Importation under Bond? · What are the Importer's obligations? · Who issues ATA...
Read more >
The Effect of Imports of Steel on the National Security
January to October, import levels for 2017 are projected to reach 36.0 ... While Section 232 does not contain a definition of “national ......
Read more >
Description of the cmsRun Python Configuration Syntax
Here is an illustration of the structure of a configuration file: # Import CMS python class definitions such as Process, Source, ...
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