yarn linking and using a typescript module directly

Viewed 420

In an attempt to organize some code I extracted a bunch of TypeScript React components into their own npm module that is scoped with my organization name then yarn linked back into the original codebase.

In my original code base I now have:

import { Title } from '@foo/ui'

Typescript is giving me this error Cannot find module '@foo/ui' or its corresponding type declarations.ts(2307)

Now I can see my module symlinked in my original repo node_modules folder no problem.

I do not have a separate typings file - everything is in each react module - I attempted to create a semi empty typings file nonetheless though it's a bit unclear to me how one uses scoped packages. I have:

/
   @types
     @foo
        ui.d.ts
     index.d.ts

Both d.ts files have just a basic entry:

declare module '@foo/ui'

Now key to this is Id like to use the TypeScript files in my @foo/ui directly without generating js files (is that possible? the point of this is to have easy development side by side as the ui module is in the works`. I am relatively new to TS so clearly missing something here - adding scopes and yarn links doesn't help!

Can someone shed some light as to how I can resolve this? Ideally with direct usage of the TS files.

0 Answers
Related