Last active
December 20, 2016 11:33
-
-
Save mkusher/946d2958692e712ff60ab03c8a2b1133 to your computer and use it in GitHub Desktop.
TypeScript typings example for cucumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { World } from "support/World"; | |
export namespace cucumber { | |
type Step = RegExp|string; | |
interface StepCallback extends Function { | |
(this: World, ...args: any[]): void|Promise<any>; | |
} | |
export interface Feature { | |
Given(step: Step, callback: StepCallback): void; | |
When(step: Step, callback: StepCallback): void; | |
Then(step: Step, callback: StepCallback): void; | |
After(callback: Function): void; | |
Before(callback: Function): void; | |
} | |
export interface FeatureContext { | |
(this: Feature): void; | |
} | |
export interface Callback { | |
(err?: any, type?: string): void; | |
} | |
export interface Table { | |
hashes<T>(): T[]; | |
rows(): string[][]; | |
raw(): string[][]; | |
rowsHash(): { [key: string]: string }; | |
rowsHash<T>(): T; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cucumber } from "somewhere"; // or you could add it to global namespace | |
const steps: cucumber.FeatureContext = function() { | |
// here this has type Feature from cucumber namespace | |
this.Given("test", function() { | |
// here this has type World | |
}); | |
}; | |
export default steps; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment