You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check if updating to the latest Preact version resolves the issue (it did not...)
Describe the bug
I found two problems in the type compatibility layer for React included in preact/compat (in node_modules\preact\compat\src\index.d.ts):
HTMLAttributes: Interface has a required generic parameter (HTMLAttributes<T>) in React, but it is optional in preact/compat, which is an alias for preact.JSX.HTMLAttributes.
SVGProps: Included in React, but missing in preact/compat and preact.JSX.
Try the code below with and without React path aliases.
SVGProps
import * as React from 'react'
// With path aliases in tsconfig
type SVGProps = React.SVGProps<any> // ❌ Namespace '".../node_modules/preact/src/jsx".JSXInternal' has no exported member 'SVGProps'.
// WITHOUT path aliases in tsconfig
type SVGProps = React.SVGProps<any> //👍 interface React.SVGProps<T>
HTMLAttributes
import * as React from 'react'
// With path aliases in tsconfig
type HTMLAtts = React.HTMLAttributes // 🤔 This should be an error, but isn't
// WITHOUT path aliases in tsconfig
type HTMLAtts = React.HTMLAttributes // ❌ Generic type 'HTMLAttributes<T>' requires 1 type argument(s).
This can also be confirmed by comparing node_modules\@types\react\index.d.ts with node_modules\preact\compat\src\index.d.ts.
Expected behavior
My understanding is that Preact should be interchangeable with React -- a drop-in replacement, at least for a very basic use case. Preact should therefore provide compatible shims for core React types.
The text was updated successfully, but these errors were encountered:
Describe the bug
I found two problems in the type compatibility layer for React included in
preact/compat
(innode_modules\preact\compat\src\index.d.ts
):HTMLAttributes
: Interface has a required generic parameter (HTMLAttributes<T>
) in React, but it is optional in preact/compat, which is an alias forpreact.JSX.HTMLAttributes
.SVGProps
: Included in React, but missing in preact/compat and preact.JSX.To Reproduce
package.json
tsconfig.json
Try the code below with and without React path aliases.
SVGProps
HTMLAttributes
This can also be confirmed by comparing
node_modules\@types\react\index.d.ts
withnode_modules\preact\compat\src\index.d.ts
.Expected behavior
My understanding is that Preact should be interchangeable with React -- a drop-in replacement, at least for a very basic use case. Preact should therefore provide compatible shims for core React types.
The text was updated successfully, but these errors were encountered: