Skip to content

Instantly share code, notes, and snippets.

@levino
Created December 19, 2018 08:54
Show Gist options
  • Save levino/caca90056d6d73821d722d811c346542 to your computer and use it in GitHub Desktop.
Save levino/caca90056d6d73821d722d811c346542 to your computer and use it in GitHub Desktop.
Example for linting rules.
type standardFunction = (arg1: number, arg2: number) => number
// Should be okay
const add: standardFunction = (arg1, arg2) => arg1 + arg2 // Types can be inferred from 'standardFunction'
const addLater = (
arg1: number,
arg2: number
): (() => Promise<number>) => async () => arg1 + arg2 // Return type of promise can be inferred from type definition of 'addLater'
// Should not be okay
const add2 = (arg1: number, arg2: number) => arg1 + arg2 // Return type is not explictly declared.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment