Closed junosuarez closed 9 years ago
I ran into a similar problem. Except I have a type definition for functions which makes this harder
/* type Callback<T> := (Error, T) => void
type Continuable<T> := (Callback<T>) => void
mongo := (uri: String, options: Object?) => db: {
(Callback<Db>) => void,
collection: (name: String) => coll: {
Continuable<Collection>,
findOne: (selector: Object, options: Object?) => Continuable<Value>,
...
},
close: Continuable<void>
}
*/
For the resulting value from the mongo
function (whose name is db
) I have defined that it is a function that takes a callback and returns void.
I also defined it has two methods.
For the resulting value from collection
function (whose name is coll
) I've just said that the value is a continuable and it has at least one method.
I'm not sure which syntax I prefer.
I've been using
now : {
asDate: () => Date
} & () => Number
This says now
is a member of both { asData: Function }
and Function
.
If this is good enough for your use case please close this issue :)
Existing combinators > special-cased syntax. :+1:
This is even more reason to clarify #14 because I just found myself wanting to write
now : () => Number
& {
asDate : () => Date
}
@jden ;) I know. I wrote it the other way around for a reason :D
Given this:
I propose the following to describe
now
:An unnamed function signature at the top of the object type signature would be the callable function. Other, named properties would be properties on the function object.
Precedent: based loosely on the ES6 proposal for extended object literals.