Reputation: 692
For some reason, types do not seem to work properly in Deno (version: 1.41.0) when using import maps.
This works:
import Stripe from 'npm:[email protected]'
This doesn't work:
import Stripe from '$stripe'
or
// @deno-types="npm:@types/stripe"
import Stripe from '$stripe'
The import map in deno.json
:
"imports": {
"$stripe": "npm:[email protected]"
}
VS Code's settings.json
:
{
"deno.enablePaths": [
"./"
],
"deno.enable": true,
"deno.unstable": true,
"deno.config": "./deno.json",
"deno.lint": true,
}
Why?
Upvotes: 0
Views: 634
Reputation: 692
I have resorted to using deps.ts
(as described here) instead of import maps, e.g.:
// deps.ts
export { Stripe } from "npm:[email protected]";
and then importing any given dependency like this:
// e.g. stripe.ts
import { Stripe } from "./deps.ts";
Everything works as expected when using this pattern and the overall DX is satisfactory.
Upvotes: 0