Skip to content

Instantly share code, notes, and snippets.

@kitsonk
Last active August 18, 2020 18:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsonk/7c2c2d331dccb13f25c931ca6be9a40a to your computer and use it in GitHub Desktop.
Save kitsonk/7c2c2d331dccb13f25c931ca6be9a40a to your computer and use it in GitHub Desktop.
An example of using lodash under Deno in a type safe way.
// @deno-types="https://unpkg.com/@types/lodash@4.14.135/index.d.ts"
import * as lodash from "https://cdn.pika.dev/lodash-es@^4.17.15";
console.log(Object.keys(lodash));
@frankhale
Copy link

Trying with the latest deno release 0.41 I get the following error trying to run this:

Error:

error: Uncaught Error: Import 'https://unpkg.com/@types/lodash@4.14.135/index' failed: 404 Not Found

Full output:

❯ .\deno.exe deno-lodash.ts
Compile file:///C:/Users/frank/Documents/DEV/deno/deno-lodash.ts
Download https://unpkg.com/@types/lodash@4.14.135/index.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/common.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/array.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/collection.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/date.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/function.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/lang.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/math.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/number.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/object.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/seq.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/string.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/common/util.d.ts
Download https://unpkg.com/@types/lodash@4.14.135/index
Download https://unpkg.com/@types/lodash@4.14.135/index
error: Uncaught Error: Import 'https://unpkg.com/@types/lodash@4.14.135/index' failed: 404 Not Found
► $deno$/ops/dispatch_json.ts:43:11
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async processImports ($deno$/compiler/imports.ts:148:23)
    at async processImports ($deno$/compiler/imports.ts:156:7)
    at async processImports ($deno$/compiler/imports.ts:156:7)
    at async Object.processImports ($deno$/compiler/imports.ts:156:7)
    at async compile (file:///D:/a/deno/deno/cli/js/compiler.ts:131:31)
    at async tsCompilerOnMessage (file:///D:/a/deno/deno/cli/js/compiler.ts:338:22)
    at async workerMessageRecvCallback ($deno$/runtime_worker.ts:62:9)

@frankhale
Copy link

Removing the deno-types line causes it to work but I don't know why.

@garronej
Copy link

Yeah it does not work :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment