_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/conformance/types/import/importTypeLocal.ts_0_700
// @declaration: true // @lib: es6 // @filename: foo.ts interface Point { x: number; y: number; } export = Point; // @filename: foo2.ts namespace Bar { export interface I { a: string; b: number; } } export namespace Baz { export interface J { a: number; b: string; ...
{ "end_byte": 700, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeLocal.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeNested.ts_0_220
// @declaration: true // @target: es6 // @filename: a.d.ts export type LookAt = "./b"; // @filename: b.d.ts export type Value = "yes"; // @filename: chainer.ts export const x: import(import("./a").LookAt).Value = "yes";
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeNested.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeNestedNoRef.ts_0_316
// @declaration: true // @target: es6 // @noImplicitReferences: true // @filename: a.d.ts export type LookAt = "./b"; // @filename: b.d.ts export type Value = "yes"; // @filename: chainer.ts export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build
{ "end_byte": 316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeNestedNoRef.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeInJSDoc.ts_0_682
// @target: es6 // @outDir: ./out // @allowJs: true // @checkJs: true // @filename: externs.d.ts declare namespace MyClass { export interface Bar { doer: (x: string) => void; } } declare class MyClass { field: string; static Bar: (x: string, y?: number) => void; constructor(x: MyClass.Bar); ...
{ "end_byte": 682, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeInJSDoc.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeGenericTypes.ts_0_833
// @declaration: true // @lib: es6 // @filename: foo.ts interface Point<T> { x: number; y: number; data: T; } export = Point; // @filename: foo2.ts namespace Bar { export interface I<T> { a: string; b: number; data: T; } } export namespace Baz { export interface J<T> { ...
{ "end_byte": 833, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeGenericTypes.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeNonString.ts_0_90
// @declaration: true // @target: es6 export const x: import({x: 12}) = undefined as any;
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeNonString.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeLocalMissing.ts_0_753
// @declaration: true // @lib: es6 // @filename: foo.ts interface Point { x: number; y: number; } export = Point; // @filename: foo2.ts namespace Bar { export interface I { a: string; b: number; } } export namespace Baz { export interface J { a: number; b: string; ...
{ "end_byte": 753, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeLocalMissing.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeGeneric.ts_0_406
// @declaration: true // @target: es6 // @filename: a.d.ts export interface Foo { a: string; } // @filename: b.d.ts export interface Foo { a: number; } // @filename: usage.ts export function getFooFrom<T extends "./a" | "./b">(v: T): import(T).Foo { return undefined as any; } export function getFooValueFro...
{ "end_byte": 406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeGeneric.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeAmbient.ts_0_697
// @declaration: true // @lib: es6 declare module "foo" { interface Point { x: number; y: number; } export = Point; } const x: import("foo") = { x: 0, y: 0 }; declare module "foo2" { namespace Bar { interface I { a: string; b: number; } } ...
{ "end_byte": 697, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeAmbient.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeAmbientMissing.ts_0_202
// @declaration: true // @lib: es6 declare module "foo" { interface Point { x: number; y: number; } export = Point; } const x: import("fo") = { x: 0, y: 0 }; // typo, error
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeAmbientMissing.ts" }
TypeScript/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts_0_285
// @declaration: true // @module: amd // @outFile: bundle.js // @filename: a/b/c.ts export interface Foo { x: 12; } // @filename: a/inner.ts const c: import("./b/c").Foo = {x: 12}; export {c}; // @filename: index.ts const d: typeof import("./a/inner")["c"] = {x: 12}; export {d};
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts_0_612
// #37859 enum TerrestrialAnimalTypes { CAT = "cat", DOG = "dog" }; enum AlienAnimalTypes { CAT = "cat", }; type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; interface TerrestrialCat { type: TerrestrialAnimalTypes.CAT; address: string; } interface AlienCat { type: AlienAnimalTypes.CAT pla...
{ "end_byte": 612, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts_0_2380
// @strictNullChecks: true // @noimplicitany: true type T = { a: number, b: string }; type TP = { a?: number, b?: string }; type TR = { readonly a: number, readonly b: string }; type TPR = { readonly a?: number, readonly b?: string }; var v00: "a" | "b"; var v00: keyof T; var v00: keyof TP; var v00: keyof TR; var v00...
{ "end_byte": 2380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeConstraints.ts_0_830
// @strict: true function f0<T extends { a: string, b: string }>(obj: Pick<T, Extract<keyof T, 'b'>>) { obj.b; } function f1<T extends { a: string, b: string }>(obj: Pick<T, Exclude<keyof T, 'a'>>) { obj.b; } function f2<T extends { a: string, b: string }, U extends { b: string, c: string }>(obj: Pick<T | U,...
{ "end_byte": 830, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeConstraints.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts_0_1071
// From original issue #45212: type Methods<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] }; type H<T> = T[keyof Methods<T>]; // Ok // `Filter<T>` only filters out some keys of `T`. type Filter<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] }; // `Modify<T>` might modify some keys ...
{ "end_byte": 1071, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeProperties.ts_0_771
// @declaration: true export type PlaceType = 'openSky' | 'roofed' | 'garage' type Before = { model: 'hour' | 'day'; [placeType in PlaceType]: void; } type After = { [placeType in PlaceType]: void; model: 'hour' | 'day' } type AfterQuestion = { [placeType in PlaceType]?: void; model: 'hour' | ...
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeProperties.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeErrors.ts_0_3732
// @strictNullChecks: true // @declaration: true interface Shape { name: string; width: number; height: number; visible: boolean; } interface Named { name: string; } interface Point { x: number; y: number; } // Constraint checking type T00 = { [P in P]: string }; // Error type T01 = { ...
{ "end_byte": 3732, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeErrors.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeErrors2.ts_0_553
// @strictNullChecks: true // @declaration: true // Repros from #17238 type AB = { a: 'a' b: 'a' }; type T1<K extends keyof AB> = { [key in AB[K]]: true }; type T2<K extends 'a'|'b'> = T1<K>[K]; // Error type R = AB[keyof AB]; // "a" type T3 = { [key in R]: true }; type T4<K extends 'a'|'b'> = T3[K] // Erro...
{ "end_byte": 553, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeErrors2.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts_0_319
// @strict: true // @lib: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/57389 declare function getT<T>(): T; Promise.all([getT<string>(), ...getT<any>()]).then((result) => { const head = result[0]; // string const tail = result.slice(1); // any[] tail satisfies string[]; // ok });
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypesGenericTuples.ts_0_1636
// @strict: true // @noEmit: true // Property keys are `number` following the fixed part of a tuple type K<T> = { [P in keyof T]: P }; type M<T> = { [P in keyof T]: T[P] }; type KA = K<[string, string, boolean]>; // ["0", "1", "2"] type KB = K<[string, string, ...string[], string]>; // ["0", "1", ...number[], numb...
{ "end_byte": 1636, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypesGenericTuples.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes4.ts_0_1598
// @strictNullChecks: true // @declaration: true type Box<T> = { }; type Boxified<T> = { [P in keyof T]: Box<T[P]>; }; function boxify<T>(obj: T): Boxified<T> { if (typeof obj === "object") { let result = {} as Boxified<T>; for (let k in obj) { result[k] = { value: obj[k] }; ...
{ "end_byte": 1598, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes4.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeWithAny.ts_0_2136
// @strict: true // @declaration: true type Item = { value: string }; type ItemMap<T> = { [P in keyof T]: Item }; declare let x0: keyof any; declare let x1: { [P in any]: Item }; declare let x2: { [P in string]: Item }; declare let x3: { [P in keyof any]: Item }; declare let x4: ItemMap<any>; // Repro from #19152 t...
{ "end_byte": 2136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeWithAny.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes5.ts_0_1780
// @strict: true function f<T>(p: Partial<T>, r: Readonly<T>, pr: Partial<Readonly<T>>, rp: Readonly<Partial<T>>) { let a1: Partial<T> = p; let a2: Partial<T> = r; let a3: Partial<T> = pr; let a4: Partial<T> = rp; let b1: Readonly<T> = p; // Error let b2: Readonly<T> = r; let b3: Readonly<...
{ "end_byte": 1780, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes5.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts_0_3185
// @strict: true // @declaration: true type Box<T> = { value: T }; type Boxified<T> = { [P in keyof T]: Box<T[P]> }; type T00 = Boxified<[number, string?, ...boolean[]]>; type T01 = Partial<[number, string?, ...boolean[]]>; type T02 = Required<[number, string?, ...boolean[]]>; type T10 = Boxified<string[]>; type T11...
{ "end_byte": 3185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes1.ts_0_1438
// @strictNullChecks: true // @declaration: true type Item = { a: string, b: number, c: boolean }; type T00 = { [P in "x" | "y"]: number }; type T01 = { [P in "x" | "y"]: P }; type T02 = { [P in "a" | "b"]: Item[P]; } type T03 = { [P in keyof Item]: Date }; type T10 = { [P in keyof Item]: Item[P] }; type T11 = { [P ...
{ "end_byte": 1438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes1.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes6.ts_0_2564
// @strict: true // @declaration: true type T00<T> = { [P in keyof T]: T[P] }; type T01<T> = { [P in keyof T]?: T[P] }; type T02<T> = { [P in keyof T]+?: T[P] }; type T03<T> = { [P in keyof T]-?: T[P] }; type T04<T> = { readonly [P in keyof T]: T[P] }; type T05<T> = { readonly [P in keyof T]?: T[P] }; type T06<T> = {...
{ "end_byte": 2564, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes6.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes2.ts_0_2245
// @strictNullChecks: true // @declaration: true function verifyLibTypes<T, K extends keyof T, U>() { var x1: Partial<T>; var x1: { [P in keyof T]?: T[P] }; var x2: Readonly<T>; var x2: { readonly [P in keyof T]: T[P] }; var x3: Pick<T, K>; var x3: { [P in K]: T[P] }; var x4: Record<K, U>; ...
{ "end_byte": 2245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes2.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypes3.ts_0_785
// @declaration: true class Box<P> { value: P; } type Boxified<T> = { [K in keyof T]: Box<T[K]>; } declare function boxify<T>(obj: T): Boxified<T>; declare function unboxify<T>(obj: Boxified<T>): T; interface Bacon { isPerfect: boolean; weight: number; } interface BoxifiedBacon { isPerfect: Box...
{ "end_byte": 785, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypes3.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeIndexSignatureModifiers.ts_0_1770
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/14295 interface Obj1 { readonly [key: string]: string; } type Res1 = Pick<Obj1, keyof Obj1> interface Obj2 { concreteProp: 'hello'; readonly [key: string]: string; } type Res2 = Pick<Obj2, keyof Obj2> interface Obj3 { ...
{ "end_byte": 1770, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeIndexSignatureModifiers.ts" }
TypeScript/tests/cases/conformance/types/mapped/recursiveMappedTypes.ts_0_2253
// @declaration: true // Recursive mapped types simply appear empty type Recurse = { [K in keyof Recurse]: Recurse[K] } type Recurse1 = { [K in keyof Recurse2]: Recurse2[K] } type Recurse2 = { [K in keyof Recurse1]: Recurse1[K] } // Repro from #27881 export type Circular<T> = {[P in keyof T]: Circular...
{ "end_byte": 2253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/recursiveMappedTypes.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts_0_2313
// @strict: true // @declaration: true // @target: es2017 type Mapped1<K extends string> = { [P in K]: { a: P } }; function f1<K extends string>(obj: Mapped1<K>, key: K) { const x: { a: K } = obj[key]; } type Mapped2<K extends string> = { [P in K as `get${P}`]: { a: P } }; function f2<K extends string>(obj: Map...
{ "end_byte": 2313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeAsClauses.ts_0_5480
// @strict: true // @declaration: true // Mapped type 'as N' clauses type Getters<T> = { [P in keyof T & string as `get${Capitalize<P>}`]: () => T[P] }; type TG1 = Getters<{ foo: string, bar: number, baz: { z: boolean } }>; // Mapped type with 'as N' clause has no constraint on 'in T' clause type PropDef<K extends ...
{ "end_byte": 5480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeAsClauses.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts_0_364
// @strict: true // Repro from #19316 type ComputedOf<T> = { [K in keyof T]: () => T[K]; } declare function foo<P, C>(options: { props: P, computed: ComputedOf<C> } & ThisType<P & C>): void; foo({ props: { x: 10, y: 20 }, computed: { bar(): number { let z = this.bar; retu...
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts_0_758
// @strictNullChecks: true // @declaration: true function f1<T>(x: Partial<T>, y: Readonly<T>) { let obj: {}; obj = x; obj = y; } function f2<T>(x: Partial<T>, y: Readonly<T>) { let obj: { [x: string]: any }; obj = x; obj = y; } function f3<T>(x: Partial<T>) { x = {}; } // Repro from #12...
{ "end_byte": 758, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts" }
TypeScript/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts_0_4260
// @strictNullChecks: true // @noimplicitany: true // @declaration: true type Box<T> = { value: T; } type Boxified<T> = { [P in keyof T]: Box<T[P]>; } function box<T>(x: T): Box<T> { return { value: x }; } function unbox<T>(x: Box<T>): T { return x.value; } function boxify<T>(obj: T): Boxified<T> {...
{ "end_byte": 4260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts" }
TypeScript/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts_0_4527
// @strictNullChecks: true // @declaration: true function f1<T>(x: T, k: keyof T) { return x[k]; } function f2<T, K extends keyof T>(x: T, k: K) { return x[k]; } function f3<T, U extends T>(x: T, y: U, k: keyof T) { x[k] = y[k]; y[k] = x[k]; // Error } function f4<T, U extends T, K extends keyof T>...
{ "end_byte": 4527, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestPropertyMustBeLast.ts_0_281
var {...a, x } = { x: 1 }; // Error, rest must be last property ({...a, x } = { x: 1 }); // Error, rest must be last property var {...a, x, ...b } = { x: 1 }; // Error, rest must be last property ({...a, x, ...b } = { x: 1 }); // Error, rest must be last property
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestPropertyMustBeLast.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestParameter.ts_0_666
// @target: es2015 function cloneAgain({ a, ...clone }: { a: number, b: string }): void { } declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void); suddenly(({ x: a, ...rest }) => rest.y); suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka); class...
{ "end_byte": 666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestParameter.ts" }
TypeScript/tests/cases/conformance/types/rest/genericRestArityStrict.ts_0_247
// @strict: true // Repro from #25559 declare function call<TS extends unknown[]>( handler: (...args: TS) => void, ...args: TS): void; call((x: number, y: number) => x + y); call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7);
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericRestArityStrict.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestNegative.ts_0_395
// @noImplicitAny: true let o = { a: 1, b: 'no' }; var { ...mustBeLast, a } = o; var b: string; let notAssignable: { a: string }; ({ b, ...notAssignable } = o); function stillMustBeLast({ ...mustBeLast, a }: { a: number, b: string }): void { } function generic<T extends { x, y }>(t: T) { let { x, ...rest } = t; ...
{ "end_byte": 395, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestNegative.ts" }
TypeScript/tests/cases/conformance/types/rest/genericRestParameters2.ts_0_2646
// @strict: true // @declaration: true declare const t1: [number, string, ...boolean[]]; declare const t2: [string, ...boolean[]]; declare const t3: [...boolean[]]; declare const t4: []; declare let f00: (...x: [number, string, boolean]) => void; declare let f01: (a: number, ...x: [string, boolean]) => void; declare ...
{ "end_byte": 2646, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericRestParameters2.ts" }
TypeScript/tests/cases/conformance/types/rest/genericObjectRest.ts_0_783
// @strict: true // @target: es2015 const a = 'a'; function f1<T extends { a: string, b: number }>(obj: T) { let { ...r0 } = obj; let { a: a1, ...r1 } = obj; let { a: a2, b: b2, ...r2 } = obj; let { 'a': a3, ...r3 } = obj; let { ['a']: a4, ...r4 } = obj; let { [a]: a5, ...r5 } = obj; } const ...
{ "end_byte": 783, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericObjectRest.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestReadonly.ts_0_199
// #23734 type ObjType = { foo: string baz: string quux: string } const obj: Readonly<ObjType> = { foo: 'bar', baz: 'qux', quux: 'quuz', } const { foo, ...rest } = obj delete rest.baz
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestReadonly.ts" }
TypeScript/tests/cases/conformance/types/rest/restElementMustBeLast.ts_0_128
var [...a, x] = [1, 2, 3]; // Error, rest must be last element [...a, x] = [1, 2, 3]; // Error, rest must be last element
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/restElementMustBeLast.ts" }
TypeScript/tests/cases/conformance/types/rest/genericRestParameters3.ts_0_2264
// @strict: true // @declaration: true declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; declare let f2: (x: string, y: string) => void; declare let f3: (x: string, y: number, z: boolean) => void; declare let f4: (...args: [string, string] | [string, number, boolean]) => void; declare const ...
{ "end_byte": 2264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericRestParameters3.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRest2.ts_0_373
// @lib: es2015 // @target: es2015 // test for #12203 declare function connectionFromArray(objects: number, args: any): {}; function rootConnection(name: string) { return { resolve: async (context, args) => { const { objects } = await { objects: 12 }; return { ...connectionFromArray(objects,...
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRest2.ts" }
TypeScript/tests/cases/conformance/types/rest/genericRestArity.ts_0_229
// Repro from #25559 declare function call<TS extends unknown[]>( handler: (...args: TS) => void, ...args: TS): void; call((x: number, y: number) => x + y); call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7);
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericRestArity.ts" }
TypeScript/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts_0_2579
// @strict: true // @declaration: true declare const t1: [number, boolean, string]; (function (a, b, c){})(...t1); (function (...x){})(...t1); (function (a, ...x){})(...t1); (function (a, b, ...x){})(...t1); (function (a, b, c, ...x){})(...t1); declare function f1(cb: (...args: typeof t1) => void): void; f1((a, b, ...
{ "end_byte": 2579, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts" }
TypeScript/tests/cases/conformance/types/rest/genericRestParameters1.ts_0_5361
// @strict: true // @declaration: true declare let f1: (...x: [number, string, boolean]) => void; declare let f2: (x0: number, x1: string, x2: boolean) => void; f1 = f2; f2 = f1; declare const t3: [number, string, boolean]; declare const t2: [string, boolean]; declare const t1: [boolean]; declare const t0: []; decl...
{ "end_byte": 5361, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/genericRestParameters1.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestAssignment.ts_0_615
// @target: es2015 let ka: any; let nested: { ki }; let other: number; let rest: { }; let complex: { x: { ka, ki }, y: number }; ({x: { ka, ...nested }, y: other, ...rest} = complex); // should be: let overEmit: { a: { ka: string, x: string }[], b: { z: string, ki: string, ku: string }, ke: string, ko: string }; // v...
{ "end_byte": 615, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestAssignment.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestParameterES5.ts_0_663
// @target: es5 function cloneAgain({ a, ...clone }: { a: number, b: string }): void { } declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void); suddenly(({ x: a, ...rest }) => rest.y); suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka); class C ...
{ "end_byte": 663, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestParameterES5.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestForOf.ts_0_358
// @target: es2015 let array: { x: number, y: string }[]; for (let { x, ...restOf } of array) { [x, restOf]; } let xx: number; let rrestOff: { y: string }; for ({ x: xx, ...rrestOff } of array ) { [xx, rrestOff]; } for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { [norest.x, norest.y]; /...
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestForOf.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRestCatchES5.ts_0_47
let a = 1, b = 2; try {} catch ({ a, ...b }) {}
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRestCatchES5.ts" }
TypeScript/tests/cases/conformance/types/rest/objectRest.ts_0_1468
// @target: es2015 var o = { a: 1, b: 'no' } var { ...clone } = o; var { a, ...justB } = o; var { a, b: renamed, ...empty } = o; var { ['b']: renamed, ...justA } = o; var { 'b': renamed, ...justA } = o; var { b: { '0': n, '1': oooo }, ...justA } = o; let o2 = { c: 'terrible idea?', d: 'yes' }; var { d: renamed, ...d }...
{ "end_byte": 1468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/rest/objectRest.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts_0_201
// @declaration: true interface BoxOfFoo<T extends Foo<T>> { item: T } interface Foo<T extends Foo<T>> { self: T; } interface Bar<T extends Bar<T>> extends Foo<T> { other: BoxOfFoo<T>; }
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts_0_191
// type parameters cannot be used as base types // these are all errors class C<T> extends T { } class C2<T, U> extends U { } interface I<T> extends T { } interface I2<T, U> extends U { }
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts_0_5456
// @strict: true // @declaration: true declare function fx<T>(x: T): T; declare function fx<T>(x: T, n: number): T; declare function fx<T, U>(t: [T, U]): [T, U]; function f1() { let f0 = fx<>; // Error let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; } let f2 = fx<string, n...
{ "end_byte": 5456, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts_5458_6024
// { (a: V) => { a: V }; new (b: V) => { b: V }; } type T31<A> = ReturnType<T30<A>>; // { a: A } type T32<B> = InstanceType<T30<B>>; // { b: B } declare const g2: { <T extends string>(a: T): T; new <T extends number>(b: T): T; } type T40<U extends string> = typeof g2<U>; // Error type T41<U extends number>...
{ "end_byte": 6024, "start_byte": 5458, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithZeroTypeArguments.ts_0_550
// valid invocations of generic functions with no explicit type arguments provided function f<T>(x: T): T { return null; } var r = f(1); var f2 = <T>(x: T): T => { return null; } var r2 = f2(1); var f3: { <T>(x: T): T; } var r3 = f3(1); class C { f<T>(x: T): T { return null; } } var r4 = (new C())....
{ "end_byte": 550, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithZeroTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction.ts_0_1237
// satisfaction of a constraint to Function, no errors expected function foo<T extends Function>(x: T): T { return x; } interface I { (): string; } var i: I; class C { foo: string; } var a: { (): string }; var b: { new (): string }; var c: { (): string; (x): string }; var r = foo(new Function()); var r1 = ...
{ "end_byte": 1237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithIncorrectNumberOfTypeArguments.ts_0_1060
// type parameter lists must exactly match type argument lists // all of these invocations are errors function f<T, U>(x: T, y: U): T { return null; } var r1 = f<number>(1, ''); var r1b = f<number, string, number>(1, ''); var f2 = <T, U>(x: T, y: U): T => { return null; } var r2 = f2<number>(1, ''); var r2b = f2<numb...
{ "end_byte": 1060, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithIncorrectNumberOfTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint.ts_0_548
// using a type parameter as a constraint for a type parameter is valid // no errors expected except illegal constraints function foo<T, U extends T>(x: T, y: U): U { return y; } var r = foo(1, 2); var r = foo({}, 1); interface A { foo: string; } interface B extends A { bar: number; } var a: A; var b: B; va...
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively.ts_0_775
// using a type parameter as a constraint for a type parameter is valid // no errors expected interface A { foo: number } interface B extends A { bar: string; } interface C extends B { baz: boolean; } var a: A; var b: B; var c: C; function foo<T, U, V>(x: T, y: U, z: V): V { return z; } //function foo<T, U extends T,...
{ "end_byte": 775, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateGenericClassWithZeroTypeArguments.ts_0_187
// no errors expected when instantiating a generic type with no type arguments provided class C<T> { x: T; } var c = new C(); class D<T, U> { x: T y: U } var d = new D();
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateGenericClassWithZeroTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts_0_313
class C<T extends { length: number }> { constructor(x: T) { } foo<U extends T>(x: U) { function bar<V extends U>(x: V) { return x; } return bar; } } var c = new C({ length: 2 }); var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny.ts_0_1040
// any is not a valid type argument unless there is no constraint, or the constraint is any function foo<T extends String>(x: T): T { return null; } function foo2<T extends { x: number }>(x: T): T { return null; } //function foo3<T extends T[]>(x: T): T { return null; } function foo4<T extends <T>(x: T) => void>(x: T)...
{ "end_byte": 1040, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively2.ts_0_858
// using a type parameter as a constraint for a type parameter is invalid // these should be errors at the type parameter constraint declarations, and have no downstream errors interface A { foo: number } interface B extends A { bar: string; } interface C extends B { baz: boolean; } var a: A; var b: B; var c: C; func...
{ "end_byte": 858, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateNonGenericTypeWithTypeArguments.ts_0_300
// it is an error to provide type arguments to a non-generic call // all of these are errors class C { x: string; } var c = new C<number>(); function Foo(): void { } var r = new Foo<number>(); var f: { (): void }; var r2 = new f<number>(); var a: any; // BUG 790977 var r2 = new a<number>();
{ "end_byte": 300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateNonGenericTypeWithTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts_0_490
// using a type parameter as a constraint for a type parameter is invalid // these should be errors unless otherwise noted function foo<T, U extends T>(x: T, y: U): U { return y; } // this is now an error foo(1, ''); foo(1, {}); interface NumberVariant extends Number { x: number; } var n: NumberVariant; var r3 =...
{ "end_byte": 490, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts_0_244
// no errors expected class C<T extends Date> { constructor(public data: T) { } foo<U extends T>(x: U) { return x; } } interface Foo extends Date { foo: string; } var y: Foo = null; var c = new C(y); var r = c.foo(y);
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateGenericClassWithWrongNumberOfTypeArguments.ts_0_302
// it is always an error to provide a type argument list whose count does not match the type parameter list // both of these attempts to construct a type is an error class C<T> { x: T; } var c = new C<number, number>(); class D<T, U> { x: T y: U } // BUG 794238 var d = new D<number>();
{ "end_byte": 302, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiateGenericClassWithWrongNumberOfTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints2.ts_0_116
class C<T extends C<T>> { // error constructor(x: T) { } } var c = new C(1); var c = new C(new C('')); // error
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts_0_2126
// @strict: true // @declaration: true declare let f: { <T>(): T, g<U>(): U }; // Type arguments in member expressions const a1 = f<number>; // { (): number; g<U>(): U; } const a2 = f.g<number>; // () => number const a3 = f<number>.g; // <U>() => U const a4 = f<number>.g<number>; // () => number const a5 = f['g'...
{ "end_byte": 2126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints3.ts_0_327
// no errors expected class C<T extends { length: number }> { constructor(x: T) { } foo<U extends T>(x: U) { function bar<V extends U>(x: V) { return x; } return bar; } } var c = new C({ length: 2 }); var r = c.foo({ length: 3, charAt: (x: number) => { '' } }); var r2 =...
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints3.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny2.ts_0_286
// errors expected for type parameter cannot be referenced in the constraints of the same list // any is not a valid type argument unless there is no constraint, or the constraint is any declare function foo<Z, T extends <U>(x: U) => Z>(y: T): Z; var a: any; foo(a); foo<any, any>(a);
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/callNonGenericFunctionWithTypeArguments.ts_0_696
// it is always illegal to provide type arguments to a non-generic function // all invocations here are illegal function f(x: number) { return null; } var r = f<string>(1); var f2 = (x: number) => { return null; } var r2 = f2<string>(1); var f3: { (x: number): any; } var r3 = f3<string>(1); class C { f(x: numbe...
{ "end_byte": 696, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/callNonGenericFunctionWithTypeArguments.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts_0_814
// satisfaction of a constraint to Function, all of these invocations are errors unless otherwise noted function foo<T extends Function>(x: T): T { return x; } foo(1); foo(() => { }, 1); foo(1, () => { }); function foo2<T extends (x: string) => string>(x: T): T { return x; } class C { foo: string; } var b: { n...
{ "end_byte": 814, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithEmptyObject.ts_0_562
// valid uses of a basic object constraint, no errors expected // Object constraint function foo<T extends Object>(x: T) { } var r = foo({}); var a = {}; var r = foo({}); class C<T extends Object> { constructor(public x: T) { } } var r2 = new C({}); interface I<T extends Object> { x: T; } var i: I<{}>; // ...
{ "end_byte": 562, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithEmptyObject.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction3.ts_0_795
// satisfaction of a constraint to Function, no errors expected function foo<T extends (x: string) => string>(x: T): T { return x; } interface I { (): string; } var i: I; class C { foo: string; } var a: { (): string }; var b: { new (): string }; var c: { (): string; (x): string }; var r1 = foo((x) => x); v...
{ "end_byte": 795, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction3.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts_0_655
class C<U extends T, T extends U> { } class C2<T extends U, U extends V, V extends T> { } interface I<U extends T, T extends U> { } interface I2<T extends U, U extends V, V extends T> { } function f<U extends T, T extends U>() { } function f2<T extends U, U extends V, V extends T>() { } var a: { <U extends T, T ...
{ "end_byte": 655, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts_0_3554
// @strict: true // @declaration: true type Covariant<out T> = { x: T; } declare let super_covariant: Covariant<unknown>; declare let sub_covariant: Covariant<string>; super_covariant = sub_covariant; sub_covariant = super_covariant; // Error type Contravariant<in T> = { f: (x: T) => void; } declare let s...
{ "end_byte": 3554, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typesWithDuplicateTypeParameters.ts_0_139
class C<T, T> { } class C2<T, U, T> { } interface I<T, T> { } interface I2<T, U, T> { } function f<T, T>() { } function f2<T, U, T>() { }
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typesWithDuplicateTypeParameters.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiersWithIntersection.ts_0_416
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55778 interface Config<T1 extends { type: string }> { useIt: T1; } declare function test< T1 extends { type: string }, const TConfig extends Config<T1>, >(config: { produceThing: T1 } & TConfig): TConfig; const result = test({...
{ "end_byte": 416, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiersWithIntersection.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints4.ts_0_599
class C<T extends Date> { f() { var x: T; var a = x['notHere'](); // should be string return a + x.notHere(); } } var r = (new C<Date>()).f(); interface I<T extends Date> { foo: T; } var i: I<Date>; var r2 = i.foo.notHere(); var r2b = i.foo['notHere'](); var a: { <T extends Da...
{ "end_byte": 599, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints4.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts_0_839
class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends T, T extends A> { f() { var x: U; var a = x['foo'](); // should be string return a + x.foo() + x.notHere(); } } var r = (new C<B, A>()).f(); interface I<U...
{ "end_byte": 839, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterDirectlyConstrainedToItself.ts_0_357
// all of the below should be errors class C<T extends T> { } class C2<T, U extends U> { } interface I<T extends T> { } interface I2<T, U extends U> { } function f<T extends T>() { } function f2<T, U extends U>() { } var a: { <T extends T>(): void; <T, U extends U>(): void; } var b = <T extends T>() => {...
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterDirectlyConstrainedToItself.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiersReverseMappedTypes.ts_0_840
// @strict: true // @noEmit: true declare function test1<const T>(obj: { [K in keyof T]: T[K]; }): [T, typeof obj]; const result1 = test1({ prop: "foo", nested: { nestedProp: "bar", }, }); declare function test2<const T>(obj: { readonly [K in keyof T]: T[K]; }): [T, typeof obj]; const result2 = test2(...
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiersReverseMappedTypes.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotationsWithCircularlyReferencesError.ts_0_147
// @strict: true // @declaration: true type T1<in in> = T1 // Error: circularly references type T2<out out> = T2 // Error: circularly references
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotationsWithCircularlyReferencesError.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts_0_519
class C<T> { f() { var x: T; var a = x['toString'](); // should be string return a + x.toString(); } } var r = (new C<number>()).f(); interface I<T> { foo: T; } var i: I<number>; var r2 = i.foo.toString(); var r2b = i.foo['toString'](); var a: { <T>(): T; } var r3: string = a(...
{ "end_byte": 519, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/staticMembersUsingClassTypeParameter.ts_0_197
// BUG 745747 class C<T> { static x: T; static f(x: T) {} } class C2<T, U> { static x: U; static f(x: U) { } } class C3<T extends Date> { static x: T; static f(x: T) { } }
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/staticMembersUsingClassTypeParameter.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints.ts_0_645
// generic types should behave as if they have properties of their constraint type // no errors expected class C<T extends Date> { f() { var x: T; var a = x['getDate'](); // number return a + x.getDate(); } } var r = (new C<Date>()).f(); interface I<T extends Date> { foo: T; } va...
{ "end_byte": 645, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope3.ts_0_284
// @declaration: true function foo<T>(v: T) { function a<T>(a: T) { return a; } function b(): T { return v; } function c<T>(v: T) { function a<T>(a: T) { return a; } function b(): T { return v; } return { a, b }; } return { a, b, c }; }
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope3.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope2.ts_0_176
function foo<T, U>(x: T, y: U) { function bar<V>(z: V) { function baz<W>(a: W) { var c: T; var d: U; var e: V; } } }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterUsedAsConstraint.ts_0_1267
class C<T, U extends T> { } class C2<T extends U, U> { } class C3<T extends Date, U extends T> { } class C4<T extends U, U extends Date> { } class C5<T extends U, U extends V, V> { } class C6<T, U extends T, V extends U> { } interface I<T, U extends T> { } interface I2<T extends U, U> { } interface I3<T extends Date, ...
{ "end_byte": 1267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterUsedAsConstraint.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope.ts_0_294
class C<T> { data: T; x = <U>(a: U) => { var y: T; return y; } foo() { function temp<U>(a: U) { var y: T; return y; } return temp(<T>null); } } var c = new C<number>(); c.data = c.x(null); c.data = c.foo();
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParametersAvailableInNestedScope.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/innerTypeParameterShadowingOuterOne2.ts_0_636
// inner type parameters shadow outer ones of the same name // no errors expected class C<T extends Date> { g<T extends Number>() { var x: T; x.toFixed(); } h() { var x: T; x.getDate(); } } class C2<T extends Date, U extends Date> { g<T extends Number, U extends Nu...
{ "end_byte": 636, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/innerTypeParameterShadowingOuterOne2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/innerTypeParameterShadowingOuterOne.ts_0_599
// inner type parameters shadow outer ones of the same name // no errors expected function f<T extends Date>() { function g<T extends Number>() { var x: T; x.toFixed(); } var x: T; x.getDate(); } function f2<T extends Date, U extends Date>() { function g<T extends Number, U extends...
{ "end_byte": 599, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/innerTypeParameterShadowingOuterOne.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints2.ts_0_1820
// generic types should behave as if they have properties of their constraint type class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends A, T extends A> { f() { var x: U; var a = x['foo'](); // should be string re...
{ "end_byte": 1820, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints2.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts_0_1362
// generic types should behave as if they have properties of their constraint type class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends A, T extends U> { f() { var x: T; // BUG 823818 var a = x['foo'](); // shoul...
{ "end_byte": 1362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts" }
TypeScript/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiers.ts_0_5202
// @strict: true declare function f1<const T>(x: T): T; const x11 = f1('a'); const x12 = f1(['a', ['b', 'c']]); const x13 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); declare function f2<const T, U>(x: T | undefined): T; const x21 = f2('a'); const x22 = f2(['a', ['b', 'c']]); const x23 = f2({ a: 1, b: "c"...
{ "end_byte": 5202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiers.ts" }