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

Broken typescript examples? #54

Closed
lamontadams opened this issue Jun 4, 2019 · 4 comments
Closed

Broken typescript examples? #54

lamontadams opened this issue Jun 4, 2019 · 4 comments

Comments

@lamontadams
Copy link

Hi there.

Looking at the example typescript app. I'm getting compilation errors against typescript 3.4.3. It seems to be expecting Async to return a JSX element and it isn't, and there doesn't seem to be an Async.Pending property....

JSX element type 'Async<string>' is not a constructor function for JSX elements.
  Type 'Async<string>' is missing the following properties from type 'Element': type, key
JSX element type 'Async<string>' is not a constructor function for JSX elements.
Property 'Pending' does not exist on type '<T>(defaultProps?: AsyncProps<T> | undefined) => Async<T>'.
Property 'Pending' does not exist on type '<T>(defaultProps?: AsyncProps<T> | undefined) => Async<T>'.

I'm looking at tsconfig.json and I'm not seeing anything there that should make a difference (this is also a create-react-app app). Should that example work as-is?

@lamontadams
Copy link
Author

lamontadams commented Jun 4, 2019

Didn't notice 3.5 had dropped when I posted this. I'm getting the same errors with tsc version 3.5.1

Edit - I see v6 changed Async.Pending to Async.Initial. If I update the example to

<Async promiseFn={() => Promise.resolve("foo")}>{({ data }: { data: string }) => data}</Async>
    <Async promiseFn={() => Promise.resolve("bar")}>
    <Async.Initial>{(data: string) => data}</Async.Initial>
</Async>

Then the last two errors become:

Property 'Initial' does not exist on type '<T>(defaultProps?: AsyncProps<T> | undefined) => Async<T>'.

So something does seem broken. In the event any of this makes any difference, here's relevant stuff from package.json:

"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-scripts": "2.1.5",

Cheers!

@dobesv
Copy link

dobesv commented Jun 12, 2019

Currently we cannot use the Async component or the createInstance function since their typescript declarations are incorrect.

@ghengeveld
Copy link
Member

This should be fixed in v6.2.1.

Will you please verify?

@ghengeveld
Copy link
Member

ghengeveld commented Jun 13, 2019

Turned out there was another issue with element types, which is fixed in v6.2.2.

Also I updated the with-typescript example. Should work now.

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

3 participants