ts-node doesn't load a locally declared module

Viewed 14

I have a typescript package project with a layout like:

 - index.d.ts
 - index.js
 - demo/
     - index.ts

The index.d.ts looks like:

declare module 'foo' {
    export function foo(str: string): boolean
}

The root index.ts looks like this:

import { foo } from 'foo';
console.log(foo('foo'));

When I run ts-node demo/index.ts, I get this:

src/index.ts:1:21 - error TS2307: Cannot find module 'foo' or its corresponding type declarations.

1 import { foo } from 'foo';

Any ideas how I can use a module declared "locally" like this?

If I import (the real) foo from a private npm registry, it all works fine. The content of the index.d.ts is the same. This is a head scratcher.

Is there a nicer way to include an example of how to use/demo the project in the same repo (avoiding npm link, yalc, packing etc)

0 Answers
Related