How to use a module like simple-schema in typescript?

the new version of aldeed:simple-schema is also available as an npm package for non meteor apps. Since I use webpack I want to import simple-schema into an app written in typescript.

First I skiped the type definition by declare var SimpleSchema: any; which works fine. Second I tried to import SimpleSchema by adding this:

import * as SimpleSchema from 'simpl-schema';

simpl-schema (without ‘e’) exists in the node-modules folder but I got the error Module build failed: Error: (2,31): Cannot find module 'simpl-schma'.)

Only the first ‘e’ should be missing :wink:

You’re right :slight_smile: but it doesnt’ work anyways.

I think to get import to work you definitely need a type definition.

However, if you have an npm module you don’t need to create the typings yourself. Either the type definitions can be accessed through npm or typings. Or you can create a basic set by using another tool:

npm install -g dts-gen
npm install -g your_module_here
dts-gen -m your_module_here

Of course, since the module is installed globally you may also need to pull in some dependencies.

1 Like