better types that work

`ImporterReturnType` is a union of all the possible return values.
The function signature works for both sync and async varieties, and in truth both can be used at the same time (I've tried it) so this is great.
This commit is contained in:
Gilad Gray
2016-11-22 23:55:07 -08:00
committed by GitHub
parent 5b78db64d3
commit adcd8272d7

View File

@@ -8,8 +8,7 @@
type ImporterReturnType = { file: string } | { contents: string } | Error | null;
interface Importer {
(url: string, prev: string): ImporterReturnType;
(url: string, prev: string, done: (data: ImporterReturnType) => void): void;
(url: string, prev: string, done: (data: ImporterReturnType) => void): ImporterReturnType | void;
}
interface Options {