有没有办法通过error: unknown编译器选项/eslint 禁止任何类型的错误或强制注释?
function justDoIt(arg: string){}
// because error is any type this works :(
smth().catch(error => justDoIt(error))
如果用户尚未下载 react_app.js(第一次来),则使用 react 您需要在任何路由中提供包含 react_app.js 的 index.html。
然后你需要从 react_app.js 提供一些 api 调用,但是如果你对 GET 使用相同的 url,假设你会得到 API 调用响应,而不是带有 react_app.js 的 index.html。
解决这个问题的方法是什么?仅使用某些前缀进行 api 调用并仅在未找到路由时发送 index.html?
我的代码:
fastify.register(require('fastify-static'), {
  root: path.join(__dirname, './static')
})
fastify.route({
  method: 'GET',
  url: '/',
  handler: async (req, res) => {
    res.send('you will get api call answer but you need to serve index.html with react_app.js first!!!!')
  }
})
如何为表单输入制作类型?
const Index = () => {
  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault()
    console.log(e.currentTarget.elements.email)
  }
  return (
    <Layout>
      <form onSubmit={handleSubmit}>
        <input name='email' type='email' autoComplete='email' required />
        <input name='password' type='password' autoComplete='password' required />
        <button type='submit'>Login</button>
      </form>
    </Layout>
  )
}
类型错误:
“HTMLFormControlsCollection”类型上不存在属性“email”。
我很好奇 JS 有多少种类型,因为我从其他可靠的来源读到了相互矛盾的答案:
如果我们查看ECMAScript 规范,有 8 种类型:
看来function是算作对象了。
如果我们查看MDN,他们说有 9 种类型:
六种基本数据类型,由 typeof 运算符检查:
结构类型:
结构根原语:
其中哪一项是正确的?
由于某种原因,他们只是不想在 flex 行中处于基线:
小提琴:https : //jsfiddle.net/4Lmdqnj6/
div {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
h1 {
  font-size: 22px;
  display: flex;
  align-items: baseline;
  vertical-align: baseline;
}
h2 {
  font-weight: 16px;
  display: flex;
  align-items: baseline;
  vertical-align: baseline;
}<div>
  <h1>H1</h1>
  <h2>H2</h2>
</div>reactjs ×2
typescript ×2
css ×1
eslint ×1
express ×1
fastify ×1
html ×1
javascript ×1
node.js ×1
types ×1