Skip to content

Instantly share code, notes, and snippets.

@ankitamasand
Created April 17, 2019 18:11
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 ankitamasand/ec963f8e3862e165f78fb8262cd6372f to your computer and use it in GitHub Desktop.
Save ankitamasand/ec963f8e3862e165f78fb8262cd6372f to your computer and use it in GitHub Desktop.
interface CarDelivery {
(string): TeslaModelS,
getCustomerDetails (): string,
price: number,
trackDelivery (): string
}
function manufactureCar (type: string): CarDelivery {
const model = <CarDelivery> function (type: string) {
// get the model of type as mentioned in the argument
}
model.getCustomerDetails = function () {
// get the details of customer who has purchased this model
return 'customer details'
}
model.price = 100000
model.trackDelivery = function () {
// track the delivery of the model
return 'tracking address'
}
return model
}
let tesla = manufactureCar('tesla')
tesla() // tesla is a function
tesla.getCustomerDetails() // getCustomerDetails is a property defined on function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment