TypeScript/tests/baselines/reference/callbackTag2.types
Nathan Shively-Sanders bd7b97ce61
Get return type from @type tag (#25580)
* Get return type from `@type` tag

This only happens in the checker, where the type is easily accessible.
The syntax-based check in getEffectiveReturnTypeNode as a fast path, and
for other uses that don't want to make a call to getTypeFromTypeNode.

Fixes #25525

* Implement PR suggestions

* Error when type tag isn't callable

* Fix lint
2018-07-12 10:49:41 -07:00

60 lines
1.4 KiB
Text

=== tests/cases/conformance/jsdoc/cb.js ===
/** @template T
* @callback Id
* @param {T} t
* @returns {T} Maybe just return 120 and cast it?
*/
var x = 1
>x : number
>1 : 1
/** @type {Id<string>} I actually wanted to write `const "120"` */
var one_twenty = s => "120";
>one_twenty : Id<string>
>s => "120" : (s: string) => string
>s : string
>"120" : "120"
/** @template S
* @callback SharedId
* @param {S} ego
* @return {S}
*/
class SharedClass {
>SharedClass : SharedClass
constructor() {
/** @type {SharedId<S>} */
this.id;
>this.id : SharedId<any>
>this : this
>id : SharedId<any>
}
}
/** @type {SharedId<number>} */
var outside = n => n + 1;
>outside : SharedId<number>
>n => n + 1 : (n: number) => number
>n : number
>n + 1 : number
>n : number
>1 : 1
/** @type {Final<{ fantasy }, { heroes }>} */
var noreturn = (barts, tidus, noctis) => "cecil"
>noreturn : Final<{ fantasy: any; }, { heroes: any; }>
>(barts, tidus, noctis) => "cecil" : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" | "zidane"
>barts : { fantasy: any; }
>tidus : { heroes: any; }
>noctis : { heroes: any; } & { fantasy: any; }
>"cecil" : "cecil"
/**
* @template V,X
* @callback Final
* @param {V} barts - "Barts"
* @param {X} tidus - Titus
* @param {X & V} noctis - "Prince Noctis Lucius Caelum"
* @return {"cecil" | "zidane"}
*/