react-strict-dom icon indicating copy to clipboard operation
react-strict-dom copied to clipboard

Typescript: Module '"react-strict-dom"' has no exported member 'compat'.

Open davidjbng opened this issue 9 months ago • 2 comments

Describe the issue

compat is documented here, but it does not have a Typescript definition.

Expected behavior

Typescript definition for compat is available

Steps to reproduce

  • Clone https://github.com/davidjbng/react-strict-dom-compat-ts
  • npm install
  • npm run typecheck

Test case

https://github.com/davidjbng/react-strict-dom-compat-ts

Additional comments

No response

davidjbng avatar Apr 23 '25 12:04 davidjbng

The types are there, but the API is only exported for native. I'll update the docs to make that clear

necolas avatar Apr 23 '25 16:04 necolas

Custom conditions can be resolved using "customConditions", and platform extensions using "moduleSuffixes" option in TypeScript.

In this case adding "customConditions" seems to fix the missing compat types.

{
  "compilerOptions": {
    "customConditions": ["react-native"],
    "moduleSuffixes": [".ios", ".android", ".native", ""]
  },
}

ref:

  • https://www.typescriptlang.org/tsconfig/#customConditions
  • https://www.typescriptlang.org/tsconfig/#moduleSuffixes

javascripter avatar Apr 24 '25 09:04 javascripter

This is being added to the docs in https://github.com/facebook/react-strict-dom/pull/315

necolas avatar Jun 26 '25 21:06 necolas