What import attribute types are available? #23696
-
I see this is working in Deno: import example from "./example.json" with { type: "json" }; Thats great! But I am wondering what types are available other than Also, this is bit of a leading question because specifically what I'm looking for is the ability to define custom types and handle those as a sort of pre-processor. some hypothetical syntaximport justin "./justin.ts"
import example from "./example.justin" with justin; I really have no idea if the above is possible, or if anyone is even thinking along these lines as an eventually feature? But I'm not gonna lie it would be pretty cool. I'm working on a tool which is essentially a parser generator and the above would be pretty slick for people making dsls. json alternative (simplified)import justin from "./justin.ts"
import dsl from "./example.json" with { type: "json" };
export const example = justin(dsl); The above will work for now but it will essentially require a pre-compile step for dsl authors while the desired hypothetical syntax would be dynamic, which feels more appropriate for the web. I'm just wondering how far this feature will go. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Currently only
There was talks about this in the team, especially @piscisaureus wanted such a feature, but so far there's been no consensus and we don't plan doing that in the forseeable future. |
Beta Was this translation helpful? Give feedback.
Currently only
"json"
type is supported. We did a bunch of preliminary work to supporttext
,bytes
andwasm
types as well (eg. denoland/deno_core#402) but they are not yet available.There was talks about this in the team, especially @piscisaureus wanted such a feature, but so far there's been no consensus and we don't plan doing that in the forseea…