denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.91k stars 5.22k forks source link

Import map does not redefine types #18065

Open Ciantic opened 1 year ago

Ciantic commented 1 year ago

Currently date-fns can't load up types in Deno when imported like this:

import {
    startOfDay
} from "https://esm.sh/date-fns";

// This should give error if types were loaded
let foo = startOfDay("foo");

I noticed that Deno loads the types just fine if I use this:

import { startOfDay } from "npm:date-fns";

// Gives error as expected
let foo = startOfDay("foo");

This lead me to try what if I use import maps to redefine https://esm.sh/date-fns as npm:date-fns it didn't seem to work:

{
    "imports": {
        "https://esm.sh/date-fns" : "npm:date-fns"
    }
}

Now if I use the above code, this should give error:

import {
    startOfDay
} from "https://esm.sh/date-fns";

// This should give error if types were loaded, but it still doesn't give out error?
let foo = startOfDay("foo");

It looks like import maps aren't redefining the types somehow.

boarwell commented 1 year ago

I had a similar problem, but it seems to have been fixed for me after upgrading Deno from 1.31.1 to 1.31.3.