想要使用typescript定義一個對象,對象中可以有任意屬性,但是在訪問屬性的時候會報錯,顯示Property "a" does not exist on type Object,請問有方法可以定義這樣一個對象嗎?type Options = { data: Object}const v: Options = { data: { a: 1, b: 2 }}v.data.a// Property "a" does not exist on type Object
typescript對象字面量類型定義
繁星coding
2018-11-13 17:21:33