forked from jashkenas/coffeescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesired-output.coffee
110 lines (98 loc) · 1.69 KB
/
desired-output.coffee
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# This file contains desired syntax and desired output.
###
jsdoc:
/**
* @type {(x: number) => number}
* /
var f;
/**
* @param {number} x
* @returns {number}
* /
f = function(x) {
return x + 3;
}
.d.ts:
/**
* @type {(x: number) => number}
* /
declare var f: (x: number) => number;
###
# f<[=> number]> = (x<[number]>) -> x + 3
# f<[(x: number) => number]> = (x) -> x + 3
f = (x) -> x + 3
###
jsdoc:
/**
* @type {{a: number}}
* /
var x;
x = {
a: 3
};
.d.ts:
/**
* @type {{a: number}}
* /
declare var x: {
a: number;
};
###
# x = {a<[number]>: 3}
# x<[{a: number}]> = {a: 3}
x = {a: 3}
###
jsdoc:
/**
* @type {({a}: {a: string}) => string}
* /
var g;
/**
* @param {{a: string}} _
* @returns {string}
* /
g = function({a: x}) {
return x;
}
.d.ts:
/**
* @type {({a}: {a: string}) => string}
* /
declare var g: ({ a }: {
a: string;
}) => string;
###
# g<[=> string]> = ({a<[string]>: x}) -> x
# this one does not rename the field:
# g<[=> string]> = ({a<[string]>}) -> a
g = ({a: x}) -> x
###
jsdoc:
/**
* @type {({a, b, c, e}: {a: number, b?: number, c: {d?: number}, e: [f: number]}) => number}
* /
var h;
/**
* @param {{a: number, b?: number, c: {d?: number}, e: [f: number]}} _
* @returns number
* /
h = function({a, b = 3, c: {d = 3}, e: [f]}) {
return a + b + d;
};
.d.ts:
/**
* @type {({a, b, c, e}: {a: number, b?: number, c: {d?: number}, e: [f: number]}) => number}
* /
declare var h: ({ a, b, c, e }: {
a: number;
b?: number;
c: {
d?: number;
};
e: [f: number];
}) => number;
###
# h<[=> number]> = ({a<[number]>, b<[?number]> = 3, c: {d<[?number]> = 3}, e: [f<[number]>]}) ->
# a + b + d
h = ({a, b = 3, c: {d = 3}, e: [f]}) ->
a + b + d + f