by TheDong · 6y ago · 0 comments
I thought typescript also used structural subtyping? i.e. in typescript I can define:
interface Stringer {
String: () => string
}
function takesStringer(s: Stringer) {}
And now I can call takesStringer with any class that happens to have a String() method.This seems to match structural subtyping in go.
Am I missing some reason that this isn't structural subtyping as referred to in the paper? Do they mean to say that typescript isn't a "mainstream typed programming language"?
I assume they're not considering it because typescript compiles to javascript, so it doesn't have the problem Go faces of how to generate code for its generics. The wording is definitely weird though.