#Mitigating error message when adding YAML support to astro

1 messages · Page 1 of 1 (latest)

dusty torrent
#

This section (https://docs.astro.build/en/guides/imports/#example-yaml-support) on the Astro website describes how to use @rollup/plugin-yaml to add YAML support to Astro via Vite. However, even when I've configured Astro as outlined in those docs I still get the following error when attempting to do an import of a YAML file: Error: Cannot find module '../data/example.yaml' or its corresponding type declarations.

Even with the error being thrown, the build still completes without issue. Is there a way to prevent the error from being thrown? Disabling typescript features and diagnostics altogether appears to silence the error in VSCode but it continues to pop up when running astro check, but that feels like more of a workaround rather than a solution. Just curious if there was a way!

Astro Documentation

Learn how to import different content types with Astro.

somber gull
#

You can add a module definition for .yaml file

#
declare module '*.yaml' {
  const data: any;
  export default data;
}```