首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

(八)interfacetype 区别

# interfacetype 区别 说明 interface 可扩展 type 不好扩展,后者是不方便扩展 # interface 扩展 说明 比如说我们现在正在编写一个公共类库,允许程序员来基础上进行扩展...,或者是自定义,这个时候就需要使用 interface 扩展语法,定义一个和原有的 interface 一样的类型,里面添加上自己需要的属性就可以了 interface Product { title...: string price: number isStock: boolean } // 扩展 interface 添加一个新的属性数量 interface product {...定义的话 type Product = { title: string } // 此时这里就会报错,说不能定义重复的 type type Procuct = { price: number...} # 总结-写在最后 总结 在我们日常开发中推荐首选 interface ,因为他可扩展性好

26920
领券