- Получаются ошибки IDE, такие как свойство 'div' не существует для типа 'JSX.IntrinsicElements'. при использовании Bun с React в Linux Ubuntu с tsconfig по умолчанию (где "jsx" : "react-jsx").
- Создание приложение со сборкой Bun Run, которая преобразуется в tsc -b && vite build, выдаст ошибки, как показано ниже.
Код: Выделить всё
19:22:08 3728 test-bun bun run build
$ tsc -b && vite build
src/App.tsx:11:7 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
11
~~~~~
src/App.tsx:12:9 - error TS2339: Property 'a' does not exist on type 'JSX.IntrinsicElements'.
12 [url=https://vite.dev]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:13:11 - error TS2339: Property 'img' does not exist on type 'JSX.IntrinsicElements'.
13
[img]{viteLogo} className=[/img]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:14:9 - error TS2339: Property 'a' does not exist on type 'JSX.IntrinsicElements'.
14 [/url]
~~~~
src/App.tsx:15:9 - error TS2339: Property 'a' does not exist on type 'JSX.IntrinsicElements'.
15 [url=https://react.dev]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:16:11 - error TS2339: Property 'img' does not exist on type 'JSX.IntrinsicElements'.
16
[img]{reactLogo} className=[/img]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:17:9 - error TS2339: Property 'a' does not exist on type 'JSX.IntrinsicElements'.
17 [/url]
~~~~
src/App.tsx:18:7 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
18
~~~~~~
src/App.tsx:19:7 - error TS2339: Property 'h1' does not exist on type 'JSX.IntrinsicElements'.
19 Vite + React
~~~~
src/App.tsx:19:23 - error TS2339: Property 'h1' does not exist on type 'JSX.IntrinsicElements'.
19 Vite + React
~~~~~
src/App.tsx:20:7 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
20
~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:21:9 - error TS2339: Property 'button' does not exist on type 'JSX.IntrinsicElements'.
21 setCount((count) => count + 1)}>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:23:9 - error TS2339: Property 'button' does not exist on type 'JSX.IntrinsicElements'.
23
~~~~~~~~~
src/App.tsx:24:9 - error TS2339: Property 'p' does not exist on type 'JSX.IntrinsicElements'.
24
~~~
src/App.tsx:25:16 - error TS2339: Property 'code' does not exist on type 'JSX.IntrinsicElements'.
25 Edit src/App.tsx~~~~~~
src/App.tsx:25:33 - error TS2339: Property 'code' does not exist on type 'JSX.IntrinsicElements'.
25 Edit
Код: Выделить всё
src/App.tsx~~~~~~~
src/App.tsx:26:9 - error TS2339: Property 'p' does not exist on type 'JSX.IntrinsicElements'.
26
~~~~
src/App.tsx:27:7 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
27
~~~~~~
src/App.tsx:28:7 - error TS2339: Property 'p' does not exist on type 'JSX.IntrinsicElements'.
28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:30:7 - error TS2339: Property 'p' does not exist on type 'JSX.IntrinsicElements'.
30
~~~~
src/main.tsx:7:3 - error TS2345: Argument of type 'Element' is not assignable to parameter of type 'ReactNode'.
7
~~~~~~~~~~~~
8
~~~~~~~~~~~
9 ,
~~~~~~~~~~~~~~~
src/main.tsx:7:4 - error TS2786: 'StrictMode' cannot be used as a JSX component.
Its return type 'ReactNode' is not a valid JSX element.
Type 'undefined' is not assignable to type 'Element | null'.
7
~~~~~~~~~~
Found 22 errors.
Минимальный воспроизводимый код:
Минимальный воспроизводимый код — это базовый шаблонный код, который вы получаете при запуске Bun Create Vite . Единственное отличие заключается в том, что я использую Linux Ubuntu.
Вот файл tsconfig.json по умолчанию, который поставляется с Bun create Vite .
Код: Выделить всё
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
- Я изменил значение jsx в файле tsconfig.app.json на «preserve» . Кажется, это избавляет от ошибок линтера, и мое приложение можно собрать, но мне интересно, почему мне нужно это делать при использовании Bun в Linux?
- Использование npm для создания приложения Vite + TypeScript + React не вызывает никаких проблем на моем компьютере с Linux и Ubuntu.
- Использование Bun для создания приложения Vite + TypeScript + React не вызывает какие-либо проблемы на моем компьютере с MacOS.
Подробнее здесь: https://stackoverflow.com/questions/798 ... n-on-linux
Мобильная версия