Typescript WTF Moments 9:不断发展的空数组类型
const a = false || []
// ^?
const b = []
// ^?
function c() {
// ^?
return []
}
con
const a = false || []
// ^?
const b = []
// ^?
function c() {
// ^?
return []
}
con
观察下面的例子: type A = boolean; type B = string; type C<T extends B> = {
type ABC = { A: number, B: number } | { C: number
const a = false || [] // ^? const b = [] // ^? function c() {
type o = boolean extends Record<infer X, unknown> ? X : false // valueOf // ^?
相同类型的对象联合不会崩溃 type a = 1 | 1 // 1, collapsed // ^? type b = {
相同类型的对象联合不会崩溃 type a = 1 | 1 // 1, collapsed // ^? type b = {
type a = never extends `${ infer P}` ? P : 1 // never //
const a = 'a' const obj = { [a]:1 } // {a:1} const b =
这个系列是关于我在 Typescript 中遇到的困惑,不直观,难以推理或需要额外注意的事情。 警告的原因可能是由于错误或缺陷或只是按预期工作 我会不时地为这个系列添加新的
typescript重要吗 If you hang around in the JavaScript community, along with `left-pad` you
还没有评论,来说两句吧...