Skip to content

Commit

Permalink
rax: fix JSX RaxFragment usage/export
Browse files Browse the repository at this point in the history
Typescript 5.7 will fail unless usage of RaxFragment is explicit, with
an import of it and a `/** @jsxFrag RaxFragment */` pragma at the top of
the file. This PR adds that.

RaxFragment also needs to have an exported value. I wasn't sure what to
use here so I copied preact, since preact is used in the Typescript
handbook as an example:

```ts
export const RaxFragment: FunctionComponent<{}>
```

Notably, though, the preact source has a comment indicating that
*they're* not sure of the correct type either.

Here is the Typescript 5.7 PR that made this error appear:

microsoft/TypeScript#59933
  • Loading branch information
sandersn committed Oct 3, 2024
1 parent 24a32d6 commit 136acde
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/rax/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ declare namespace Rax {
interface RaxNodeArray extends Array<RaxNode> {}
type RaxFragment = {} | RaxNodeArray;
type RaxNode = RaxChild | RaxFragment | RaxPortal | boolean | null | undefined;
export const RaxFragment: FunctionComponent<{}>

/**
* ======================================================================
Expand Down
2 changes: 2 additions & 0 deletions types/rax/test/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/** @jsxFrag RaxFragment */
import {
ComponentRef,
createContext,
createRef,
forwardRef,
MutableRefObject,
RaxNode,
RaxFragment,
Ref,
RefObject,
useCallback,
Expand Down

0 comments on commit 136acde

Please sign in to comment.