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

Bug: No types on Deno #3764

Closed
guy-borderless opened this issue Jan 18, 2023 · 12 comments
Closed

Bug: No types on Deno #3764

guy-borderless opened this issue Jan 18, 2023 · 12 comments

Comments

@guy-borderless
Copy link

guy-borderless commented Jan 18, 2023

Description

Hello!
when importing xstate in deno like so:
import * as xstate from "https://deno.land/x/xstate@[email protected]/src/index.ts";

loaded code has no types, probably since xstate doesn't use the .ts file extensions when importing files.
import { createMachine, Machine } from './Machine';
=>
import { createMachine, Machine } from './Machine.ts';

Expected result

typescript types should be loaded

Actual result

everything is typed as any

Reproduction

import * as xstate from "https://deno.land/x/xstate@[email protected]/src/index.ts";

Additional context

No response

@Andarist
Copy link
Member

This will be fixed in the next major version of XState.

@Andarist
Copy link
Member

We landed the appropriate change on the next branch: #3765

@Andarist Andarist reopened this Jan 24, 2023
@Andarist
Copy link
Member

Actually, while that PR switches the repo to moduleResolution: node16 and thus to using explicit extensions - it doesn't fix the issue at hand here. The repo is now using .js extensions in import sources - but Deno won't understand it as it's actually using .ts.

We gonna fix this and provide a way to import XState correctly in Deno but I need to rethink our options.

@davidkpiano
Copy link
Member

Can you check xstate@beta and see if it now has types?

@guy-borderless
Copy link
Author

guy-borderless commented Apr 14, 2023

importing xstate 5 latest- alpha 6 I see types!
import * as xstate from "https://deno.land/x/xstate@[email protected]/src/index.ts"

Thanks a lot!

@Andarist
Copy link
Member

How does deno.land work today with the recently added support for node_modules in deno? It feels to me that, ideally, you shouldn't reach into /src sirectory when importing xstate.

@guy-borderless
Copy link
Author

guy-borderless commented Apr 14, 2023

Personally I like that this style of import is not abstracted, like it is with local imports. Easier to debug and understand imported code IMO. For the main module in deno there is a mod.ts convention. Also, This is an interesting read. if I understand correctly the next version of deno will formalize the mod.ts pattern to encourage npm style import with the "deno:" URL scheme (and I'm sure they'll generalize for file servers hosting ESM). I think the more ESM the better, great ergonomics and less power to npm.

@davidkpiano
Copy link
Member

davidkpiano commented Apr 15, 2023

Closing as it seems that xstate@beta in Deno how provides types 🎉

Feel free to reopen if some details are still missing about this.

EDIT: not closed yet

@Andarist
Copy link
Member

I’d definitely like to figure out a better way for Deno users to consume our package. Relying in the src directory isn’t stable and could break for subtle reasons at any time

@guy-borderless
Copy link
Author

I’d definitely like to figure out a better way for Deno users to consume our package. Relying in the src directory isn’t stable and could break for subtle reasons at any time

mod.ts

@guy-borderless
Copy link
Author

guy-borderless commented Sep 12, 2023

npm import works now
import { createMachine } from 'npm:xstate'

@davidkpiano
Copy link
Member

npm import works now import { createMachine } from 'npm:xstate'

Great, thanks for the update!

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

No branches or pull requests

3 participants