-
-
Notifications
You must be signed in to change notification settings - Fork 148
Provide TypeScript definition file #357
Comments
That seems fine to me, though I don't really know much about typescript. Maybe @mseddon knows 😊 |
@developit I want to use
but app.tsx |
Hi @yyhappynice - can you post a little more of the surrounding Webpack configuration? It seems like your aliases are not being used. Also just to make sure - you've run |
I submitted the code my project . I didn't find the config mistake. |
Hey - I tried a bunch of stuff out locally, but I have no idea what I'm doing when it comes to TypeScript + webpack. I've never seen anyone use |
OK thinks~ I'll have a try |
@yyhappynice run resolve: {
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat',
}
} |
@plievone At the same time, webpack config need to add ProvidePlugin. Very nice!My project working. thanks ~
|
Hi. I was faced with the problem using I'm using I solved it with remove JSX section from a Maybe there's another way? Also migrating from |
@shyr1punk Hi you can look at this demo. May help you~ |
I'm running into this issue as well. I am using I get issues using libraries that depend on react:
If i install |
@jeffutter @shyr1punk I think you want to import only from react (not preact) in your code base. This way typescript doesn't link to the types of preact. You should then be able to install The implication is that you cannot use libraries built on preact and libraries built on react and have the types working for both at the same time (apart from deleting the conflicting type declarations in node_modules/)... I don't know what would be a proper solution for that. If anyone has any suggestion? |
@Mytrill Hmm, this does work. It feels a little 'dirty' but I suppose it's fine, react doesn't end up getting imported accidentally or anything like that and flow is happy. |
I don't think you really want a Typings for preact-compat, you just install My React components is so complex because they're created in AngularJS scope, and they also inject (render) AngularJS directives in their React scope!! So the preact-compat trying will be very interesting! |
So I'm not sure how this all works. I created a project with preact-cli using the widget template. I modified my preact config to use preact-cli-plugin-typescript and then tried importing react-apollo to use as my graphql-client, which did not work obviously. I then installed |
|
When mix-and-match preact and react components in typescript, typescript complains as react's element cannot be converted to preact's JSX element.
However, the above code does work as webpack has aliased
react
topreact-compat
and use preact's element.Output of above code:
What if preact-compat add a typescript definition file that declare
preact-compat
and aliasedreact
,react-dom
modules? This should solve typescript complaining about type error.Sorry I am not good at writing definition file. But the idea is,
The text was updated successfully, but these errors were encountered: