question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript typing errors with Deno

See original GitHub issue

Using date-fns with typescript and Deno 1.0 produces the following error:

Uncaught URIError: relative import path "date-fns" not prefixed with / or ./ or ../ Imported from "https://cdn.pika.dev/-/date-fns@v2.13.0-CNtDbLLYSsBdKHS9Td13/dist=es2019,mode=types/typings.d.ts"

Reproduce using this gist

deno run https://gist.githubusercontent.com/sambs/d3c30151b9ed1cd3d308883148f88aec/raw/acffa68d532bd0df333c466671eb0565e3d85445/date-fns-deno.ts

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andykaiscommented, Sep 15, 2022

wanted to throw this out there, deno standard library includes its own datetime library now. Looks like it can handle most things https://deno.land/std@0.155.0/datetime/mod.ts

import * as datetime from "https://deno.land/std@0.155.0/datetime/mod.ts";

const date = new Date()
datetime.format(date, 'yyyy-MM-dd')
datetime.difference(new Date("2020/1/1"),new Date("2020/2/2"),{ units : ["days","months"] })
1reaction
bodograumanncommented, Sep 13, 2022

It seems the custom module https://deno.land/x/date_fns is not being updated. The related repository has been archived.

I tried using the latest verison of date-fns directly and it seemed to work without any problems:

import * as dateFns from "https://cdn.skypack.dev/date-fns@^2.29.2";
const date = new Date();
dateFns.format(date, "yyyy-MM-dd");
dateFns.startOfWeek(date);

So is there anything left to do here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using TypeScript | Manual - Deno
Using TypeScript. Deno supports both JavaScript and TypeScript as first class languages at runtime. This means it requires fully qualified module names, ...
Read more >
How do I fix these typescript errors? - deno - Stack Overflow
As for how to resolve error , you can resolve it by giving it types as given in the interface , suppose if...
Read more >
5 Changes Coming Soon to Deno - Fusebit
If the errors are variable-type data declarations, it will halt compilation until the errors are rectified. There are good arguments for ...
Read more >
TypeError - JavaScript - MDN Web Docs
The TypeError object represents an error when an operation could not be ... (but not exclusively) when a value is not of the...
Read more >
TypeScript for Deno: Any, Union Types, Custom Types, and ...
The clear problem is that the TypeScript compiler of any problem compiles to JavaScript even if we have typing errors as in line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found