_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes5.ts_0_502 | // @strict: true
// @target: esnext
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/55364
interface TypeMap {
a: "A";
b: "B";
}
declare const f: <T0 extends "a" | "b">(x: `${T0}`) => TypeMap[T0];
type F1 = <T1 extends "a" | "b">(x: `${T1}`) => TypeMap[T1];
const f1: F1 = f;
type F2 = <T2 extend... | {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes5.ts"
} |
TypeScript/tests/cases/conformance/types/literal/enumLiteralTypes3.ts_0_2283 | const enum Choice { Unknown, Yes, No };
type Yes = Choice.Yes;
type YesNo = Choice.Yes | Choice.No;
type NoYes = Choice.No | Choice.Yes;
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
a = a;
a = b;
a = c;
a = d;
}
function f2(a... | {
"end_byte": 2283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/enumLiteralTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/literal/literalTypesAndTypeAssertions.ts_0_283 | const obj = {
a: "foo" as "foo",
b: <"foo">"foo",
c: "foo"
};
let x1 = 1 as (0 | 1);
let x2 = 1;
let { a = "foo" } = { a: "foo" };
let { b = "foo" as "foo" } = { b: "bar" };
let { c = "foo" } = { c: "bar" as "bar" };
let { d = "foo" as "foo" } = { d: "bar" as "bar" };
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/literalTypesAndTypeAssertions.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringMappingOverPatternLiterals.ts_0_3650 | // non-template
type A = "aA";
type B = Uppercase<A>;
type C = Lowercase<A>;
// templated
type ATemplate = `aA${string}`;
type BTemplate = Uppercase<ATemplate>;
type CTemplate = Lowercase<ATemplate>;
function f1(
a: A,
b: B,
c: C,
a_template: ATemplate,
b_template: BTemplate,
c_template: CTemp... | {
"end_byte": 3650,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringMappingOverPatternLiterals.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks02.ts_3_312 | t x: "foo";
let y: "foo" | "bar";
let b: boolean;
b = x == y;
b = "foo" == y
b = y == "foo";
b = "foo" == "bar";
b = "bar" == x;
b = x == "bar";
b = y == "bar";
b = "bar" == y;
b = x != y;
b = "foo" != y
b = y != "foo";
b = "foo" != "bar";
b = "bar" != x;
b = x != "bar";
b = y != "bar";
b = "bar" != y;
| {
"end_byte": 312,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks02.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes1.ts_0_5627 | // @strict: true
// @declaration: true
// Template types example from #12754
const createScopedActionType = <S extends string>(scope: S) => <T extends string>(type: T) => `${scope}/${type}` as `${S}/${T}`;
const createActionInMyScope = createScopedActionType("MyScope"); // <T extends string>(type: T) => `MyScope/${T... | {
"end_byte": 5627,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes1.ts_5629_9326 | declare function getPropValue<T, P extends string>(obj: T, path: P): PropType<T, P>;
declare const s: string;
const obj = { a: { b: {c: 42, d: 'hello' }}};
getPropValue(obj, 'a'); // { b: {c: number, d: string } }
getPropValue(obj, 'a.b'); // {c: number, d: string }
getPropValue(obj, 'a.b.d'); // string
getPropVal... | {
"end_byte": 9326,
"start_byte": 5629,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements04.ts_3_373 | t x: "foo";
let y: "foo" | "bar";
declare function randBool(): boolean;
switch (y) {
case "foo", x:
break;
case x, "foo":
break;
case x, "baz":
break;
case "baz", x:
break;
case "baz" && "bar":
break;
case "baz" && ("foo" || "bar"):
break;
c... | {
"end_byte": 373,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements04.ts"
} |
TypeScript/tests/cases/conformance/types/literal/enumLiteralTypes2.ts_0_2129 | // @strictNullChecks: true
const enum Choice { Unknown, Yes, No };
type YesNo = Choice.Yes | Choice.No;
type NoYes = Choice.No | Choice.Yes;
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
function f1() {
var a: YesNo;
var a: NoYes;
var a: Choice.Yes | Choice.No;
var a: Choice.No | Choic... | {
"end_byte": 2129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/enumLiteralTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/literal/literalTypesWidenInParameterPosition.ts_0_162 | class D {
readonly noWiden = 1
constructor(readonly widen = 2) {
this.noWiden = 5; // error
this.widen = 6; // ok
}
}
new D(7); // ok
| {
"end_byte": 162,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/literalTypesWidenInParameterPosition.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringMappingReduction.ts_0_1184 | // @strict: true
// @noEmit: true
type T00 = "prop" | `p${Lowercase<string>}p`; // `p${Lowercase<string>}p`
type T01 = "prop" | Lowercase<string>; // Lowercase<string>
type T02 = "PROP" | Lowercase<string>; // "PROP" | Lowercase<string>
type T10 = "prop" & `p${Lowercase<string>}p`; // "prop"
type T11 = "prop" & L... | {
"end_byte": 1184,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringMappingReduction.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts_3_458 | terface Runnable {
isRunning: boolean;
}
interface Refrigerator extends Runnable {
makesFoodGoBrrr: boolean;
}
let x: string;
let y: "foo" | Refrigerator;
let b: boolean;
b = x === y;
b = "foo" === y
b = y === "foo";
b = "foo" === "bar";
b = "bar" === x;
b = x === "bar";
b = y === "bar";
b = "bar" === y;
b ... | {
"end_byte": 458,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes4.ts_0_6760 | // @strict: true
// @target: esnext
// @declaration: true
// infer from number
type TNumber0 = "100" extends `${infer N extends number}` ? N : never; // 100
type TNumber1 = "-100" extends `${infer N extends number}` ? N : never; // -100
type TNumber2 = "1.1" extends `${infer N extends number}` ? N : never; // 1.1
type... | {
"end_byte": 6760,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes4.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes4.ts_6761_13586 | type PStringLiteral04 = "0" extends `${infer T extends "0" | bigint}` ? T : never; // "0"
// string-literal > bigint-literal
type PStringLiteral05 = "0" extends `${infer T extends "0" | 0n}` ? T : never; // "0"
// string-literal > boolean
type PStringLiteral06 = "true" extends `${infer T extends "true" | "false" | bo... | {
"end_byte": 13586,
"start_byte": 6761,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes4.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes4.ts_13588_15600 | // Generates ordinal members like `{ 0: number, 1: bigint }` from `[{ name: "x", type: "i32" }, { name: "y", type: "i64" }]`
type TypedObjectOrdinalMembers<TDef extends readonly FieldDefinition[]> = {
[I in Extract<keyof TDef, `${number}`>]: FieldType<Extract<TDef[I], FieldDefinition>["type"]>;
};
// Default membe... | {
"end_byte": 15600,
"start_byte": 13588,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes4.ts"
} |
TypeScript/tests/cases/conformance/types/literal/enumLiteralTypes1.ts_0_2087 | const enum Choice { Unknown, Yes, No };
type YesNo = Choice.Yes | Choice.No;
type NoYes = Choice.No | Choice.Yes;
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
function f1() {
var a: YesNo;
var a: NoYes;
var a: Choice.Yes | Choice.No;
var a: Choice.No | Choice.Yes;
}
function f2(a: Yes... | {
"end_byte": 2087,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/enumLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes3.ts_0_5437 | // @strict: true
// @declaration: true
// Inference from template literal type to template literal type
type Foo1<T> = T extends `*${infer U}*` ? U : never;
type T01 = Foo1<'hello'>;
type T02 = Foo1<'*hello*'>;
type T03 = Foo1<'**hello**'>;
type T04 = Foo1<`*${string}*`>;
type T05 = Foo1<`*${number}*`>;
type T06 = F... | {
"end_byte": 5437,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsAssignedToStringMappings.ts_0_174 | declare var x: Uppercase<Lowercase<string>>;
// good
x = "A";
// bad
x = "a";
declare var y: Uppercase<Lowercase<`${number}`>>;
// good
y = "1";
// bad
y = "a";
y = "A"; | {
"end_byte": 174,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsAssignedToStringMappings.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts_3_491 | t x: "foo";
let y: "foo" | "bar";
let z: "bar";
declare function randBool(): boolean;
switch (x) {
case randBool() ? "foo" : "baz":
break;
case (randBool() ? ("bar") : "baz" ? "bar" : "baz"):
break;
case (("bar")):
break;
case (x, y, ("baz")):
x;
y;
bre... | {
"end_byte": 491,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts_3_442 | terface Runnable {
isRunning: boolean;
}
interface Refrigerator extends Runnable {
makesFoodGoBrrr: boolean;
}
let x: string;
let y: "foo" | Refrigerator;
let b: boolean;
b = x == y;
b = "foo" == y
b = y == "foo";
b = "foo" == "bar";
b = "bar" == x;
b = x == "bar";
b = y == "bar";
b = "bar" == y;
b = x != y... | {
"end_byte": 442,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes7.ts_0_468 | // @strict: true
// @target: esnext
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/57807
interface NMap {
1: 'A'
2: 'B'
3: 'C'
4: 'D'
}
declare const g: <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T]
type G1 = <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T]
const g1: G1 = g; // ok
type G2 = <T... | {
"end_byte": 468,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes7.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements02.ts_3_184 | t x: "foo";
let y: "foo" | "bar";
let b: boolean;
b = x == y;
b = "foo" == y
b = y == "foo";
b = "foo" == "bar";
b = x != y;
b = "foo" != y
b = y != "foo";
b = "foo" != "bar";
| {
"end_byte": 184,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements02.ts"
} |
TypeScript/tests/cases/conformance/types/literal/booleanLiteralTypes1.ts_0_1587 | type A1 = true | false;
type A2 = false | true;
function f1() {
var a: A1;
var a: A2;
var a: true | false;
var a: false | true;
}
function f2(a: true | false, b: boolean) {
a = b;
b = a;
}
function f3(a: true | false, b: true | false) {
var x = a || b;
var x = a && b;
var x = !a;
... | {
"end_byte": 1587,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/booleanLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts_0_5499 | // @strict: true
type RequiresLeadingSlash = `/${string}`;
// ok
const a: RequiresLeadingSlash = "/bin";
// not ok
const b: RequiresLeadingSlash = "no slash";
type Protocol<T extends string, U extends string> = `${T}://${U}`;
function download(hostSpec: Protocol<"http" | "https" | "ftp", string>) { }
// ok, has prot... | {
"end_byte": 5499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypesPatterns.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes6.ts_0_485 | // @strict: true
// @target: esnext
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/56659
type Registry = {
a: { a1: {} };
b: { b1: {} };
};
type Keyof<T> = keyof T & string;
declare function f1<
Scope extends Keyof<Registry>,
Event extends Keyof<Registry[Scope]>,
>(eventPath: `${Scope}:$... | {
"end_byte": 485,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes6.ts"
} |
TypeScript/tests/cases/conformance/types/literal/literalTypesAndDestructuring.ts_0_366 | // @strict: true
declare let x: { a: 0 | 1 | undefined };
let { a: a1 } = x;
let { a: a2 = 0 } = x;
let { a: a3 = 2 } = x;
let { a: a4 = 2 as const } = x;
let b1 = x.a;
let b2 = x.a ?? 0;
let b3 = x.a ?? 2;
let b4 = x.a ?? 2 as const;
// Repro from #35693
interface Foo {
bar: 'yo' | 'ha' | undefined;
}
let { ba... | {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/literalTypesAndDestructuring.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks01.ts_3_328 | t x: "foo";
let y: "foo" | "bar";
let b: boolean;
b = x === y;
b = "foo" === y
b = y === "foo";
b = "foo" === "bar";
b = "bar" === x;
b = x === "bar";
b = y === "bar";
b = "bar" === y;
b = x !== y;
b = "foo" !== y
b = y !== "foo";
b = "foo" !== "bar";
b = "bar" !== x;
b = x !== "bar";
b = y !== "bar";
b = "bar" !== y... | {
"end_byte": 328,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks01.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes2.ts_0_3502 | // @strict: true
// @declaration: true
function ft1<T extends string>(s: string, n: number, u: 'foo' | 'bar' | 'baz', t: T) {
const c1 = `abc${s}`;
const c2 = `abc${n}`;
const c3 = `abc${u}`;
const c4 = `abc${t}`;
const d1: `abc${string}` = `abc${s}`;
const d2: `abc${number}` = `abc${n}`;
c... | {
"end_byte": 3502,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringEnumLiteralTypes1.ts_0_1882 | const enum Choice { Unknown = "", Yes = "yes", No = "no" };
type YesNo = Choice.Yes | Choice.No;
type NoYes = Choice.No | Choice.Yes;
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
function f1() {
var a: YesNo;
var a: NoYes;
var a: Choice.Yes | Choice.No;
var a: Choice.No | Choice.Yes;
}... | {
"end_byte": 1882,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringEnumLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/literalTypes2.ts_0_3914 | enum E {
A, B, C
}
let cond: boolean;
function f1(p1 = 1, p2 = "abc", p3 = true, p4 = E.A) {
var v1 = 1;
var v2 = -123;
var v3 = 3 + 4;
var v4 = "abc";
var v5 = "";
var v6 = "abc" + "def";
var v7 = true;
var v8 = E.A;
let x1 = 1;
let x2 = -123;
let x3 = 3 + 4;
let x... | {
"end_byte": 3914,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/literalTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/literal/numericStringLiteralTypes.ts_0_1211 | // @strict: true
// @declaration: true
type T0 = string & `${string}`; // string
type T1 = string & `${number}`; // `${number}
type T2 = string & `${bigint}`; // `${bigint}
type T3<T extends string> = string & `${T}`; // `${T}
type T4<T extends string> = string & `${Capitalize<`${T}`>}`; // `${Capitalize<T>}`
fu... | {
"end_byte": 1211,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/numericStringLiteralTypes.ts"
} |
TypeScript/tests/cases/conformance/types/literal/numericLiteralTypes1.ts_0_2273 | type A1 = 1;
type A2 = 1.0;
type A3 = 1e0;
type A4 = 10e-1;
type A5 = 1 | 1.0 | 1e0 | 10e-1;
function f1() {
var a: A1 = 1;
var a: A2 = 1;
var a: A3 = 1;
var a: A4 = 1;
var a: A5 = 1;
}
type B1 = -1 | 0 | 1;
type B2 = 1 | 0 | -1;
type B3 = 0 | -1 | 1;
function f2() {
var b: B1 = -1;
var b... | {
"end_byte": 2273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/numericLiteralTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypesPatternsPrefixSuffixAssignability.ts_0_191 | const s1: `:${string}:` = ":"; // should error
const s2: `:${string}:` = "::"; // ok
const s3: `:${string}:${string}:` = "::"; // should error
const s4: `:${string}:${string}:` = ":::"; // ok | {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypesPatternsPrefixSuffixAssignability.ts"
} |
TypeScript/tests/cases/conformance/types/literal/literalTypes3.ts_0_1233 | // @strictNullChecks: true
function f1(s: string) {
if (s === "foo") {
s; // "foo"
}
if (s === "foo" || s === "bar") {
s; // "foo" | "bar"
}
}
function f2(s: string) {
switch (s) {
case "foo":
case "bar":
s; // "foo" | "bar"
case "baz":
... | {
"end_byte": 1233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/literalTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons01.ts_3_105 | r a = "foo" === "bar" as string;
var b = "foo" !== ("bar" as string);
var c = "foo" == (<any>"bar"); | {
"end_byte": 105,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons01.ts"
} |
TypeScript/tests/cases/conformance/types/literal/templateLiteralTypes8.ts_0_168 | // @strict: true
// @noEmit: true
const enum E {
a = "a",
b = "b",
}
type Stringify<T extends string> = `${T}`;
let z1: `${E}` = "a";
let z2: Stringify<E> = "a"; | {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes8.ts"
} |
TypeScript/tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts_3_195 | t fooOrBar: "foo" | "bar";
let a = "foo" as "bar";
let b = "bar" as "foo";
let c = fooOrBar as "foo";
let d = fooOrBar as "bar";
let e = fooOrBar as "baz";
let f = "baz" as typeof fooOrBar; | {
"end_byte": 195,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts"
} |
TypeScript/tests/cases/conformance/types/localTypes/localTypes3.ts_0_721 | function f1() {
function f() {
class C<X, Y> {
constructor(public x: X, public y: Y) { }
}
return C;
}
let C = f();
let v = new C(10, "hello");
let x = v.x;
let y = v.y;
}
function f2() {
function f<X>(x: X) {
class C<Y> {
public x = x... | {
"end_byte": 721,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/localTypes/localTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/localTypes/localTypes2.ts_0_718 | function f1() {
function f() {
class C {
constructor(public x: number, public y: number) { }
}
return C;
}
let C = f();
let v = new C(10, 20);
let x = v.x;
let y = v.y;
}
function f2() {
function f(x: number) {
class C {
public x = x;
... | {
"end_byte": 718,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/localTypes/localTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/localTypes/localTypes5.ts_0_297 | function foo<A>() {
class X {
m<B, C>() {
return (function <D>() {
class Y<E> {
}
return new Y<string>();
})<Date>();
}
}
var x = new X();
return x.m<number, boolean>();
}
var x = foo<void>();
| {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/localTypes/localTypes5.ts"
} |
TypeScript/tests/cases/conformance/types/localTypes/localTypes1.ts_0_2240 | // @target: es5
function f1() {
enum E {
A, B, C
}
class C {
x: E;
}
interface I {
x: E;
}
type A = I[];
let a: A = [new C()];
a[0].x = E.B;
return a;
}
function f2() {
function g() {
enum E {
A, B, C
}
class C {
... | {
"end_byte": 2240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/localTypes/localTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/localTypes/localTypes4.ts_0_767 | // @allowUnreachableCode: true
function f1() {
// Type parameters are in scope in parameters and return types
function f<T>(x: T): T {
return undefined;
}
}
function f2() {
// Local types are not in scope in parameters and return types
function f(x: T): T {
interface T { }
... | {
"end_byte": 767,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/localTypes/localTypes4.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts_0_217 | interface Real {
method(this: this, n: number): void;
data: string;
}
interface Fake {
method(this: this, n: number): void;
data: number;
}
function test(r: Real | Fake) {
r.method(12); // error
}
| {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts_0_147 | declare class Base {
check<TProp extends this>(prop: TProp): boolean;
}
class Test extends Base {
m() {
this.check(this);
}
}
| {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts_0_5887 | // @target: es6
class C {
n: number;
explicitThis(this: this, m: number): number {
return this.n + m;
}
implicitThis(m: number): number {
return this.n + m;
}
explicitC(this: C, m: number): number {
return this.n + m;
}
explicitProperty(this: {n: number}, m: numb... | {
"end_byte": 5887,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeErrors2.ts_0_206 | class Base {
constructor(a: this) {
}
}
class Generic<T> {
}
class Derived {
n: number;
constructor(public host: Generic<this>) {
let self: this = this;
this.n = 12;
}
}
| {
"end_byte": 206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeErrors2.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts_0_165 | // @declaration: true
interface BoxOfFoo<T extends Foo> {
item: T
}
interface Foo {
self: this;
}
interface Bar extends Foo {
other: BoxOfFoo<this>;
} | {
"end_byte": 165,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts_0_1365 | // @noImplicitAny: true
// @noImplicitThis: true
interface IndexedWithThis {
// this is a workaround for React
init?: (this: this) => void;
willDestroy?: (this: any) => void;
[propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any);
}
interfac... | {
"end_byte": 1365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts_0_434 | interface I1 {
x: this;
f(x: this): this;
}
interface I2 {
(x: this): this;
new (x: this): this;
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
interface I3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;... | {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts_0_379 | // @noImplicitAny: true
// @noImplicitThis: true
// @target: es5
interface Foo {
n: number;
x: number;
}
interface Bar {
wrong: "place" | "time" | "method" | "technique";
}
const mismatch = {
n: 13,
get x(this: Foo) { return this.n; },
set x(this: Bar, n) { this.wrong = "method"; }
}
const conte... | {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInTaggedTemplateCall.ts_0_172 | // @target: esnext
class Foo {
static m<T>(this: new () => T, strings: TemplateStringsArray | string) {
return new this()
}
}
Foo.m`test`;
(Foo.m)`test`;
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInTaggedTemplateCall.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeAccessibility.ts_0_1350 | class MyClass {
private p: number = 123;
protected pp: number = 123;
public ppp: number = 123;
private static sp: number = 123;
protected static spp: number = 123;
public static sppp: number = 123;
}
interface MyClass {
extension1(p: number): void;
extension2(p: number): void;
exten... | {
"end_byte": 1350,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeAccessibility.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/declarationFiles.ts_0_723 | // @declaration: true
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x:... | {
"end_byte": 723,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/declarationFiles.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/fluentInterfaces.ts_0_177 | interface A {
foo(): this;
}
interface B extends A {
bar(): this;
}
interface C extends B {
baz(): this;
}
var c: C;
var z = c.foo().bar().baz(); // Fluent pattern
| {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/fluentInterfaces.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/typeRelationships.ts_0_870 | class C {
self = this;
c = new C();
foo() {
return this;
}
f1() {
this.c = this.self;
this.self = this.c; // Error
}
f2() {
var a: C[];
var a = [this, this.c]; // C[] since this is subtype of C
var b: this[];
var b = [this, this.self,... | {
"end_byte": 870,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/typeRelationships.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts_0_4672 | // @declaration: true
// @strict: true
// @target: es5
// In methods of an object literal with no contextual type, 'this' has the type
// of the object literal.
let obj1 = {
a: 1,
f() {
return this.a;
},
b: "hello",
c: {
g() {
this.g();
}
},
get d() {
... | {
"end_byte": 4672,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts_0_1430 | // @noImplicitAny: true
// @noImplicitThis: true
interface I {
n: number;
explicitThis(this: this, m: number): number;
}
interface Unused {
implicitNoThis(m: number): number;
}
class C implements I {
n: number;
explicitThis(this: this, m: number): number {
return this.n + m;
}
impli... | {
"end_byte": 1430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/contextualThisTypeInJavascript.ts_0_236 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: context.js
const obj = {
prop: 2,
method() {
this;
this.prop;
this.method;
this.unknown; // ok, obj has a string indexer
}
}
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/contextualThisTypeInJavascript.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeErrors.ts_0_894 | var x1: this;
var x2: { a: this };
var x3: this[];
function f1(x: this): this {
var y: this;
return this;
}
interface I1 {
a: { x: this };
b: { (): this };
c: { new (): this };
d: { [x: string]: this };
e: { f(x: this): this };
}
class C1 {
a: { x: this };
b: { (): this };
c: ... | {
"end_byte": 894,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeErrors.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/contextualThisType.ts_0_137 | interface X {
a: (p: this) => this;
}
interface Y extends X {
}
var x: Y = {
a(p) {
return p;
}
}
var y = x.a(x);
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/contextualThisType.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInTypePredicate.ts_0_141 | declare function filter<S>(f: (this: void, x: any) => x is S): S[];
const numbers = filter<number>((x): x is number => 'number' == typeof x)
| {
"end_byte": 141,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInTypePredicate.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInTuples.ts_0_146 | interface Array<T> {
slice(): this;
}
let t: [number, string] = [42, "hello"];
let a = t.slice();
let b = t.slice(1);
let c = t.slice(0, 1);
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInTuples.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeOptionalCall.ts_0_266 | // @strictNullChecks: true
// @noImplicitAny: true
// @noImplicitThis: true
// @strictBindCallApply: false
function maybeBind<T, A extends any[], R>(obj: T, fn: ((this: T, ...args: A) => R) | undefined): ((...args: A) => R) | undefined {
return fn?.bind(obj);
} | {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeOptionalCall.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeSyntacticContext.ts_0_192 | function f(this: { n: number }) {
}
const o: { n: number, test?: (this: { n: number }) => void } = { n: 1 }
o.test = f
o.test();
o!.test();
o.test!();
o.test!!!();
(o.test!)();
(o.test)();
| {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeSyntacticContext.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInAccessors.ts_0_835 | // @noImplicitAny: true
// @noImplicitThis: true
// @target: es5
interface Foo {
n: number;
x: number;
}
const explicit = {
n: 12,
get x(this: Foo): number { return this.n; },
set x(this: Foo, n: number) { this.n = n; }
}
const copiedFromGetter = {
n: 14,
get x(this: Foo): number { return t... | {
"end_byte": 835,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInAccessors.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/fluentClasses.ts_0_231 | class A {
foo() {
return this;
}
}
class B extends A {
bar() {
return this;
}
}
class C extends B {
baz() {
return this;
}
}
var c: C;
var z = c.foo().bar().baz(); // Fluent pattern
| {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/fluentClasses.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts_0_669 | // @noImplicitAny: true
// @noImplicitThis: true
let o = {
d: "bar",
m() {
return this.d.length;
},
f: function() {
return this.d.length;
}
}
let mutuallyRecursive = {
a: 100,
start() {
return this.passthrough(this.a);
},
passthrough(n: number) {
ret... | {
"end_byte": 669,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/inferThisType.ts_0_414 | declare function f<T>(g: (this: T) => void): T
declare function h(this: number): void;
f(h)
// works with infer types as well
type Check<T> = T extends (this: infer U, ...args: any[]) => any ? string : unknown;
type r1 = Check<(this: number) => void>; // should be string
type This<T> = T extends (this: infer U, ...a... | {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/inferThisType.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts_0_6159 | // body checking
class B {
n: number;
}
class C {
n: number;
explicitThis(this: this, m: number): number {
return this.n + m;
}
explicitC(this: C, m: number): number {
return this.n + m;
}
explicitProperty(this: {n: number}, m: number): number {
return this.n + m;
... | {
"end_byte": 6159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeAndConstraints.ts_0_296 | class A {
self() {
return this;
}
}
function f<T extends A>(x: T) {
function g<U extends T>(x: U) {
x = x.self();
}
x = x.self();
}
class B<T extends A> {
foo(x: T) {
x = x.self();
}
bar<U extends T>(x: U) {
x = x.self();
}
}
| {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeAndConstraints.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInClasses.ts_0_855 | class C1 {
x: this;
f(x: this): this { return undefined; }
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h:... | {
"end_byte": 855,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInClasses.ts"
} |
TypeScript/tests/cases/conformance/types/thisType/thisTypeInFunctions4.ts_0_424 | type WrongObject = {value: number};
type CorrectObject = {name: string};
declare function isCorrect(obj: any): obj is CorrectObject
declare function callsCallback(cb: (name: string)=>void)
function problemFunction(this: CorrectObject | WrongObject): void {
//check type
if (!isCorrect(this)) return;
call... | {
"end_byte": 424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/thisType/thisTypeInFunctions4.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/objectTypeLiteralSyntax2.ts_0_146 | var x: {
foo: string,
bar: string
}
// ASI makes this work
var y: {
foo: string
bar: string
}
var z: { foo: string bar: string } | {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/objectTypeLiteralSyntax2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/objectTypeLiteralSyntax.ts_0_89 | var x: {
foo: string;
bar: string;
}
var y: {
foo: string;
bar: string
} | {
"end_byte": 89,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/objectTypeLiteralSyntax.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithIdenticalOverloads.ts_0_959 | // Duplicate overloads of construct signatures should generate errors
class C {
constructor(x: number, y: string);
constructor(x: number, y: string); // error
constructor(x: number) { }
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T, y: string);
constructor(x: T, y: string); // error
... | {
"end_byte": 959,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithIdenticalOverloads.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads.ts_0_894 | // No errors expected for basic overloads of construct signatures
class C {
constructor(x: number, y?: string);
constructor(x: number, y: string);
constructor(x: number) { }
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T, y?: string);
constructor(x: T, y: string);
constructor(x: T) {... | {
"end_byte": 894,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloadsThatDifferOnlyByReturnType.ts_0_644 | // Error for construct signature overloads to differ only by return type
class C {
constructor(x: number) { }
}
class C2<T> {
constructor(x: T, y?: string) { }
}
interface I {
new(x: number, y: string): C;
new(x: number, y: string): C2<number>; // error
}
interface I2<T> {
new (x: T, y: string):... | {
"end_byte": 644,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloadsThatDifferOnlyByReturnType.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts_0_722 | // No errors expected for basic overloads of construct signatures with merged declarations
// clodules
class C {
constructor(x: number, y?: string);
constructor(x: number, y: string);
constructor(x: number) { }
}
module C {
export var x = 1;
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T... | {
"end_byte": 722,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/functionLiterals.ts_0_1193 | // PropName<TypeParamList>(ParamList):ReturnType is equivalent to PropName: { <TypeParamList>(ParamList): ReturnType }
var b: {
func1(x: number): number; // Method signature
func2: (x: number) => number; // Function type literal
func3: { (x: number): number }; // Object type literal
}
// no ... | {
"end_byte": 1193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/functionLiterals.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/methodSignaturesWithOverloads.ts_0_443 | // Object type literals permit overloads with optionality but they must match
var c: {
func4?(x: number): number;
func4(s: string): string; // error, mismatched optionality
func5?: {
(x: number): number;
(s: string): string;
};
};
var c2: {
func4<T>(x: T): number;
func4? <T>(s:... | {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/methodSignaturesWithOverloads.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts_0_286 | // Illegal attempts to define optional methods
var a: {
x()?: number; // error
}
interface I {
x()?: number; // error
}
class C {
x()?: number; // error
}
interface I2<T> {
x()?: T; // error
}
class C2<T> {
x()?: T; // error
}
var b = {
x()?: 1 // error
} | {
"end_byte": 286,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/methodSignaturesWithOverloads2.ts_0_488 | // Object type literals permit overloads with optionality but they must match
var c: {
func4?(x: number): number;
func4?(s: string): string;
func5?: {
(x: number): number;
(s: string): string;
};
};
// no errors
c.func4 = c.func5;
c.func5 = c.func4;
var c2: {
func4?<T>(x: T): num... | {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/methodSignaturesWithOverloads2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts_0_248 | // Basic uses of optional properties
var a: {
x?: number; // ok
}
interface I {
x?: number; // ok
}
class C {
x?: number; // ok
}
interface I2<T> {
x?: T; // ok
}
class C2<T> {
x?: T; // ok
}
var b = {
x?: 1 // error
} | {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts_0_347 | // Normally it is an error to have multiple overloads which differ only by return type in a single type declaration.
// Here the multiple overloads come from multiple bases.
interface I<T> {
foo(x: number): T;
}
interface A extends I<number>, I<string> { }
var x: A;
// BUG 822524
var r = x.foo(1); // no error
va... | {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint.ts_0_531 | // Type parameters are in scope in their own and other type parameter lists
function foo<T, U extends T>(x: T, y: U): T {
x = y;
return y;
}
function foo2<U extends T, T>(x: T, y: U): T {
x = y;
return y;
}
var f = function <T, U extends T>(x: T, y: U): T {
x = y;
return y;
}
var f2 = functi... | {
"end_byte": 531,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType3.ts_0_356 | // Normally it is an error to have multiple overloads with identical signatures in a single type declaration.
// Here the multiple overloads come from multiple merged declarations.
interface I {
(x: string): string;
}
interface I {
(x: string): number;
}
interface I2<T> {
(x: string): string;
}
interfac... | {
"end_byte": 356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType3.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/parametersWithNoAnnotationAreAny.ts_0_344 | function foo(x) { return x; }
var f = function foo(x) { return x; }
var f2 = (x) => x;
var f3 = <T>(x) => x;
class C {
foo(x) {
return x;
}
}
interface I {
foo(x);
foo2(x, y);
}
var a: {
foo(x);
}
var b = {
foo(x) {
return x;
},
a: function foo(x) {
return x;
... | {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/parametersWithNoAnnotationAreAny.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts_0_1205 | // Rest parameters must be an array type if they have a type annotation,
// user defined subtypes of array do not count, all of these are errors
interface MyThing extends Array<any> { }
interface MyThing2<T> extends Array<T> { }
function foo(...x: MyThing) { }
var f = function foo(...x: MyThing) { }
var f2 = (...x: ... | {
"end_byte": 1205,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts_0_783 | // Duplicate parameter names are always an error
function foo(x, x) { }
var f = function foo(x, x) { }
var f2 = function (x, x) { }
var f3 = (x, x) => { }
var f4 = <T>(x: T, x: T) => { }
function foo2(x: string, x: number) { }
var f5 = function foo(x: string, x: number) { }
var f6 = function (x: string, x: number) { ... | {
"end_byte": 783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureWithOptional.ts_0_73 | declare function f(x?: "hi"): void;
declare function f(x?: string): void; | {
"end_byte": 73,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureWithOptional.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts_0_526 | // Parameter properties are not valid in overloads of constructors
class C {
constructor(public x, private y);
constructor(public x, private y) { }
}
class C2 {
constructor(private x);
constructor(public x) { }
}
class C3 {
constructor(private x);
constructor(private y) { }
}
interface I {
... | {
"end_byte": 526,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutAnnotationsOrBody.ts_0_282 | // Call signatures without a return type annotation and function body return 'any'
function foo(x) { }
var r = foo(1); // void since there's a body
interface I {
();
f();
}
var i: I;
var r2 = i();
var r3 = i.f();
var a: {
();
f();
};
var r4 = a();
var r5 = a.f(); | {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutAnnotationsOrBody.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts_0_398 | // Rest parameters without type annotations are 'any', errors only for the functions with 2 rest params
function foo(...x) { }
var f = function foo(...x) { }
var f2 = (...x, ...y) => { }
class C {
foo(...x) { }
}
interface I {
(...x);
foo(...x, ...y);
}
var a: {
(...x);
foo(...x);
}
var b = {
... | {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts_0_1280 | // Type parameters are in scope in their own and other type parameter lists
// Some negative cases
class C<T, U extends T, V extends U> {
z: W; // error
foo<W extends V>(x: W): T {
var r: T;
return x;
}
}
interface I<T, U extends T, V extends U> {
x: T;
y: U;
z: W; // error
... | {
"end_byte": 1280,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithAccessibilityModifiersOnParameters.ts_0_1100 | // Call signature parameters do not allow accessibility modifiers
function foo(public x, private y) { }
var f = function foo(public x, private y) { }
var f2 = function (public x, private y) { }
var f3 = (x, private y) => { }
var f4 = <T>(public x: T, y: T) => { }
function foo2(private x: string, public y: number) { }... | {
"end_byte": 1100,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithAccessibilityModifiersOnParameters.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts_0_803 | // @declaration: true
function foo(x: 'a');
function foo(x: number) { }
class C {
foo(x: 'a');
foo(x: number);
foo(x: any) { }
}
class C2<T> {
foo(x: 'a');
foo(x: T);
foo(x: any) { }
}
class C3<T extends String> {
foo(x: 'a');
foo(x: T);
foo(x: any) { }
}
interface I {
(x: '... | {
"end_byte": 803,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures.ts_0_398 | // String literal types are only valid in overload signatures
function foo(x: 'hi') { }
var f = function foo(x: 'hi') { }
var f2 = (x: 'hi', y: 'hi') => { }
class C {
foo(x: 'hi') { }
}
interface I {
(x: 'hi');
foo(x: 'hi', y: 'hi');
}
var a: {
(x: 'hi');
foo(x: 'hi');
}
var b = {
foo(x: 'h... | {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsSubtypeOfNonSpecializedSignature.ts_0_1178 | // Specialized signatures must be a subtype of a non-specialized signature
// All the below should not be errors
function foo(x: 'a');
function foo(x: string);
function foo(x: any) { }
class C {
foo(x: 'a');
foo(x: string);
foo(x: any) { }
}
class C2<T> {
foo(x: 'a');
foo(x: string);
foo(x: T... | {
"end_byte": 1178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsSubtypeOfNonSpecializedSignature.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts_0_343 | // Optional parameters allow initializers only in implementation signatures
// All the below declarations are errors
function foo(x = 2);
function foo(x = 1) { }
foo(1);
foo();
class C {
foo(x = 2);
foo(x = 1) { }
}
var c: C;
c.foo();
c.foo(1);
var b = {
foo(x = 1), // error
foo(x = 1) { }, // erro... | {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType.ts_0_543 | // Each pair of signatures in these types has a signature that should cause an error.
// Overloads, generic or not, that differ only by return type are an error.
interface I {
(x): number;
(x): void; // error
<T>(x: T): number;
<T>(x: T): string; // error
}
interface I2 {
<T>(x: T): number;
<T... | {
"end_byte": 543,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.