-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version:
1.9.0-dev.20160505
with both strictNullChecks
and noImplicitAny
enabled.
Code:
class Animal {
name: string = "Any animal";
}
class Dog extends Animal {
name: string = "Dog";
bark() {
console.log("bark");
}
}
class AnimalCage {
member: Animal = new Animal();
}
class DogCage extends AnimalCage {
member: Dog;
}
let dogCage = new DogCage();
if (dogCage.member != null) { // Yup, it is even checked for null or undefined,
// but it turned out that wasn't enough..
dogCage.member.bark(); // Bang!
}
Expected behavior:
Design a language where inheritance actually works.
(Edit: I was felling very 'passionate' when I wrote this.. sorry :) nothing personal)
Actual behavior:
By design:
dogCage.member.bark();
^
TypeError: dogCage.member.bark is not a function
at Object.<anonymous> (C:\X\Documents\Drafts\TypeScript\Code\a.js:38:20)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:159:18)
at node.js:444:3
Resolution:
tslint
volunteers, for the rescue!
Asvarduil and ClementNermaandersekdahl
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript