I've been really very stuck for some weeks trying to solve that, I'm really suach a exhausted man...
Up to now, and according to this guide:
npm install stripe --save
npm install @types/stripe --save-dev
and I've added this in to webpack.common.js:
new webpack.ProvidePlugin({
Stripe: 'stripe'
})
Then, into my typescript component I've added this:
import * as Stripe from '@types/stripe';
Nevertheless I'm getting this error:
[ts] File '.../node_modules/@types/stripe/index.d.ts' is not a module.
I've also tried:
import stripePackage from 'stripe';
But I'm getting the same message:
[ts] File '.../node_modules/@types/stripe/index.d.ts' is not a module.
EXTENSION
By now, I've uninstalled @types/stripe and I've added the script cdn reference on index.html:
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
By other side, I've also added the reference into my typescript:
import * as Stripe from 'stripe';
- I'm using VSCode in order to develop my typescript project. It's magic for me
VSCodeis available to give methods onStripeobject.- How does VSCode know where
stripeis located? (Remember I've only added a<script type=...>tag intoindex.html. It's something magic for me. - How does
webpack or typescriptcreate the link between<script>tag reference into my typescript code? I'm not able to figure out how it's provided...
- How does VSCode know where
import 'stripe''stripe'?Stripestraightforwardly. Which are the issues I'm not able to useimport * as Stripe from '@types/stripe'orimport * as Stripe from 'stripe'...?@typesare just type definitions. This is not a library you can import. It depends on how the package is written, but if you just have a script tag in your index.html, and the@typesinstalled, there is no need for an import in typescript anymore