Deno: [Question] Use typings.d.ts of date-fns

Created on 8 Feb 2020  Â·  4Comments  Â·  Source: denoland/deno

We can use date-fns with the following import statement.

import { format } from 'https://deno.land/x/date_fns/index.js'

date-fns publishes typings.d.ts at the root of their github repo, and we can reference it like the below.

/// <reference path="https://raw.githubusercontent.com/date-fns/date-fns/master/typings.d.ts" />
import { format } from 'https://deno.land/x/date_fns/index.js'

However the above doesn't work with the following error:

error: Uncaught ImportPrefixMissing: relative import path "date-fns" not prefixed with / or ./ or ../ Imported from "https://raw.githubusercontent.com/date-fns/date-fns/master/typings.d.ts"
â–º $deno$/dispatch_json.ts:40:11

Does anyone know how to fix the above error?

All 4 comments

All the:

import { endOfSecond } from 'date-fns'

that are located in typings.d.ts are not compatible with Deno.

already support in vscode extension

BTW. typing.d.ts 's namespace data-fns is not compatible with Deno

- declare module 'data-fns' {
+ declare module 'https://deno.land/x/date_fns/index.js' {
  export type Interval = IntervalAliased

  export type Locale = LocaleAliased

  export type Duration = DurationAliased
}

1

Or if you want something that looks more portable:

- declare module 'data-fns' {
+ declare module './date_fns/index.js' {
  export type Interval = IntervalAliased

  export type Locale = LocaleAliased

  export type Duration = DurationAliased
}

We need to add the emitting of declarations to bundles in Deno as well, and then we would only emit module names in declarations that would work with Deno.

Can this be closed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

justjavac picture justjavac  Â·  3Comments

JosephAkayesi picture JosephAkayesi  Â·  3Comments

ry picture ry  Â·  3Comments

CruxCv picture CruxCv  Â·  3Comments

doutchnugget picture doutchnugget  Â·  3Comments