不知道为什么打字稿突然无法识别我的代码,它显示
Cannot find module './hookStyle/useMemostyle.module.css' or its corresponding type declarations
Run Code Online (Sandbox Code Playgroud)
当我将样式移动到另一个文件夹时会发生这种情况
这是打字稿配置
{
"compilerOptions": {
"lib": [
"ESNext",
"dom"
],
"outDir": "lib",
"removeComments": true,
"target": "ES6",
"baseUrl": "src",
"esModuleInterop": true,
"moduleResolution": "node",
"sourceMap": true,
"sourceRoot": "/",
"alwaysStrict": true,
"allowUnreachableCode": false,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowJs": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"./**/*.ts"
],
"exclude": …Run Code Online (Sandbox Code Playgroud) 我正在学习 TypeScript,在入门页面中,他们谈论了 javascript 是多么出人意料。
来源:https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html
if ("" == 0) {
// It is! But why??
}
if (1 < x < 3) {
// True for *any* value of x!
}
Run Code Online (Sandbox Code Playgroud)
但我还是不明白为什么1<x<3总是这样?例如,如果我让 x=10,从逻辑上讲它不会为真,但为什么他们说它总是为真?
我只是用 mobX 玩了一些代码,就发生了这种情况,不知道为什么,但我确信它与官方文档没有太大不同
这是store.tsx
import { observable, computed, action, makeObservable, override, makeAutoObservable } from "mobx"
class CounterStore {
initValue = 0
powValue = Math.pow(this.initValue, 2)
constructor() {
makeAutoObservable(this)
}
increaseNumber() {
this.initValue = this.initValue + 1
}
}
const Store = new CounterStore()
export default Store
Run Code Online (Sandbox Code Playgroud)
这是我使用这个的地方。称为增量.tsx
import { observer } from "mobx-react"
export const IncrementButton = observer(({ store }) => {
return (
<div>
<button onClick={store.increaseNumber}>Increase</button>
<h1>{store.initValue}</h1>
</div>
)
})
Run Code Online (Sandbox Code Playgroud)
和index.tsx
ReactDOM.render(
<React.StrictMode>
<IncrementButton store={Store} /> …Run Code Online (Sandbox Code Playgroud)