Skip to content

Instantly share code, notes, and snippets.

@christo
Created April 24, 2012 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christo/2478134 to your computer and use it in GitHub Desktop.
Save christo/2478134 to your computer and use it in GitHub Desktop.
roy compile error
// Strong
console.log 40 + 2
// Won't compile:
// console.log "40" + 2
// Explicit
let f x: Number = x
console.log (f 100)
// Won't compile:
//console.log (f "100")
type Person = {firstName: String, lastName: String, friend: Person}
let getName (x: Person) = x.firstName ++ " " ++ x.lastName
console.log (getName {firstName: "Brian", lastName: "McKenna"})
// Won't compile:
console.log (getName {firstName: "", lastName: "", friend: {firstName: "", lastName: ""}})
@jedws
Copy link

jedws commented Apr 24, 2012

// this is the worst form I've been able to see:
type Person = {first: String, last: String}
let p: Person = {first: "Fred", last: "dick"}
let getName (x: Person) = x.firstName ++ " " ++ x.lastName
console.log (getName p)

// Error: Type error on line 4: Person is not Person

EDIT: the code is actually wrong, but the error is unhelpful, the problem is that getName is calling non-existent firstName and lastName properties on Person

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment