hono icon indicating copy to clipboard operation
hono copied to clipboard

Module '"hono/jsx"' declares 'FC' locally, but it is not exported.ts

Open dcsan opened this issue 1 year ago • 1 comments

What version of Hono are you using?

2.7.8

What runtime/platform is your app running on?

cloudflare workers or just plain node - same

What steps can reproduce the bug?

as per this guide: https://hono.dev/guides/jsx#jsx

try to create a JSX module and add the line:

import type { FC } from 'hono/jsx'

will give compiler error:

Module '"hono/jsx"' declares 'FC' locally, but it is not exported.ts(2459)

What is the expected behavior?

should be able to create JSX modules

What do you see instead?

> [email protected] run
> node --watch -r ts-node/register src/index.ts

(node:13184) ExperimentalWarning: Watch mode is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/api/home.tsx:2:15 - error TS2459: Module '"hono/jsx"' declares 'FC' locally, but it is not exported.

2 import type { FC } from 'hono/jsx'
                ~~

  node_modules/hono/dist/types/middleware/jsx/index.d.ts:22:14
    22 declare type FC<T = Props> = (props: T) => HtmlEscapedString;
                    ~~
    'FC' is declared here.

    at createTSError (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.require.extensions.<computed> [as .tsx] (/Users/dc/dev/hacks/kbxt/workers/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  diagnosticCodes: [ 2459 ]
}
Failed running 'src/index.ts'

Additional information

and in the file in question:

it is indeed just declared and not exported:

node_modules/hono/dist/types/middleware/jsx/index.d.ts

declare type FC<T = Props> = (props: T) => HtmlEscapedString;

dcsan avatar Apr 28 '24 09:04 dcsan

FC is no longer used for the user. Please use PropsWithChildren instead of it.

https://hono.dev/guides/jsx#propswithchildren

Ref: https://github.com/honojs/hono/issues/2142

yusukebe avatar Apr 29 '24 03:04 yusukebe

This can be closed. Thanks!

yusukebe avatar May 22 '24 09:05 yusukebe