-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for alternative uses of @overload tag
- Loading branch information
Showing
4 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
tests/baselines/reference/jsFileAlternativeUseOfOverloadTag.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
//// [jsFileAlternativeUseOfOverloadTag.js] | ||
// These are a few examples of existing alternative uses of @overload tag. | ||
// They will not work as expected with our implementation, but we are | ||
// trying to make sure that our changes do not result in any crashes here. | ||
|
||
const example1 = { | ||
/** | ||
* @overload Example1(value) | ||
* Creates Example1 | ||
* @param value [String] | ||
*/ | ||
constructor: function Example1(value, options) {}, | ||
}; | ||
|
||
const example2 = { | ||
/** | ||
* 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() {}, | ||
}; | ||
|
||
const example3 = { | ||
/** | ||
* @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) {}, | ||
}; | ||
|
||
|
||
//// [jsFileAlternativeUseOfOverloadTag.js] | ||
// These are a few examples of existing alternative uses of @overload tag. | ||
// They will not work as expected with our implementation, but we are | ||
// trying to make sure that our changes do not result in any crashes here. | ||
var example1 = { | ||
/** | ||
* @overload Example1(value) | ||
* Creates Example1 | ||
* @param value [String] | ||
*/ | ||
constructor: function Example1(value, options) { } | ||
}; | ||
var example2 = { | ||
/** | ||
* 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() { } | ||
}; | ||
var example3 = { | ||
/** | ||
* @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) { } | ||
}; | ||
|
||
|
||
//// [jsFileAlternativeUseOfOverloadTag.d.ts] | ||
declare namespace example1 { | ||
function constructor(value: any, options: any): void; | ||
} | ||
declare namespace example2 { | ||
export function constructor_1(): void; | ||
export { constructor_1 as constructor }; | ||
} | ||
declare namespace example3 { | ||
function evaluate(options: any, callback: any): void; | ||
} | ||
/** | ||
* function (error, result) | ||
* If callback is provided it will be called with evaluation result | ||
*/ | ||
type callback = (error: any, result: any) => any; |
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/jsFileAlternativeUseOfOverloadTag.symbols
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
=== tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.js === | ||
// These are a few examples of existing alternative uses of @overload tag. | ||
// They will not work as expected with our implementation, but we are | ||
// trying to make sure that our changes do not result in any crashes here. | ||
|
||
const example1 = { | ||
>example1 : Symbol(example1, Decl(jsFileAlternativeUseOfOverloadTag.js, 4, 5)) | ||
|
||
/** | ||
* @overload Example1(value) | ||
* Creates Example1 | ||
* @param value [String] | ||
*/ | ||
constructor: function Example1(value, options) {}, | ||
>constructor : Symbol(constructor, Decl(jsFileAlternativeUseOfOverloadTag.js, 4, 18)) | ||
>Example1 : Symbol(Example1, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 14)) | ||
>value : Symbol(value, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 33)) | ||
>options : Symbol(options, Decl(jsFileAlternativeUseOfOverloadTag.js, 10, 39)) | ||
|
||
}; | ||
|
||
const example2 = { | ||
>example2 : Symbol(example2, Decl(jsFileAlternativeUseOfOverloadTag.js, 13, 5)) | ||
|
||
/** | ||
* 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 : Symbol(constructor, Decl(jsFileAlternativeUseOfOverloadTag.js, 13, 18)) | ||
>Example2 : Symbol(Example2, Decl(jsFileAlternativeUseOfOverloadTag.js, 32, 14)) | ||
|
||
}; | ||
|
||
const example3 = { | ||
>example3 : Symbol(example3, Decl(jsFileAlternativeUseOfOverloadTag.js, 35, 5)) | ||
|
||
/** | ||
* @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 : Symbol(evaluate, Decl(jsFileAlternativeUseOfOverloadTag.js, 35, 18)) | ||
>evaluate : Symbol(evaluate, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 11)) | ||
>options : Symbol(options, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 30)) | ||
>callback : Symbol(callback, Decl(jsFileAlternativeUseOfOverloadTag.js, 49, 38)) | ||
|
||
}; | ||
|
78 changes: 78 additions & 0 deletions
78
tests/baselines/reference/jsFileAlternativeUseOfOverloadTag.types
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
=== tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.js === | ||
// These are a few examples of existing alternative uses of @overload tag. | ||
// They will not work as expected with our implementation, but we are | ||
// trying to make sure that our changes do not result in any crashes here. | ||
|
||
const example1 = { | ||
>example1 : { constructor: (value: any, options: any) => void; } | ||
>{ /** * @overload Example1(value) * Creates Example1 * @param value [String] */ constructor: function Example1(value, options) {},} : { constructor: (value: any, options: any) => void; } | ||
|
||
/** | ||
* @overload Example1(value) | ||
* Creates Example1 | ||
* @param value [String] | ||
*/ | ||
constructor: function Example1(value, options) {}, | ||
>constructor : (value: any, options: any) => void | ||
>function Example1(value, options) {} : (value: any, options: any) => void | ||
>Example1 : (value: any, options: any) => void | ||
>value : any | ||
>options : any | ||
|
||
}; | ||
|
||
const example2 = { | ||
>example2 : { constructor: () => void; } | ||
>{ /** * 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; } | ||
|
||
/** | ||
* 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 | ||
>function Example2() {} : () => void | ||
>Example2 : () => void | ||
|
||
}; | ||
|
||
const example3 = { | ||
>example3 : { evaluate: (options: any, callback: any) => void; } | ||
>{ /** * @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; } | ||
|
||
/** | ||
* @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 | ||
>function evaluate(options, callback) {} : (options: any, callback: any) => void | ||
>evaluate : (options: any, callback: any) => void | ||
>options : any | ||
>callback : any | ||
|
||
}; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @allowJs: true | ||
// @outDir: dist/ | ||
// @declaration: true | ||
// @filename: jsFileAlternativeUseOfOverloadTag.js | ||
|
||
// These are a few examples of existing alternative uses of @overload tag. | ||
// They will not work as expected with our implementation, but we are | ||
// trying to make sure that our changes do not result in any crashes here. | ||
|
||
const example1 = { | ||
/** | ||
* @overload Example1(value) | ||
* Creates Example1 | ||
* @param value [String] | ||
*/ | ||
constructor: function Example1(value, options) {}, | ||
}; | ||
|
||
const example2 = { | ||
/** | ||
* 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() {}, | ||
}; | ||
|
||
const example3 = { | ||
/** | ||
* @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) {}, | ||
}; |