Repository: TypeScript
Issue: resolve declaration extension assets as paths and directing users to the correct implementation
Labels: Suggestion,Awaiting More Feedback

# Suggestion

Resolve string paths with nodeJS for declaration assets. And allow the resolution implementation to be directed to instead of the declaration file.

## 🔍 Search Terms

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

path resolution, custom declarations, assets, svg, png, jpg, webp, wav, mp4 etc.

## ✅ Viability Checklist

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).


## ⭐ Suggestion

<!-- A summary of what you'd like to see added or changed -->

**Add the ability to resolve custom declarations based on path within typescript directly.** 
- This would make it much easier to fix issues with assets that are considered typescript strings.
- Would not require third party plugins such as https://www.npmjs.com/package/eslint-plugin-validate-declared-imports
- It should support tsconfig paths.
- Validation should be done when running `tsc`. It should output an error when a string that is flagged as an asset is not resolvable.

**Add the ability to go directly to the file now that string paths are being resolved as potential files**

**Add the ability to define which asset extensions in declarations are resolvable**
- would allow declarations to be able to say if the declaration is an asset and if it can be resolved.
- Some assets like .mp4 should not be opened in most IDEs. But assets like svgs (and other files) would benefit from having this option.

This would prevent declaration path matching from causing runtime problems due to the assets missing and not being validated with `tsc`.

Related issues on Stack Overflow:
- https://stackoverflow.com/questions/76597629/how-to-write-path-resolutions-for-assets-that-require-declarations-and-open-the
- https://stackoverflow.com/questions/72084536/vscode-svg-declarations-file-resolved-instead-svg-file-path-with-react-native-an

## 📃 Motivating Example

<!--
  If you were announcing this feature in a blog post, what's a short explanation that shows
  a developer why this feature improves the language?
-->

Adding this feature will prevent runtime issues with missing assets due to typos or changes in a codebase. This allows developers to directly import assets that are considered strings in typescript and retain file path validation for those new assets.

Adding this feature will also speed up development process when assets need to be tweaked. Example SVGs can be mutated in the VSCode IDE but clicking on an imported svg will redirect the user to a declaration instead of the asset implementation. Directing the user to the asset implementation would speedup things for everyone.

## 💻 Use Cases

1. Prevent runtime issues related to assets path not matching and/or having typos in a path and typescript ignoring those typos due to the path being considered a pure string.
2. Stabilizes the code even for external solutions that use imports.

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

I want to use this feature for any project that requires a asset to be declared as a string asset in a declaration file and resolve the asset extension using typescript directly instead of third party linting plugins such as eslint.