Dynamically generate virtual typings for modules #18809
Unanswered
cabralpinto
asked this question in
Q&A
Replies: 1 comment
-
By making a typescript plugin, you won't need to generate a But using a typescript plugin is a bit hard, so probably you want to avoid that. The other way is to generate a type definition for each module in a single file. declare module 'src/foo.yaml' {
const content: any // types here
export default content
}
declare module 'src/bar.yaml' {
const content: any // types here
export default content
} Then, put that file in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote a simple Vite plugin that automatically generates a
.ts
file for each .yaml file to provide proper TypeScript typing for YAML imports. While this works as intended, it has the downside of cluttering my project with .yaml.ts files, which isn’t ideal. Here's the current implementation:Is there a way to generate virtual typing files or another method that VSCode can recognize for IntelliSense without physically creating
.ts
files in the workspace? Any insight would be greatly appreciated. Thanks!Beta Was this translation helpful? Give feedback.
All reactions