-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Types wrong for ESM + module: Node16 / NodeNext #1613
Comments
One thing that is working for me is to change all of the affected Eg. for this export in Line 30 in 662082a
The change would look like this: -export default class FilePlayer extends BaseReactPlayer<FilePlayerProps> {}
+export = class FilePlayer extends BaseReactPlayer<FilePlayerProps> {} This is also compatible with projects using CommonJS and/or other module resolution types. So probably not a huge PR, but probably all of the exports across all files need to change. |
This seems to be fixed https://arethetypeswrong.github.io/?p=react-player%402.16.0 |
@luwes Thanks for the answer! It looks like Are The Types Wrong? does indeed report no errors for However, it seems that Are The Types Wrong? is not detecting the problem that (still) exists with react-player/src/players/FilePlayer.js Line 20 in 795b196
The The current
Code: import ReactPlayer from 'react-player/file.js';
type Props = {
thumbnail: string;
url: string;
};
export default function ResponsiveVideoPlayer(props: Props) {
return <ReactPlayer {...props} />
} Here's a TypeScript Playground to show the error: (change the Fully-Specified Import PathThe fully-specified import path cc @andrewbranch in case ATTW should also detect this problem |
Looks like it's working without errors, yep! Happy to either keep this open until a v3 non-canary release lands, or close it already now. (I had to switch the import path to // eslint-disable-next-line import/no-unresolved -- eslint-plugin-import doesn't understand `exports` in package.json yet https://github.com/import-js/eslint-plugin-import/issues/1810
import ReactPlayer from 'react-player/file';
type Props = {
thumbnail: string;
url: string;
};
export default function ResponsiveVideoPlayer(props: Props) {
return <ReactPlayer {...props} />
} |
Ah, seems like this
So maybe the Eg. an example PR fixing such an error: I'll open a PR |
@luwes opened a PR to address the |
merged and released! here it seems to work but it's the latest Next.js |
Thanks for the review and merge! I can confirm that |
Be sure to search for your issue before opening a new one.
Current Behavior
The types for
react-player@2.12.0
are incorrect when using ESM (eg."type": "module"
inpackage.json
) and modern Node.js module resolution ("module": "Node16"
or"module": "NodeNext"
intsconfig.json
)See the error on Are The Types Wrong?
You can also see this on this TypeScript Playground, with the code from the first example in the readme. Error message:
Expected Behavior
There should be no error
Steps to Reproduce
Environment
Other Information
--
The text was updated successfully, but these errors were encountered: