Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active June 13, 2018 11:34
Show Gist options
  • Save kevinchisholm/db355d4765660b7d7bf073bd1bc4fe57 to your computer and use it in GitHub Desktop.
Save kevinchisholm/db355d4765660b7d7bf073bd1bc4fe57 to your computer and use it in GitHub Desktop.
class Vehicle {
name: string;
}
class Car extends Vehicle{
type: string;
}
class Computer {
brand: string;
}
let cars: Array<Car> = [];
cars[0] = new Car();
cars[1] = new Car();
console.dir(cars); // [Car:{}, Car:{}]
class Vehicle {
name: string;
}
class Car extends Vehicle{
type: string;
}
class Computer {
brand: string;
}
let cars: Array<Car> = [];
cars[0] = new Car();
cars[1] = new Computer(); //throws a typescript error: "Type 'Computer' is not assignable to type 'Car'" / "Property 'type' is missing in type 'Computer'"
console.dir(cars);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment