Skip to content

Commit f0ec97c

Browse files
committed
Add tests for alternative uses of @overload tag
1 parent 52a94ca commit f0ec97c

4 files changed

+327
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//// [jsFileAlternativeUseOfOverloadTag.js]
2+
// These are a few examples of existing alternative uses of @overload tag.
3+
// They will not work as expected with our implementation, but we are
4+
// trying to make sure that our changes do not result in any crashes here.
5+
6+
const example1 = {
7+
/**
8+
* @overload Example1(value)
9+
* Creates Example1
10+
* @param value [String]
11+
*/
12+
constructor: function Example1(value, options) {},
13+
};
14+
15+
const example2 = {
16+
/**
17+
* Example 2
18+
*
19+
* @overload Example2(value)
20+
* Creates Example2
21+
* @param value [String]
22+
* @param secretAccessKey [String]
23+
* @param sessionToken [String]
24+
* @example Creates with string value
25+
* const example = new Example('');
26+
* @overload Example2(options)
27+
* Creates Example2
28+
* @option options value [String]
29+
* @example Creates with options object
30+
* const example = new Example2({
31+
* value: '',
32+
* });
33+
*/
34+
constructor: function Example2() {},
35+
};
36+
37+
const example3 = {
38+
/**
39+
* @overload evaluate(options = {}, [callback])
40+
* Evaluate something
41+
* @note Something interesting
42+
* @param options [map]
43+
* @return [string] returns evaluation result
44+
* @return [null] returns nothing if callback provided
45+
* @callback callback function (error, result)
46+
* If callback is provided it will be called with evaluation result
47+
* @param error [Error]
48+
* @param result [String]
49+
* @see callback
50+
*/
51+
evaluate: function evaluate(options, callback) {},
52+
};
53+
54+
55+
//// [jsFileAlternativeUseOfOverloadTag.js]
56+
// These are a few examples of existing alternative uses of @overload tag.
57+
// They will not work as expected with our implementation, but we are
58+
// trying to make sure that our changes do not result in any crashes here.
59+
var example1 = {
60+
/**
61+
* @overload Example1(value)
62+
* Creates Example1
63+
* @param value [String]
64+
*/
65+
constructor: function Example1(value, options) { }
66+
};
67+
var example2 = {
68+
/**
69+
* Example 2
70+
*
71+
* @overload Example2(value)
72+
* Creates Example2
73+
* @param value [String]
74+
* @param secretAccessKey [String]
75+
* @param sessionToken [String]
76+
* @example Creates with string value
77+
* const example = new Example('');
78+
* @overload Example2(options)
79+
* Creates Example2
80+
* @option options value [String]
81+
* @example Creates with options object
82+
* const example = new Example2({
83+
* value: '',
84+
* });
85+
*/
86+
constructor: function Example2() { }
87+
};
88+
var example3 = {
89+
/**
90+
* @overload evaluate(options = {}, [callback])
91+
* Evaluate something
92+
* @note Something interesting
93+
* @param options [map]
94+
* @return [string] returns evaluation result
95+
* @return [null] returns nothing if callback provided
96+
* @callback callback function (error, result)
97+
* If callback is provided it will be called with evaluation result
98+
* @param error [Error]
99+
* @param result [String]
100+
* @see callback
101+
*/
102+
evaluate: function evaluate(options, callback) { }
103+
};
104+
105+
106+
//// [jsFileAlternativeUseOfOverloadTag.d.ts]
107+
declare namespace example1 {
108+
function constructor(value: any, options: any): void;
109+
}
110+
declare namespace example2 {
111+
export function constructor_1(): void;
112+
export { constructor_1 as constructor };
113+
}
114+
declare namespace example3 {
115+
function evaluate(options: any, callback: any): void;
116+
}
117+
/**
118+
* function (error, result)
119+
* If callback is provided it will be called with evaluation result
120+
*/
121+
type callback = (error: any, result: any) => any;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
=== tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.js ===
2+
// These are a few examples of existing alternative uses of @overload tag.
3+
// They will not work as expected with our implementation, but we are
4+
// trying to make sure that our changes do not result in any crashes here.
5+
6+
const example1 = {
7+
>example1 : Symbol(example1, Decl(jsFileAlternativeUseOfOverloadTag.js, 4, 5))
8+
9+
/**
10+
* @overload Example1(value)
11+
* Creates Example1
12+
* @param value [String]
13+
*/
14+
constructor: function Example1(value, options) {},
15+
>constructor : Symbol(constructor, Decl(jsFileAlternativeUseOfOverloadTag.js, 4, 18))
16+
>Example1 : Symbol(Example1, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 14))
17+
>value : Symbol(value, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 33))
18+
>options : Symbol(options, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 39))
19+
20+
};
21+
22+
const example2 = {
23+
>example2 : Symbol(example2, Decl(jsFileAlternativeUseOfOverloadTag.js, 13, 5))
24+
25+
/**
26+
* Example 2
27+
*
28+
* @overload Example2(value)
29+
* Creates Example2
30+
* @param value [String]
31+
* @param secretAccessKey [String]
32+
* @param sessionToken [String]
33+
* @example Creates with string value
34+
* const example = new Example('');
35+
* @overload Example2(options)
36+
* Creates Example2
37+
* @option options value [String]
38+
* @example Creates with options object
39+
* const example = new Example2({
40+
* value: '',
41+
* });
42+
*/
43+
constructor: function Example2() {},
44+
>constructor : Symbol(constructor, Decl(jsFileAlternativeUseOfOverloadTag.js, 13, 18))
45+
>Example2 : Symbol(Example2, Decl(jsFileAlternativeUseOfOverloadTag.js, 32, 14))
46+
47+
};
48+
49+
const example3 = {
50+
>example3 : Symbol(example3, Decl(jsFileAlternativeUseOfOverloadTag.js, 35, 5))
51+
52+
/**
53+
* @overload evaluate(options = {}, [callback])
54+
* Evaluate something
55+
* @note Something interesting
56+
* @param options [map]
57+
* @return [string] returns evaluation result
58+
* @return [null] returns nothing if callback provided
59+
* @callback callback function (error, result)
60+
* If callback is provided it will be called with evaluation result
61+
* @param error [Error]
62+
* @param result [String]
63+
* @see callback
64+
*/
65+
evaluate: function evaluate(options, callback) {},
66+
>evaluate : Symbol(evaluate, Decl(jsFileAlternativeUseOfOverloadTag.js, 35, 18))
67+
>evaluate : Symbol(evaluate, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 11))
68+
>options : Symbol(options, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 30))
69+
>callback : Symbol(callback, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 38))
70+
71+
};
72+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=== tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.js ===
2+
// These are a few examples of existing alternative uses of @overload tag.
3+
// They will not work as expected with our implementation, but we are
4+
// trying to make sure that our changes do not result in any crashes here.
5+
6+
const example1 = {
7+
>example1 : { constructor: (value: any, options: any) => void; }
8+
>{ /** * @overload Example1(value) * Creates Example1 * @param value [String] */ constructor: function Example1(value, options) {},} : { constructor: (value: any, options: any) => void; }
9+
10+
/**
11+
* @overload Example1(value)
12+
* Creates Example1
13+
* @param value [String]
14+
*/
15+
constructor: function Example1(value, options) {},
16+
>constructor : (value: any, options: any) => void
17+
>function Example1(value, options) {} : (value: any, options: any) => void
18+
>Example1 : (value: any, options: any) => void
19+
>value : any
20+
>options : any
21+
22+
};
23+
24+
const example2 = {
25+
>example2 : { constructor: () => void; }
26+
>{ /** * Example 2 * * @overload Example2(value) * Creates Example2 * @param value [String] * @param secretAccessKey [String] * @param sessionToken [String] * @example Creates with string value * const example = new Example(''); * @overload Example2(options) * Creates Example2 * @option options value [String] * @example Creates with options object * const example = new Example2({ * value: '', * }); */ constructor: function Example2() {},} : { constructor: () => void; }
27+
28+
/**
29+
* Example 2
30+
*
31+
* @overload Example2(value)
32+
* Creates Example2
33+
* @param value [String]
34+
* @param secretAccessKey [String]
35+
* @param sessionToken [String]
36+
* @example Creates with string value
37+
* const example = new Example('');
38+
* @overload Example2(options)
39+
* Creates Example2
40+
* @option options value [String]
41+
* @example Creates with options object
42+
* const example = new Example2({
43+
* value: '',
44+
* });
45+
*/
46+
constructor: function Example2() {},
47+
>constructor : () => void
48+
>function Example2() {} : () => void
49+
>Example2 : () => void
50+
51+
};
52+
53+
const example3 = {
54+
>example3 : { evaluate: (options: any, callback: any) => void; }
55+
>{ /** * @overload evaluate(options = {}, [callback]) * Evaluate something * @note Something interesting * @param options [map] * @return [string] returns evaluation result * @return [null] returns nothing if callback provided * @callback callback function (error, result) * If callback is provided it will be called with evaluation result * @param error [Error] * @param result [String] * @see callback */ evaluate: function evaluate(options, callback) {},} : { evaluate: (options: any, callback: any) => void; }
56+
57+
/**
58+
* @overload evaluate(options = {}, [callback])
59+
* Evaluate something
60+
* @note Something interesting
61+
* @param options [map]
62+
* @return [string] returns evaluation result
63+
* @return [null] returns nothing if callback provided
64+
* @callback callback function (error, result)
65+
* If callback is provided it will be called with evaluation result
66+
* @param error [Error]
67+
* @param result [String]
68+
* @see callback
69+
*/
70+
evaluate: function evaluate(options, callback) {},
71+
>evaluate : (options: any, callback: any) => void
72+
>function evaluate(options, callback) {} : (options: any, callback: any) => void
73+
>evaluate : (options: any, callback: any) => void
74+
>options : any
75+
>callback : any
76+
77+
};
78+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// @allowJs: true
2+
// @outDir: dist/
3+
// @declaration: true
4+
// @filename: jsFileAlternativeUseOfOverloadTag.js
5+
6+
// These are a few examples of existing alternative uses of @overload tag.
7+
// They will not work as expected with our implementation, but we are
8+
// trying to make sure that our changes do not result in any crashes here.
9+
10+
const example1 = {
11+
/**
12+
* @overload Example1(value)
13+
* Creates Example1
14+
* @param value [String]
15+
*/
16+
constructor: function Example1(value, options) {},
17+
};
18+
19+
const example2 = {
20+
/**
21+
* Example 2
22+
*
23+
* @overload Example2(value)
24+
* Creates Example2
25+
* @param value [String]
26+
* @param secretAccessKey [String]
27+
* @param sessionToken [String]
28+
* @example Creates with string value
29+
* const example = new Example('');
30+
* @overload Example2(options)
31+
* Creates Example2
32+
* @option options value [String]
33+
* @example Creates with options object
34+
* const example = new Example2({
35+
* value: '',
36+
* });
37+
*/
38+
constructor: function Example2() {},
39+
};
40+
41+
const example3 = {
42+
/**
43+
* @overload evaluate(options = {}, [callback])
44+
* Evaluate something
45+
* @note Something interesting
46+
* @param options [map]
47+
* @return [string] returns evaluation result
48+
* @return [null] returns nothing if callback provided
49+
* @callback callback function (error, result)
50+
* If callback is provided it will be called with evaluation result
51+
* @param error [Error]
52+
* @param result [String]
53+
* @see callback
54+
*/
55+
evaluate: function evaluate(options, callback) {},
56+
};

0 commit comments

Comments
 (0)