Jonathan
Jonathan

Reputation: 894

React typescript snowpack - can't import .webp

I just started using Snowpack for a React/Typescript project and initialized it with: https://www.npmjs.com/package/@snowpack/app-template-react-typescript. It looks very promising but I get an error [@snowpack/plugin-typescript] Cannot find module '../../dummy.webp or its corresponding type declarations when trying to import a .webp image. Somebody an idea how to get it working without using @ts-ignore?

Upvotes: 1

Views: 745

Answers (1)

Jonathan
Jonathan

Reputation: 894

Just found the solution. You need to add the following lines in types/static.d.ts:

declare module '*.webp' {
  const ref: string;
  export default ref;
}

Upvotes: 1

Related Questions