1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
=== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiers.ts ===
declare function f1<const T>(x: T): T;
>f1 : Symbol(f1, Decl(typeParameterConstModifiers.ts, 0, 0))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 0, 20))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 0, 29))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 0, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 0, 20))
const x11 = f1('a');
>x11 : Symbol(x11, Decl(typeParameterConstModifiers.ts, 2, 5))
>f1 : Symbol(f1, Decl(typeParameterConstModifiers.ts, 0, 0))
const x12 = f1(['a', ['b', 'c']]);
>x12 : Symbol(x12, Decl(typeParameterConstModifiers.ts, 3, 5))
>f1 : Symbol(f1, Decl(typeParameterConstModifiers.ts, 0, 0))
const x13 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] });
>x13 : Symbol(x13, Decl(typeParameterConstModifiers.ts, 4, 5))
>f1 : Symbol(f1, Decl(typeParameterConstModifiers.ts, 0, 0))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 4, 16))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 4, 22))
>d : Symbol(d, Decl(typeParameterConstModifiers.ts, 4, 30))
>f : Symbol(f, Decl(typeParameterConstModifiers.ts, 4, 50))
declare function f2<const T, U>(x: T | undefined): T;
>f2 : Symbol(f2, Decl(typeParameterConstModifiers.ts, 4, 64))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 6, 20))
>U : Symbol(U, Decl(typeParameterConstModifiers.ts, 6, 28))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 6, 32))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 6, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 6, 20))
const x21 = f2('a');
>x21 : Symbol(x21, Decl(typeParameterConstModifiers.ts, 8, 5))
>f2 : Symbol(f2, Decl(typeParameterConstModifiers.ts, 4, 64))
const x22 = f2(['a', ['b', 'c']]);
>x22 : Symbol(x22, Decl(typeParameterConstModifiers.ts, 9, 5))
>f2 : Symbol(f2, Decl(typeParameterConstModifiers.ts, 4, 64))
const x23 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] });
>x23 : Symbol(x23, Decl(typeParameterConstModifiers.ts, 10, 5))
>f2 : Symbol(f2, Decl(typeParameterConstModifiers.ts, 4, 64))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 10, 16))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 10, 22))
>d : Symbol(d, Decl(typeParameterConstModifiers.ts, 10, 30))
>f : Symbol(f, Decl(typeParameterConstModifiers.ts, 10, 50))
declare function f3<const T>(x: T): T[];
>f3 : Symbol(f3, Decl(typeParameterConstModifiers.ts, 10, 64))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 12, 20))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 12, 29))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 12, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 12, 20))
const x31 = f3("hello");
>x31 : Symbol(x31, Decl(typeParameterConstModifiers.ts, 14, 5))
>f3 : Symbol(f3, Decl(typeParameterConstModifiers.ts, 10, 64))
const x32 = f3("hello");
>x32 : Symbol(x32, Decl(typeParameterConstModifiers.ts, 15, 5))
>f3 : Symbol(f3, Decl(typeParameterConstModifiers.ts, 10, 64))
declare function f4<const T>(obj: [T, T]): T;
>f4 : Symbol(f4, Decl(typeParameterConstModifiers.ts, 15, 24))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 17, 20))
>obj : Symbol(obj, Decl(typeParameterConstModifiers.ts, 17, 29))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 17, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 17, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 17, 20))
const x41 = f4([[1, 'x'], [2, 'y']]);
>x41 : Symbol(x41, Decl(typeParameterConstModifiers.ts, 19, 5))
>f4 : Symbol(f4, Decl(typeParameterConstModifiers.ts, 15, 24))
const x42 = f4([{ a: 1, b: 'x' }, { a: 2, b: 'y' }]);
>x42 : Symbol(x42, Decl(typeParameterConstModifiers.ts, 20, 5))
>f4 : Symbol(f4, Decl(typeParameterConstModifiers.ts, 15, 24))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 20, 17))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 20, 23))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 20, 35))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 20, 41))
declare function f5<const T>(obj: { x: T, y: T }): T;
>f5 : Symbol(f5, Decl(typeParameterConstModifiers.ts, 20, 53))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 22, 20))
>obj : Symbol(obj, Decl(typeParameterConstModifiers.ts, 22, 29))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 22, 35))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 22, 20))
>y : Symbol(y, Decl(typeParameterConstModifiers.ts, 22, 41))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 22, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 22, 20))
const x51 = f5({ x: [1, 'x'], y: [2, 'y'] });
>x51 : Symbol(x51, Decl(typeParameterConstModifiers.ts, 24, 5))
>f5 : Symbol(f5, Decl(typeParameterConstModifiers.ts, 20, 53))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 24, 16))
>y : Symbol(y, Decl(typeParameterConstModifiers.ts, 24, 29))
const x52 = f5({ x: { a: 1, b: 'x' }, y: { a: 2, b: 'y' } });
>x52 : Symbol(x52, Decl(typeParameterConstModifiers.ts, 25, 5))
>f5 : Symbol(f5, Decl(typeParameterConstModifiers.ts, 20, 53))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 25, 16))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 25, 21))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 25, 27))
>y : Symbol(y, Decl(typeParameterConstModifiers.ts, 25, 37))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 25, 42))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 25, 48))
declare function f6<const T extends readonly unknown[]>(...args: T): T;
>f6 : Symbol(f6, Decl(typeParameterConstModifiers.ts, 25, 61))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 27, 20))
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 27, 56))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 27, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 27, 20))
const x61 = f6(1, 'b', { a: 1, b: 'x' });
>x61 : Symbol(x61, Decl(typeParameterConstModifiers.ts, 29, 5))
>f6 : Symbol(f6, Decl(typeParameterConstModifiers.ts, 25, 61))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 29, 24))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 29, 30))
class C1<const T> {
>C1 : Symbol(C1, Decl(typeParameterConstModifiers.ts, 29, 41))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 31, 9))
constructor(x: T) {}
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 32, 16))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 31, 9))
foo<const U>(x: U) { return x; }
>foo : Symbol(C1.foo, Decl(typeParameterConstModifiers.ts, 32, 24))
>U : Symbol(U, Decl(typeParameterConstModifiers.ts, 33, 8))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 33, 17))
>U : Symbol(U, Decl(typeParameterConstModifiers.ts, 33, 8))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 33, 17))
}
const c71 = new C1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] });
>c71 : Symbol(c71, Decl(typeParameterConstModifiers.ts, 36, 5))
>C1 : Symbol(C1, Decl(typeParameterConstModifiers.ts, 29, 41))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 36, 20))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 36, 26))
>d : Symbol(d, Decl(typeParameterConstModifiers.ts, 36, 34))
>f : Symbol(f, Decl(typeParameterConstModifiers.ts, 36, 54))
const c72 = c71.foo(['a', ['b', 'c']]);
>c72 : Symbol(c72, Decl(typeParameterConstModifiers.ts, 37, 5))
>c71.foo : Symbol(C1.foo, Decl(typeParameterConstModifiers.ts, 32, 24))
>c71 : Symbol(c71, Decl(typeParameterConstModifiers.ts, 36, 5))
>foo : Symbol(C1.foo, Decl(typeParameterConstModifiers.ts, 32, 24))
const C2 = class <const T> {}
>C2 : Symbol(C2, Decl(typeParameterConstModifiers.ts, 39, 5))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 39, 18))
const fx1 = <const T>(x: T) => x;
>fx1 : Symbol(fx1, Decl(typeParameterConstModifiers.ts, 41, 5))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 41, 13))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 41, 22))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 41, 13))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 41, 22))
const fx2 = <const T,>(x: T) => x;
>fx2 : Symbol(fx2, Decl(typeParameterConstModifiers.ts, 42, 5))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 42, 13))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 42, 23))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 42, 13))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 42, 23))
interface I1<const T> { x: T } // Error
>I1 : Symbol(I1, Decl(typeParameterConstModifiers.ts, 42, 34))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 44, 13))
>x : Symbol(I1.x, Decl(typeParameterConstModifiers.ts, 44, 23))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 44, 13))
interface I2 {
>I2 : Symbol(I2, Decl(typeParameterConstModifiers.ts, 44, 30))
f<const T>(x: T): T;
>f : Symbol(I2.f, Decl(typeParameterConstModifiers.ts, 46, 14))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 47, 6))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 47, 15))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 47, 6))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 47, 6))
}
type T1<const T> = T; // Error
>T1 : Symbol(T1, Decl(typeParameterConstModifiers.ts, 48, 1))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 50, 8))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 50, 8))
type T2 = <const T>(x: T) => T;
>T2 : Symbol(T2, Decl(typeParameterConstModifiers.ts, 50, 21))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 52, 11))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 52, 20))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 52, 11))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 52, 11))
type T3 = { <const T>(x: T): T };
>T3 : Symbol(T3, Decl(typeParameterConstModifiers.ts, 52, 31))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 53, 13))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 53, 22))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 53, 13))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 53, 13))
type T4 = new <const T>(x: T) => T;
>T4 : Symbol(T4, Decl(typeParameterConstModifiers.ts, 53, 33))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 54, 15))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 54, 24))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 54, 15))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 54, 15))
type T5 = { new <const T>(x: T): T };
>T5 : Symbol(T5, Decl(typeParameterConstModifiers.ts, 54, 35))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 55, 17))
>x : Symbol(x, Decl(typeParameterConstModifiers.ts, 55, 26))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 55, 17))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 55, 17))
// Corrected repro from #51745
type Obj = { a: { b: { c: "123" } } };
>Obj : Symbol(Obj, Decl(typeParameterConstModifiers.ts, 55, 37))
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 59, 12))
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 59, 17))
>c : Symbol(c, Decl(typeParameterConstModifiers.ts, 59, 22))
type GetPath<T, P> =
>GetPath : Symbol(GetPath, Decl(typeParameterConstModifiers.ts, 59, 38))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 61, 13))
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 61, 15))
P extends readonly [] ? T :
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 61, 15))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 61, 13))
P extends readonly [infer A extends keyof T, ...infer Rest] ? GetPath<T[A], Rest> :
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 61, 15))
>A : Symbol(A, Decl(typeParameterConstModifiers.ts, 63, 29))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 61, 13))
>Rest : Symbol(Rest, Decl(typeParameterConstModifiers.ts, 63, 57))
>GetPath : Symbol(GetPath, Decl(typeParameterConstModifiers.ts, 59, 38))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 61, 13))
>A : Symbol(A, Decl(typeParameterConstModifiers.ts, 63, 29))
>Rest : Symbol(Rest, Decl(typeParameterConstModifiers.ts, 63, 57))
never;
function set<T, const P extends readonly string[]>(obj: T, path: P, value: GetPath<T, P>) {}
>set : Symbol(set, Decl(typeParameterConstModifiers.ts, 64, 10))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 66, 13))
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 66, 15))
>obj : Symbol(obj, Decl(typeParameterConstModifiers.ts, 66, 51))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 66, 13))
>path : Symbol(path, Decl(typeParameterConstModifiers.ts, 66, 58))
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 66, 15))
>value : Symbol(value, Decl(typeParameterConstModifiers.ts, 66, 67))
>GetPath : Symbol(GetPath, Decl(typeParameterConstModifiers.ts, 59, 38))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 66, 13))
>P : Symbol(P, Decl(typeParameterConstModifiers.ts, 66, 15))
declare let obj: Obj;
>obj : Symbol(obj, Decl(typeParameterConstModifiers.ts, 68, 11))
>Obj : Symbol(Obj, Decl(typeParameterConstModifiers.ts, 55, 37))
declare let value: "123";
>value : Symbol(value, Decl(typeParameterConstModifiers.ts, 69, 11))
set(obj, ['a', 'b', 'c'], value);
>set : Symbol(set, Decl(typeParameterConstModifiers.ts, 64, 10))
>obj : Symbol(obj, Decl(typeParameterConstModifiers.ts, 68, 11))
>value : Symbol(value, Decl(typeParameterConstModifiers.ts, 69, 11))
// Repro from #52007
declare function inners<const T extends readonly any[]>(...args: readonly [unknown, ...T, unknown]): T;
>inners : Symbol(inners, Decl(typeParameterConstModifiers.ts, 71, 33))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 75, 24))
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 75, 56))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 75, 24))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 75, 24))
const test = inners(1,2,3,4,5);
>test : Symbol(test, Decl(typeParameterConstModifiers.ts, 77, 5))
>inners : Symbol(inners, Decl(typeParameterConstModifiers.ts, 71, 33))
declare function inners2<const T extends readonly any[]>(args: readonly [unknown, ...T, unknown]): T;
>inners2 : Symbol(inners2, Decl(typeParameterConstModifiers.ts, 77, 31))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 79, 25))
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 79, 57))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 79, 25))
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 79, 25))
const test2 = inners2([1,2,3,4,5]);
>test2 : Symbol(test2, Decl(typeParameterConstModifiers.ts, 81, 5))
>inners2 : Symbol(inners2, Decl(typeParameterConstModifiers.ts, 77, 31))
|