Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: how to use utility-types in deno #141

Open
FaberVitale opened this issue May 31, 2020 · 6 comments
Open

docs: how to use utility-types in deno #141

FaberVitale opened this issue May 31, 2020 · 6 comments

Comments

@FaberVitale
Copy link

FaberVitale commented May 31, 2020

Is your feature request related to a real problem or use-case?

It is not currently possible to import/run utility-types in deno due to
different way node and deno resolve imports (aka module resolution).

deno run 'https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/index.ts'
Download https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/index.ts
Download https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/utility-types
Download https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/mapped-types
Download https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/aliases-and-guards
Download https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/functional-helpers
error: Import 'https://raw.githubusercontent.com/piotrwitek/utility-types/master/src/utility-types' failed: 404 Not Found

Describe a solution including usage in code example

2 Suggested solutions

  • Use a compiler like denoify to emit a compiled output that deno understands.

  • Refactor: remove all imports.

Who does this impact? Who is this for?

deno users.

Describe alternatives you've considered (optional)

Additional context (optional)

2023-02-20 Update

#141 (comment)

@FaberVitale FaberVitale mentioned this issue May 31, 2020
2 tasks
@piotrwitek
Copy link
Owner

Hey @FaberVitale 

Thanks for creating PR. I'll take a look ASAP and come back to you.

@mcandeia
Copy link

up

@piotrwitek
Copy link
Owner

I'm not familiar with Deno and would like to use some help here.
@mcandeia are you able to review and test existing PR to see if that's working as expected and will not break anything for existing nodejs users?

@FaberVitale
Copy link
Author

FaberVitale commented Feb 20, 2023

I developed this PR 3 years ago.

It's possible that these changes are obsolete:
It's now possible to import node packages in deno:

https://deno.land/manual@v1.30.3/node

@FaberVitale
Copy link
Author

FaberVitale commented Feb 20, 2023

It works!

I've just tested it using the following test file:

// deno_test.ts
import * as utilityTypes from 'npm:utility-types@3.9.0'

console.log('\nutility-types module', utilityTypes)
console.log('\nisPrimitive', utilityTypes.isPrimitive({}), utilityTypes.isPrimitive(2))
$ deno run deno_test.ts  


utility-types module Module {
  __esModule: true,
  default: {
    isFalsy: [Function],
    isPrimitive: [Function],
    getReturnOfExpression: [Function: getReturnOfExpression]
  },
  getReturnOfExpression: [Function: getReturnOfExpression],
  isFalsy: [Function],
  isPrimitive: [Function]
}

isPrimitive false true
deno --version
deno 1.30.3 (release, x86_64-apple-darwin)
v8 10.9.194.5
typescript 4.9.4

@piotrwitek you probably just need to add deno specific tests and document how to run the library in deno.

@FaberVitale FaberVitale changed the title feature: deno support docs: how to use utility-types in deno Feb 20, 2023
@piotrwitek
Copy link
Owner

Thanks a lot for your help @FaberVitale!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants