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

discussion #1

Closed
GongT opened this issue Jul 21, 2023 · 10 comments
Closed

discussion #1

GongT opened this issue Jul 21, 2023 · 10 comments

Comments

@GongT
Copy link

GongT commented Jul 21, 2023

Greate thanks for your reply!


I tried this repo, but I still can not compile it.

I have tried typescript 4.9.5 and 5.1.6, they give me the same error:

src/index.tsx:1:29 - error TS2307: Cannot find module 'react-lib' or its corresponding type declarations.

1 import { FancyButton } from 'react-lib';
                              ~~~~~~~~~~~


Found 1 error in src/index.tsx:1
@rschristian
Copy link
Owner

Did you clone & run or did you try to install dependencies yourself? There's a dummy lib placed in node_modules that will probably get removed if you actually try to install deps w/ NPM, Yarn, etc.

@GongT
Copy link
Author

GongT commented Jul 21, 2023

both

image

@rschristian
Copy link
Owner

You're running yarn and creating a tsconfig.json. Like I said, don't do that, it'll break the example.

@GongT
Copy link
Author

GongT commented Jul 21, 2023

Thanks👍. let me check again

@GongT
Copy link
Author

GongT commented Jul 21, 2023

You're running yarn and creating a tsconfig.json. Like I said, don't do that, it'll break the example.

No, I did both.

I got two error if I don't run yarn, second one is expected (unknown props foo), but first one is wired.

@rschristian
Copy link
Owner

rschristian commented Jul 21, 2023

Sorry, first error is correct (we don't re-export ReactNode), second is type checking via path aliases working

Was reading from my phone, missed that in the images

@rschristian
Copy link
Owner

rschristian commented Jul 22, 2023

So the "issue" there is that Preact doesn't re-export all of React's types (which we know and try to correct, but it's a moving target as React's types constantly change), not that path aliasing doesn't work, if that makes sense.

@GongT
Copy link
Author

GongT commented Jul 22, 2023

Ok, clear! I have some ideas now, let me try.

thank you, again! 😆

@GongT GongT closed this as completed Jul 22, 2023
@rschristian
Copy link
Owner

I'll raise an issue on the repo / implement the alias for ReactNode, that's definitely an oversight we'll like to fix, but hopefully this gives you a (rough) idea of how things are meant to be working.

Certainly feel free to create an issue if you run across any further missing types or weird type errors.

@rschristian
Copy link
Owner

preactjs/preact#4077

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

No branches or pull requests

2 participants