我正在努力解决 VSCode 中的“错误”:
Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'
Run Code Online (Sandbox Code Playgroud)
因此,当value 似乎有效时,react-scripts (create-react-app) 会自动将jsx
key设置为react-jsx
value react
。
实际上,代码运行良好并显示了我想要的页面,但是 IDE 将所有内容都强调为错误,并说:
Cannot use JSX unless the '--jsx' flag is provided.
Run Code Online (Sandbox Code Playgroud)
这是我的 tsconfig.json :
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
} …
Run Code Online (Sandbox Code Playgroud) 我已经四处寻找解决这个问题的方法了.所有这些都建议添加"jsx": "react"
到您的tsconfig.json文件.我做了什么.另外一个是补充"include: []"
,我也做了.但是,当我尝试编辑.tsx
文件时,我仍然收到错误.下面是我的tsconfig文件.
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"allowJs": true,
"checkJs": false,
"jsx": "react",
"outDir": "./build",
"rootDir": "./lib",
"removeComments": true,
"noEmit": true,
"pretty": true,
"skipLibCheck": true,
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": [
"./lib/**/*"
],
"exclude": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
任何的意见都将会有帮助.我正在使用babel 7来编译env,react和typescript预设的所有代码.如果你们需要更多文件来帮助调试这个,请告诉我.
我正在学习 firebase 云函数,在我的index.ts文件夹中,我在导入下突出显示了错误消息
我不知道这意味着什么以及如何解决它,最糟糕的是,相同的代码在 youtube 上的 firebase 教程视频中工作
这段代码有什么问题?
import * as functions from "firebase-functions";
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
export const helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", { structuredData: true });
response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)
这是我的 tsconfig
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": ["src"]
}
Run Code Online (Sandbox Code Playgroud) 嘿伙计们,这个问题还没有通过类似的解决,
\n\n尝试了他们的解决方案,但对我不起作用。
\n现在我的情况\n tsconfig.js
\n{\n "compilerOptions": {\n "noUnusedLocals": false,\n "noUnusedParameters": false,\n "noImplicitReturns": false,\n "noImplicitAny": false,\n "skipLibCheck": false,\n "strict": false,\n "strictNullChecks": false,\n "allowSyntheticDefaultImports": true,\n "esModuleInterop": true,\n "resolveJsonModule": true,\n "experimentalDecorators": true,\n "emitDecoratorMetadata": true,\n "declaration": true,\n "jsx": "react",\n "module": "commonjs",\n "moduleResolution": "node",\n "target": "es6",\n "outDir": "./dist",\n "lib": [\n "dom",\n "esnext"\n ]\n },\n "esModuleInterop": true,\n "include": [\n "src/components/canvas/index.tsx",\n "src/components/canvas/Canvas.tsx",\n "src/components/canvas/global.d.ts"\n ],\n "exclude": [\n "node_modules",\n "dist",\n "lib"\n ]\n}\n\n
Run Code Online (Sandbox Code Playgroud)\ngulpfile.js
\n\nconst gulp …
Run Code Online (Sandbox Code Playgroud)