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

TypeScript declarations for react-player/lazy broken in v2.8.1 #1146

Closed
cduff opened this issue Jan 21, 2021 · 5 comments · Fixed by #1153
Closed

TypeScript declarations for react-player/lazy broken in v2.8.1 #1146

cduff opened this issue Jan 21, 2021 · 5 comments · Fixed by #1153

Comments

@cduff
Copy link

cduff commented Jan 21, 2021

Current Behavior

Previously successfully using react-player v2.7.2 in TypeScript project importing react-player/lazy.

Upgrading to react-player v2.8.1 results in TypeScript errors as the TypeScript declarations for react-player/lazy have been broken.

Expected Behavior

Working TypeScript declarations for react-player/lazy.

Steps to Reproduce

Just try importing "react-player/lazy" in TypeScript project using react-player v2.8.1.

Environment

  • URL attempting to play: n/a
  • Browser: Chrome
  • Operating system: Windows 10
  • jsFiddle example: n/a

Other Information

Related to old closed issue #918.

The react-player/lazy/index.d.ts file seems to be a copy of the react-player/index.d.ts file but this simple approach no longer works due to broken relative path imports.

@antoinelin
Copy link

Hello 🖖

Got this error on my side :

JSX element class does not support attributes because it does not have a 'props' property.ts(2607)
'ReactPlayer' cannot be used as a JSX component.
  Its instance type 'ReactPlayer' is not a valid JSX element.
    Type 'ReactPlayer' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more.

Import :

import ReactPlayer from 'react-player/lazy'`

Usage :

<ReactPlayer
  url={url}
  width="100%"
  height="100%"
  playing
  muted
  controls={false}
/>

@cduff
Copy link
Author

cduff commented Jan 21, 2021

Hello 🖖

Got this error on my side :

JSX element class does not support attributes because it does not have a 'props' property.ts(2607)
'ReactPlayer' cannot be used as a JSX component.
  Its instance type 'ReactPlayer' is not a valid JSX element.
    Type 'ReactPlayer' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more.

Import :

import ReactPlayer from 'react-player/lazy'`

Usage :

<ReactPlayer
  url={url}
  width="100%"
  height="100%"
  playing
  muted
  controls={false}
/>

Hi @toinelin, yes I believe that error is caused by the react-player/lazy TypeScript declarations being broken.

@cookpete
Copy link
Owner

@JuanM04 Any ideas?

There does seem to be a circular requirement between base.d.ts and index.d.ts. Not sure if that’s related.

I can't see any import statements that would be affected by the directory it's in.

@jahed
Copy link
Contributor

jahed commented Jan 23, 2021

It's because types/index.d.ts needs all of its imports in the same directory but in prepublish it's copied alone to lazy/index.d.ts so the imports need to go back a directory. I can try sending a PR over if you want?

Update: I've sent a PR. #1153

jahed added a commit to jahed/react-player that referenced this issue Jan 23, 2021
@JuanM04
Copy link
Contributor

JuanM04 commented Jan 23, 2021

That's basically it. lazy/index.d.ts, it imports ./base when it should import ../base

jahed added a commit to jahed/react-player that referenced this issue Jan 23, 2021
jahed added a commit to jahed/react-player that referenced this issue Jan 23, 2021
cookpete added a commit that referenced this issue Jan 24, 2021
* fix: ensure lazy typedefs mirror defaults
Fixes #1146

* build: squash copy into a single command

Co-authored-by: Pete Cook <pete@cookpete.com>

Co-authored-by: Pete Cook <pete@cookpete.com>
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.

5 participants