英文:
How to define JSX.IntrinsicElements using nano_jsx with Deno?
问题
Here's the translation of the non-code parts:
如何解决这个错误?
> JSX元素隐式具有类型'any',因为不存在接口'JSX.IntrinsicElements'。deno-ts(7026)
这里是有问题的代码:
这是Deno文章中的示例代码:https://deno.com/blog/a-whole-website-in-a-single-js-file-continued
这是源代码:https://dash.deno.com/playground/website-in-a-single-js-2
英文:
How do I get rid of this error?
> JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.deno-ts(7026)
Here's the problematic code:
const problematicCode = <div>Hello world</div>
This is example code in this Deno article: https://deno.com/blog/a-whole-website-in-a-single-js-file-continued
Here's the source code: https://dash.deno.com/playground/website-in-a-single-js-2
答案1
得分: 0
For Nano JSX to declare the jsx type in a single file use:
/** @jsx h */
/** @jsxFrag Fragment */
import { h, Fragment } from "https://deno.land/x/nano_jsx@v0.0.37/mod.ts";
For Preact:
/** @jsx h */
/** @jsxFrag Fragment */
import { h, Fragment } from "https://esm.sh/preact@10.8.2";
Fresh uses the deno.json
config with the preact import map like this:
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
英文:
For Nano JSX to declare the jsx type in a single file use:
/** @jsx h */
/** @jsxFrag Fragment */
import { h, Fragment } from "https://deno.land/x/nano_jsx@v0.0.37/mod.ts";
For Preact:
/** @jsx h */
/** @jsxFrag Fragment */
import { h, Fragment } from "https://esm.sh/preact@10.8.2";
Fresh uses the deno.json
config with the preact import map like this:
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论