I've installed @types/stripe-v3
and included Stripe's javascript file in a script tag in index.html
. Supposedly the Angular compiler should include all files automagically from the @types node modules. Reading up on the internet and looking at @types/stripe-v3/index.d.ts
there should be a var Stripe declared globally if the file is included by the compiler. From index.d.ts
declare var Stripe: stripe.StripeStatic;
In my service file I have the following code:
import { Injectable } from '@angular/core';
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root'
})
export class BetalingService {
stripe = Stripe(environment.stripeKey);
constructor() { }
}
Resulting in the following error:
error TS2304: Cannot find name 'Stripe'.
import { Stripe } from 'stripe-v3';
you get the error 'stripe-v3 is not a module', because the index.d.ts file indeed does not declare a module, it is meant to declare this global var Stripe upon inclusion by the compiler – Mccarteryarn add @types/stripe-v3 --save
– Suricate