-
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.
- Loading branch information
Showing
4 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/selfCallGenericJsDoc1.errors.txt
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,24 @@ | ||
index.js(13,42): error TS2345: Argument of type 'Children<T>' is not assignable to parameter of type 'any[]'. | ||
Type '{ children: Children<T>[] | undefined; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. | ||
|
||
|
||
==== index.js (1 errors) ==== | ||
/** | ||
* @template T | ||
* @typedef {T & { children: Children<T>[] | undefined }} Children | ||
*/ | ||
|
||
/** | ||
* @template T | ||
* @param {Children<T>[]} groups item and groups | ||
*/ | ||
export const spaceLimited = (groups) => { | ||
for (let i = 0; i < groups.length; i++) { | ||
const group = groups[i]; | ||
spaceLimited(/** @type {Children<T>} */(group.children)); // should error | ||
~~~~~~~~~~~~~~~~ | ||
!!! error TS2345: Argument of type 'Children<T>' is not assignable to parameter of type 'any[]'. | ||
!!! error TS2345: Type '{ children: Children<T>[] | undefined; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. | ||
} | ||
}; | ||
|
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,37 @@ | ||
//// [tests/cases/compiler/selfCallGenericJsDoc1.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @template T | ||
* @typedef {T & { children: Children<T>[] | undefined }} Children | ||
*/ | ||
|
||
/** | ||
* @template T | ||
* @param {Children<T>[]} groups item and groups | ||
*/ | ||
export const spaceLimited = (groups) => { | ||
>spaceLimited : Symbol(spaceLimited, Decl(index.js, 9, 12)) | ||
>groups : Symbol(groups, Decl(index.js, 9, 29)) | ||
|
||
for (let i = 0; i < groups.length; i++) { | ||
>i : Symbol(i, Decl(index.js, 10, 9)) | ||
>i : Symbol(i, Decl(index.js, 10, 9)) | ||
>groups.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) | ||
>groups : Symbol(groups, Decl(index.js, 9, 29)) | ||
>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) | ||
>i : Symbol(i, Decl(index.js, 10, 9)) | ||
|
||
const group = groups[i]; | ||
>group : Symbol(group, Decl(index.js, 11, 7)) | ||
>groups : Symbol(groups, Decl(index.js, 9, 29)) | ||
>i : Symbol(i, Decl(index.js, 10, 9)) | ||
|
||
spaceLimited(/** @type {Children<T>} */(group.children)); // should error | ||
>spaceLimited : Symbol(spaceLimited, Decl(index.js, 9, 12)) | ||
>group.children : Symbol(children, Decl(index.js, 2, 18)) | ||
>group : Symbol(group, Decl(index.js, 11, 7)) | ||
>children : Symbol(children, Decl(index.js, 2, 18)) | ||
} | ||
}; | ||
|
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,66 @@ | ||
//// [tests/cases/compiler/selfCallGenericJsDoc1.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @template T | ||
* @typedef {T & { children: Children<T>[] | undefined }} Children | ||
*/ | ||
|
||
/** | ||
* @template T | ||
* @param {Children<T>[]} groups item and groups | ||
*/ | ||
export const spaceLimited = (groups) => { | ||
>spaceLimited : <T>(groups: Children<T>[]) => void | ||
> : ^ ^^ ^^ ^^^^^^^^^ | ||
>(groups) => { for (let i = 0; i < groups.length; i++) { const group = groups[i]; spaceLimited(/** @type {Children<T>} */(group.children)); // should error }} : <T>(groups: Children<T>[]) => void | ||
> : ^ ^^ ^^ ^^^^^^^^^ | ||
>groups : Children<T>[] | ||
> : ^^^^^^^^^^^^^ | ||
|
||
for (let i = 0; i < groups.length; i++) { | ||
>i : number | ||
> : ^^^^^^ | ||
>0 : 0 | ||
> : ^ | ||
>i < groups.length : boolean | ||
> : ^^^^^^^ | ||
>i : number | ||
> : ^^^^^^ | ||
>groups.length : number | ||
> : ^^^^^^ | ||
>groups : Children<T>[] | ||
> : ^^^^^^^^^^^^^ | ||
>length : number | ||
> : ^^^^^^ | ||
>i++ : number | ||
> : ^^^^^^ | ||
>i : number | ||
> : ^^^^^^ | ||
|
||
const group = groups[i]; | ||
>group : Children<T> | ||
> : ^^^^^^^^^^^ | ||
>groups[i] : Children<T> | ||
> : ^^^^^^^^^^^ | ||
>groups : Children<T>[] | ||
> : ^^^^^^^^^^^^^ | ||
>i : number | ||
> : ^^^^^^ | ||
|
||
spaceLimited(/** @type {Children<T>} */(group.children)); // should error | ||
>spaceLimited(/** @type {Children<T>} */(group.children)) : void | ||
> : ^^^^ | ||
>spaceLimited : <T>(groups: Children<T>[]) => void | ||
> : ^ ^^ ^^ ^^^^^^^^^ | ||
>(group.children) : Children<T> | ||
> : ^^^^^^^^^^^ | ||
>group.children : Children<T>[] | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>group : Children<T> | ||
> : ^^^^^^^^^^^ | ||
>children : Children<T>[] | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
} | ||
}; | ||
|
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,22 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
// @checkJs: true | ||
// @allowJs: true | ||
|
||
// @filename: index.js | ||
|
||
/** | ||
* @template T | ||
* @typedef {T & { children: Children<T>[] | undefined }} Children | ||
*/ | ||
|
||
/** | ||
* @template T | ||
* @param {Children<T>[]} groups item and groups | ||
*/ | ||
export const spaceLimited = (groups) => { | ||
for (let i = 0; i < groups.length; i++) { | ||
const group = groups[i]; | ||
spaceLimited(/** @type {Children<T>} */(group.children)); // should error | ||
} | ||
}; |