frejs / fre

:ghost: Tiny Concurrent UI library with Fiber.

Home Page:https://fre.deno.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsx-runtime types missing?

jcayzac opened this issue · comments

When using "jsxImportSource": "fre" in my typescript project I'm getting:

Could not find a declaration file for module 'fre/jsx-runtime'. 'node_modules/.pnpm/fre@2.0.0/node_modules/fre/jsx-runtime.js' implicitly has an 'any' type.

Indeed, there is no type file to write this file. If you can't wait, you can do a pr?

Not sure how to add it to the package without refactoring exports. I added that into my project and it fixed a few things:

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
declare module 'fre/jsx-runtime' {
  import { Attributes, FC, IFiber } from 'fre'

  type _JSX = <P extends Attributes = {}>(
    type: FC<P>,
    attrs: P
  ) => Partial<IFiber>

  export const jsx: _JSX
  export const jsxs: _JSX
  export function Fragment(props: any): any
}

Not sure how to add it to the package without refactoring exports. I added that into my project and it fixed a few things:

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
declare module 'fre/jsx-runtime' {
  import { Attributes, FC, IFiber } from 'fre'

  type _JSX = <P extends Attributes = {}>(
    type: FC<P>,
    attrs: P
  ) => Partial<IFiber>

  export const jsx: _JSX
  export const jsxs: _JSX
  export function Fragment(props: any): any
}

Can you pull a PR and put a d.ts file with the same name in the root directory?