當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
TypeScript里的interface扩展,多继承以及对应的JavaScript代码
生活随笔
收集整理的這篇文章主要介紹了
TypeScript里的interface扩展,多继承以及对应的JavaScript代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
TypeScript
interface Shape {color: string; }interface Square extends Shape {sideLength: number; }let square = <Square>{}; square.color = "blue"; square.sideLength = 10;對應生成的JavaScript:
var square = {}; square.color = "blue"; square.sideLength = 10;TypeScript
interface Shape {color: string; }interface PenStroke {penWidth: number; }interface Square extends Shape, PenStroke {sideLength: number; }let square = <Square>{}; square.color = "blue"; square.sideLength = 10; square.penWidth = 5.0;對應的JavaScript代碼:
var square = {}; square.color = "blue"; square.sideLength = 10; square.penWidth = 5.0;extends ___ = ___ syntax in typescript
export interface ActionReducer<T, V extends Action = Action> {(state: T | undefined, action: V): T; }It specifies the default type of V . so V can be either a class which extends Action or if not mentioned will be of type Action.
參考鏈接
總結
以上是生活随笔為你收集整理的TypeScript里的interface扩展,多继承以及对应的JavaScript代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【转】利用syslinux制作Dos、W
- 下一篇: 使用Chrome开发者工具研究JavaS