-
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.
Reuse
getEffectiveTypeParameterHost
in `isTypeParameterPossiblyRefe…
…renced`
- Loading branch information
Showing
4 changed files
with
244 additions
and
9 deletions.
There are no files selected for viewing
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
70 changes: 70 additions & 0 deletions
70
tests/baselines/reference/inferFromReturnOfContextSensitiveFnJsDoc1.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,70 @@ | ||
//// [tests/cases/compiler/inferFromReturnOfContextSensitiveFnJsDoc1.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @template S | ||
* @param {(arg0: { observer: EO }) => S} callback | ||
* @param {Options} [options] | ||
* @returns {VC<S>} | ||
*/ | ||
/* | ||
* @type { <S>(fn: (arg0: { observer: EO; }) => S, options?: Options) => VC<S> } | ||
*/ | ||
function define(callback, options) { | ||
>define : Symbol(define, Decl(index.js, 0, 0)) | ||
>callback : Symbol(callback, Decl(index.js, 9, 16)) | ||
>options : Symbol(options, Decl(index.js, 9, 25)) | ||
|
||
const { name } = options ?? {}; | ||
>name : Symbol(name, Decl(index.js, 10, 9)) | ||
>options : Symbol(options, Decl(index.js, 9, 25)) | ||
|
||
const observer = new EO(); | ||
>observer : Symbol(observer, Decl(index.js, 11, 7)) | ||
>EO : Symbol(EO, Decl(index.js, 28, 1)) | ||
|
||
const state = callback({ observer }); | ||
>state : Symbol(state, Decl(index.js, 12, 7)) | ||
>callback : Symbol(callback, Decl(index.js, 9, 16)) | ||
>observer : Symbol(observer, Decl(index.js, 12, 26)) | ||
|
||
return new VC(state); | ||
>VC : Symbol(VC, Decl(index.js, 14, 1)) | ||
>state : Symbol(state, Decl(index.js, 12, 7)) | ||
} | ||
|
||
/** | ||
* @template S | ||
*/ | ||
class VC { | ||
>VC : Symbol(VC, Decl(index.js, 14, 1)) | ||
|
||
/** @type {S} */ | ||
state; | ||
>state : Symbol(VC.state, Decl(index.js, 19, 10)) | ||
|
||
/** | ||
* @param {S} state | ||
*/ | ||
constructor(state) { | ||
>state : Symbol(state, Decl(index.js, 25, 14)) | ||
|
||
this.state = state; | ||
>this.state : Symbol(VC.state, Decl(index.js, 19, 10)) | ||
>this : Symbol(VC, Decl(index.js, 14, 1)) | ||
>state : Symbol(VC.state, Decl(index.js, 19, 10)) | ||
>state : Symbol(state, Decl(index.js, 25, 14)) | ||
} | ||
} | ||
|
||
/** @typedef {{ name?: string }} Options */ | ||
|
||
class EO {} | ||
>EO : Symbol(EO, Decl(index.js, 28, 1)) | ||
|
||
const v1 = define((arg0) => true, { name: "default" }); | ||
>v1 : Symbol(v1, Decl(index.js, 34, 5)) | ||
>define : Symbol(define, Decl(index.js, 0, 0)) | ||
>arg0 : Symbol(arg0, Decl(index.js, 34, 19)) | ||
>name : Symbol(name, Decl(index.js, 34, 35)) | ||
|
118 changes: 118 additions & 0 deletions
118
tests/baselines/reference/inferFromReturnOfContextSensitiveFnJsDoc1.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,118 @@ | ||
//// [tests/cases/compiler/inferFromReturnOfContextSensitiveFnJsDoc1.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @template S | ||
* @param {(arg0: { observer: EO }) => S} callback | ||
* @param {Options} [options] | ||
* @returns {VC<S>} | ||
*/ | ||
/* | ||
* @type { <S>(fn: (arg0: { observer: EO; }) => S, options?: Options) => VC<S> } | ||
*/ | ||
function define(callback, options) { | ||
>define : <S>(callback: (arg0: { observer: EO; }) => S, options?: Options) => VC<S> | ||
> : ^ ^^ ^^ ^^ ^^^ ^^^^^ | ||
>callback : (arg0: { observer: EO; }) => S | ||
> : ^ ^^ ^^^^^ | ||
>options : Options | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
|
||
const { name } = options ?? {}; | ||
>name : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>options ?? {} : Options | ||
> : ^^^^^^^ | ||
>options : Options | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
||
const observer = new EO(); | ||
>observer : EO | ||
> : ^^ | ||
>new EO() : EO | ||
> : ^^ | ||
>EO : typeof EO | ||
> : ^^^^^^^^^ | ||
|
||
const state = callback({ observer }); | ||
>state : S | ||
> : ^ | ||
>callback({ observer }) : S | ||
> : ^ | ||
>callback : (arg0: { observer: EO; }) => S | ||
> : ^ ^^ ^^^^^ | ||
>{ observer } : { observer: EO; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>observer : EO | ||
> : ^^ | ||
|
||
return new VC(state); | ||
>new VC(state) : VC<S> | ||
> : ^^^^^ | ||
>VC : typeof VC | ||
> : ^^^^^^^^^ | ||
>state : S | ||
> : ^ | ||
} | ||
|
||
/** | ||
* @template S | ||
*/ | ||
class VC { | ||
>VC : VC<S> | ||
> : ^^^^^ | ||
|
||
/** @type {S} */ | ||
state; | ||
>state : S | ||
> : ^ | ||
|
||
/** | ||
* @param {S} state | ||
*/ | ||
constructor(state) { | ||
>state : S | ||
> : ^ | ||
|
||
this.state = state; | ||
>this.state = state : S | ||
> : ^ | ||
>this.state : S | ||
> : ^ | ||
>this : this | ||
> : ^^^^ | ||
>state : S | ||
> : ^ | ||
>state : S | ||
> : ^ | ||
} | ||
} | ||
|
||
/** @typedef {{ name?: string }} Options */ | ||
|
||
class EO {} | ||
>EO : EO | ||
> : ^^ | ||
|
||
const v1 = define((arg0) => true, { name: "default" }); | ||
>v1 : VC<boolean> | ||
> : ^^^^^^^^^^^ | ||
>define((arg0) => true, { name: "default" }) : VC<boolean> | ||
> : ^^^^^^^^^^^ | ||
>define : <S>(callback: (arg0: { observer: EO; }) => S, options?: Options) => VC<S> | ||
> : ^ ^^ ^^ ^^ ^^^ ^^^^^ | ||
>(arg0) => true : (arg0: { observer: EO; }) => boolean | ||
> : ^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ | ||
>arg0 : { observer: EO; } | ||
> : ^^^^^^^^^^^^ ^^^ | ||
>true : true | ||
> : ^^^^ | ||
>{ name: "default" } : { name: string; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>name : string | ||
> : ^^^^^^ | ||
>"default" : "default" | ||
> : ^^^^^^^^^ | ||
|
42 changes: 42 additions & 0 deletions
42
tests/cases/compiler/inferFromReturnOfContextSensitiveFnJsDoc1.ts
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,42 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
// @checkJs: true | ||
// @allowJs: true | ||
|
||
// @filename: index.js | ||
|
||
/** | ||
* @template S | ||
* @param {(arg0: { observer: EO }) => S} callback | ||
* @param {Options} [options] | ||
* @returns {VC<S>} | ||
*/ | ||
/* | ||
* @type { <S>(fn: (arg0: { observer: EO; }) => S, options?: Options) => VC<S> } | ||
*/ | ||
function define(callback, options) { | ||
const { name } = options ?? {}; | ||
const observer = new EO(); | ||
const state = callback({ observer }); | ||
return new VC(state); | ||
} | ||
|
||
/** | ||
* @template S | ||
*/ | ||
class VC { | ||
/** @type {S} */ | ||
state; | ||
/** | ||
* @param {S} state | ||
*/ | ||
constructor(state) { | ||
this.state = state; | ||
} | ||
} | ||
|
||
/** @typedef {{ name?: string }} Options */ | ||
|
||
class EO {} | ||
|
||
const v1 = define((arg0) => true, { name: "default" }); |