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

Bug: Strict TypeScript error with ESModules #1008

Open
1 task done
dylanjha opened this issue Oct 30, 2024 · 3 comments
Open
1 task done

Bug: Strict TypeScript error with ESModules #1008

dylanjha opened this issue Oct 30, 2024 · 3 comments
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@dylanjha
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Which Mux Elements/Packages does this apply to? Select all that apply

mux-player-react

Which browsers are you using?

Other (add details below)

Which operating systems are you using?

macOS

Description

A simple react component like this:

import MuxPlayer from '@mux/mux-player-react';
const Foo = () => <MuxPlayer />;

Gives us the following TypeScript error with modern ESModules and a strict TypeScript config:

error TS2604: JSX element type 'MuxPlayer' does not have any construct or call signatures.

28       <MuxPlayer
          ~~~~~~~~~

src/components/custom/mediaPlayer/MediaPlayer.tsx:28:8 - error TS2786: 'MuxPlayer' cannot be used as a JSX component.
  Its type 'typeof import("/node_modules/@mux/mux-player-react/dist/types/index")' is not a valid JSX element type.

28       <MuxPlayer
          ~~~~~~~~~

Reduced test case

No response

Steps to reproduce

Try reproducing this with a strict TS Config

Current Behavior

Error building

Expected Behavior

No error building

Errors

No response

What version of the package are you using?

No response

@dylanjha dylanjha added bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Oct 30, 2024
@luwes
Copy link
Contributor

luwes commented Oct 30, 2024

@dylanjha what is the moduleResolution?

@rileytomasek
Copy link

rileytomasek commented Oct 30, 2024

@luwes @dylanjha filed this for me. Here is the tsconfig.json compiler options:

{
  "compilerOptions": {
    "allowImportingTsExtensions": false,
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "checkJs": true,
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": false,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "lib": ["esnext", "dom", "dom.iterable"],
    "module": "NodeNext",
    "moduleDetection": "force",
    "moduleResolution": "NodeNext",
    "noEmit": true,
    "preserveWatchOutput": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "es2022",
    "verbatimModuleSyntax": true
  }
}

@luwes
Copy link
Contributor

luwes commented Oct 31, 2024

I tested the tsconfig above with a fresh Vite app and I can't reproduce it unfortunately.

Are you using a framework?
Could you try restarting the TS server? sometimes that acts strangely when (re)installing node_modules.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

3 participants