Import @types in typescript with yarn workspaces

Viewed 29

Consider a scenario where we have 2 workspaces.

workspace-a

  • src/index.ts
import Exr from "./test.exr";

export const example = () => { 
  Exr;
};

  • src/test.exr
// binary file
  • src/@types/exr.d.ts
declare module "*.exr";

workspace-b

  • src/index.ts
import { example } from "@project/workspace-a/src/index";

console.log(example());

When I run the command tsc --noEmit in package-a there is no problem. When I run it on package-b I get:

error TS2307: Cannot find module './test.exr' or its corresponding type declarations.

1 import Exr from "./test.exr";

How to tell typescript to include @types when using local workspaces?

0 Answers
Related