You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow setting "resolveJsonModule": "const" as well as false and true.
as const is very useful, as is resolveJsonModule. I should be able to use them together.
Use Cases
I have some type helpers that can build strongly-typed dictionaries from some seed data whose schema is in another domain. We'd like to be able to use the json for things outside typescript, so would rather not put it in a .ts file. resolveJsonModule is almost what we need, but we can't import as const.
Examples
Assuming that seed data is defined like this:
constdata={items: [{id: 'alice',type: 'person'},{id: 'bob',type: 'person'},{id: 'fido',type: 'pet'}]}asconstconsttestHelper=// ...lots of type magic, taking advantage of the types in `items` being {id: "alice", type: "person"} etc., not just {id: string; type: string}testHelper.person.alice// {id: 'alice', type: 'person'}
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. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
Search Terms
resolveJsonModule
,const
Suggestion
Allow setting
"resolveJsonModule": "const"
as well asfalse
andtrue
.as const
is very useful, as isresolveJsonModule
. I should be able to use them together.Use Cases
I have some type helpers that can build strongly-typed dictionaries from some seed data whose schema is in another domain. We'd like to be able to use the json for things outside typescript, so would rather not put it in a
.ts
file.resolveJsonModule
is almost what we need, but we can't importas const
.Examples
Assuming that seed data is defined like this:
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: