-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms
resolveJsonModule import definition
Suggestion
As a .json file is a static resource, it should be able to be referenced in a global.d.ts file for example without that file being automatically treated as a module. The reason for this is that a .json file may be used to simply enforce valid translation keys, and you shouldn't need to suck the whole .json file into the transpilation process to do that.
Use Cases
Example:
import translations from "../assets/translations/en-AU.json"
type $translate = {
instant: (translationKey: keyof typeof translations) => string,
use: Function,
proposedLanguage: Function
}
The downside of the current method again is that the translations file is output in the transpilation process, which is wasteful if the file is large.
What the above code snippet is trying to achieve, should be allowed in a .d.ts file without breaking global declaration functionality.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
muuvmuuv, sindresorhus, Bessonov, mayakwd and mirceanis
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript