Skip to content

Instantly share code, notes, and snippets.

@michaelpanik
Last active November 17, 2021 19:53
Show Gist options
  • Save michaelpanik/8327c796e12f5e9867ac5a883a002711 to your computer and use it in GitHub Desktop.
Save michaelpanik/8327c796e12f5e9867ac5a883a002711 to your computer and use it in GitHub Desktop.
TypeScript Talk Examples
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[]>
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