![](/img/trans.png)
[英]Is there any way to target the plain JavaScript object type in TypeScript?
[英]How to type plain object in TypeScript
我想輸入 JavaScript 的普通 object,然后寫下:
interface PlainObject {
[k: string]: any;
}
但我發現:
type A = keyof PlainObject // string | number
interface PlainArray {
[k: number]: any;
}
type B = keyof PlainArray // number
問題一:為什么會這樣? 問題 2:我怎樣才能輸入一個普通的 object 像{ name: 'timi' }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.