Go to Definition for Non JS/TS File Imports
See original GitHub issueFrom 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:
- Created 6 years ago
- Reactions:62
- Comments:33 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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'
inglobal.d.ts
the warning disappears, but then I’m again unable to use go-to-definition.