-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.test.js
48 lines (35 loc) · 999 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* @flow */
import type { Arity } from '..'
(() => {
const sum = (a: number, b: number): number => a + b
declare var arity: Arity<typeof sum>
;(arity: 2) // ok
/**
* $ExpectError
*
* Cannot cast `arity` to number literal `3` because number literal `2` [1] is incompatible with number literal `3` [2]
*/
;(arity: 3) // error
})()
;(() => {
const sum = (a: number, b: ?number = 0): number => a + b
declare var arity: Arity<typeof sum>
;(arity: 2) // ok
/**
* $ExpectError
*
* Cannot cast `arity` to number literal `3` because number literal `2` [1] is incompatible with number literal `3` [2]
*/
;(arity: 3) // error
})()
;(() => {
const sum = (): number => 0
declare var arity: Arity<typeof sum>
;(arity: 0) // ok
/**
* $ExpectError
*
* Cannot cast `arity` to number literal `3` because number literal `2` [1] is incompatible with number literal `3` [2]
*/
;(arity: 1) // error
})()