Last active
November 17, 2021 19:53
-
-
Save michaelpanik/8327c796e12f5e9867ac5a883a002711 to your computer and use it in GitHub Desktop.
TypeScript Talk Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IParadeParticipant { | |
position: number | |
} | |
interface IParadeFloat extends IParadeParticipant { | |
sponsor: string | |
performers: string[] | |
} | |
interface IParadeBaloon extends IParadeParticipant { | |
character: string | |
numberOfHandlers: number | |
animated: boolean | |
} | |
interface IParadeMarchingBand extends IParadeParticipant { | |
performers: Performer[] | |
} | |
type ParadeElement = IParadeFloat | IParadeBaloon | IParadeMarchingBand | |
interface IParade = { | |
participants: ParadeElement[] | |
} | |
type ParadePerformers = Extract<ParadeElement, any[]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IParade, ParadeElement } from "./parade.d" | |
class Parade implements IParade { | |
participants: ParadeElement[] = []; | |
public addParticipant(participant: ParadeElement) { | |
participant.position = this.participants.length; | |
this.participants.push(participant); | |
} | |
} | |
export default Parade; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment