Created
October 27, 2016 21:56
-
-
Save chrisnicola/918f1f0cf3ddf35df2a354514edbf15a to your computer and use it in GitHub Desktop.
Type inference limitations for Typescript
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
class TypeOne { | |
public one | |
private two | |
private three | |
} | |
class TypeTwo { | |
public one | |
} | |
// Calling a function that requests TypeTwo with a value of TypeOne works | |
function thisWorks(value: TypeTwo) { return "Worked!" } | |
thisWorks(new TypeOne()) | |
// Calling a function that requests TypeOne with a value of TypeTwo results in a compile error | |
function thisFails(value: TypeOne) { return "Failed!" } | |
thisFails(new TypeTwo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment