Reputation: 2527
I try to load this module in my typescript add.
First I added the npm package and the module has been installed correctly in my node_modules
folder as simpl-schema
.
Since there are no typings for this package I added this line:
declare var SimpleSchema: any;
I tried to import the package with import * as SimpleSchema from 'simpl-schema';
and got the message Cannot find module 'simpl-schema'
. I think a got this since simpl-schema
doesn't contain type information but I'm not sure.
I found tons of questions regarding this topic here, on reddit and other forums with a lot of suggestions which doesn't work for my setup. So I'm wondering whats the right way to this.
Upvotes: 1
Views: 240
Reputation: 446
You are correct that you're getting Cannot find module 'simpl-schema'
because types are either not available, or types are not setup properly.
Using declare var SimpleSchema: any;
in your ts says that SimpleSchema
is a variable (var
) of type any
declared outside the scope of that file. The above will not impact the result of importing simpl-schema
directly. An example would be adding something like declare const window: any;
to get access to the window
object, if it weren't already defined for you, elsewhere.
See here for a way to leverage the any
type when looking to import modules that don't have types available.
Upvotes: 1