- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue
Description
TypeScript Version: 1.8.10
Code
// tl;dr: // This should give a static error, but does not.varmonkeyAnalyzer: (input: Monkey)=>void=(input: Monkey&Robot)=>{console.log(input.FurColor,input.MotorCount);}// Will definitely fail, as we can expect from the incompatible signatures of the declared type of monkeyAnalyzer and what we actually assign to itmonkeyAnalyzer(newMonkey());// Verbose exampleclassMonkey{publicFurColor: string;}classRobot{publicMotorCount: number;}classMonkeyRobotAnalyzer{publicstaticAnalyze=(input: Monkey&Robot): void=>{console.log(input.FurColor,input.MotorCount);}}classMonkeyManager{constructor(monkeyAnalyzer: (input: Monkey)=>void){monkeyAnalyzer(newMonkey());}}MonkeyRobotAnalyzer.Analyze(newMonkey());// Shows error as it shouldvarmyManager=newMonkeyManager(MonkeyRobotAnalyzer.Analyze);// No error, but should not be allowed, signature of MonkeyRobotAnalyzer.Analyze is not compatible with (input: Monkey) => voidExpected behavior:
The incompatible signatures should result in a static error
Actual behavior:
We get no static error
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue