baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript
https://baconjs.github.io
MIT License
6.47k stars 331 forks source link

TypeScript import doesn't work #766

Closed steve-taylor closed 4 years ago

steve-taylor commented 4 years ago

I started a new TypeScript project using npm init and npx tsc --init, then created the following src/index.ts file:

import {Observable, Property} from 'baconjs';

export function add(a$: Observable<number>, b$: Observable<number>): Property<number> {
    return a$.combine(b$, (a, b) => a + b);
}

When I attempt to compile using npx tsc -p ., I get the following error:

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

1 import {Observable, Property} from 'baconjs';
                                     ~~~~~~~~~ 
steve-taylor commented 4 years ago

My bad. I added "moduleResolution": "node" to tsconfig.json and that fixed the problem.