mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Test:incorrect mapped type doesn't infinitely recur
This commit is contained in:
parent
f0ef9a08d8
commit
c0dd832e46
@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(2,32): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
Type '{ [P in T]: number; }' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts (1 errors) ====
|
||||
// #17847
|
||||
function sum<T extends { [P in T]: number }, K extends keyof T>(n: number, v: T, k: K) {
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type '{ [P in T]: number; }' is not assignable to type 'string'.
|
||||
n += v[k];
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
//// [incorrectRecursiveMappedTypeConstraint.ts]
|
||||
// #17847
|
||||
function sum<T extends { [P in T]: number }, K extends keyof T>(n: number, v: T, k: K) {
|
||||
n += v[k];
|
||||
}
|
||||
|
||||
|
||||
//// [incorrectRecursiveMappedTypeConstraint.js]
|
||||
// #17847
|
||||
function sum(n, v, k) {
|
||||
n += v[k];
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts ===
|
||||
// #17847
|
||||
function sum<T extends { [P in T]: number }, K extends keyof T>(n: number, v: T, k: K) {
|
||||
>sum : Symbol(sum, Decl(incorrectRecursiveMappedTypeConstraint.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 13))
|
||||
>P : Symbol(P, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 26))
|
||||
>T : Symbol(T, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 13))
|
||||
>K : Symbol(K, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 44))
|
||||
>T : Symbol(T, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 13))
|
||||
>n : Symbol(n, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 64))
|
||||
>v : Symbol(v, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 74))
|
||||
>T : Symbol(T, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 13))
|
||||
>k : Symbol(k, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 80))
|
||||
>K : Symbol(K, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 44))
|
||||
|
||||
n += v[k];
|
||||
>n : Symbol(n, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 64))
|
||||
>v : Symbol(v, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 74))
|
||||
>k : Symbol(k, Decl(incorrectRecursiveMappedTypeConstraint.ts, 1, 80))
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
=== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts ===
|
||||
// #17847
|
||||
function sum<T extends { [P in T]: number }, K extends keyof T>(n: number, v: T, k: K) {
|
||||
>sum : <T extends { [P in T]: number; }, K extends keyof T>(n: number, v: T, k: K) => void
|
||||
>T : T
|
||||
>P : P
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>n : number
|
||||
>v : T
|
||||
>T : T
|
||||
>k : K
|
||||
>K : K
|
||||
|
||||
n += v[k];
|
||||
>n += v[k] : number
|
||||
>n : number
|
||||
>v[k] : T[K]
|
||||
>v : T
|
||||
>k : K
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// #17847
|
||||
function sum<T extends { [P in T]: number }, K extends keyof T>(n: number, v: T, k: K) {
|
||||
n += v[k];
|
||||
}
|
||||
@ -1 +1 @@
|
||||
Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6
|
||||
Subproject commit ed149eb0c787b1195a95b44105822c64bb6eb636
|
||||
Loading…
x
Reference in New Issue
Block a user