_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts_0_1068 | // Rest parameters must be an array type if they have a type annotation, errors only for the functions with 2 rest params
function foo(...x: number[]) { }
var f = function foo(...x: number[]) { }
var f2 = (...x: number[], ...y: number[]) => { }
class C {
foo(...x: number[]) { }
}
interface I {
(...x: number[... | {
"end_byte": 1068,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers.ts_0_640 | // Optional parameters allow initializers only in implementation signatures
function foo(x = 1) { }
var f = function foo(x = 1) { }
var f2 = (x: number, y = 1) => { }
foo(1);
foo();
f(1);
f();
f2(1);
f2(1, 2);
class C {
foo(x = 1) { }
}
var c: C;
c.foo();
c.foo(1);
// these are errors
interface I {
(x = 1)... | {
"end_byte": 640,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithOptionalParameters.ts_0_641 | // Optional parameters should be valid in all the below casts
function foo(x?: number) { }
var f = function foo(x?: number) { }
var f2 = (x: number, y?: number) => { }
foo(1);
foo();
f(1);
f();
f2(1);
f2(1, 2);
class C {
foo(x?: number) { }
}
var c: C;
c.foo();
c.foo(1);
interface I {
(x?: number);
foo... | {
"end_byte": 641,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithOptionalParameters.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures.ts_0_391 | // Each pair of call signatures in these types have a duplicate signature error.
// Identical call signatures should generate an error.
interface I {
(x): number;
(x: any): number;
<T>(x: T): T;
<U>(x: U): U; // error
}
interface I2<T> {
(x: T): T;
(x: T): T; // error
}
var a: {
(x): numbe... | {
"end_byte": 391,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts_0_1629 | // @allowUnreachableCode: true
// Call signatures without a return type should infer one from the function body (if present)
// Simple types
function foo(x) {
return 1;
}
var r = foo(1);
function foo2(x) {
return foo(x);
}
var r2 = foo2(1);
function foo3() {
return foo3();
}
var r3 = foo3();
function f... | {
"end_byte": 1629,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterAsTypeArgument.ts_0_457 | // These are all errors because type parameters cannot reference other type parameters from the same list
function foo<T, U>(x: T, y: U) {
foo<U, U>(y, y);
return new C<U,T>();
}
class C<T, U> {
x: T;
}
interface I<T, U> {
x: C<U, T>;
}
//function foo<T, U extends T>(x: T, y: U) {
// foo<U, U>(y,... | {
"end_byte": 457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterAsTypeArgument.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint2.ts_0_1408 | // Type parameters are in scope in their own and other type parameter lists
// Nested local functions
function foo<T, U extends T>(x: T, y: U) {
function bar<V extends T, W extends U>() {
function baz<X extends W, Y extends V>(a: X, b: Y): T {
x = y;
return y;
}
}
}
fun... | {
"end_byte": 1408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures2.ts_0_322 | // Normally it is an error to have multiple overloads with identical signatures in a single type declaration.
// Here the multiple overloads come from multiple bases.
interface Base<T> {
(x: number): string;
}
interface I extends Base<string>, Base<number> { }
interface I2<T> extends Base<string>, Base<number> {... | {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithOptionalParameters2.ts_0_873 | // Optional parameters should be valid in all the below casts
function foo(x?: number);
function foo(x?: number) { }
foo(1);
foo();
function foo2(x: number);
function foo2(x: number, y?: number);
function foo2(x: number, y?: number) { }
foo2(1);
foo2(1, 2);
class C {
foo(x?: number);
foo(x?: number) { }
... | {
"end_byte": 873,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithOptionalParameters2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts_0_494 | // Rest parameters must be an array type if they have a type annotation, so all these are errors
function foo(...x: string) { }
var f = function foo(...x: number) { }
var f2 = (...x: Date, ...y: boolean) => { }
class C {
foo(...x: C) { }
}
interface I {
(...x: string);
foo(...x: number, ...y: number);
}
... | {
"end_byte": 494,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures3.ts_0_384 | // 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, so we do not report errors.
interface I {
(x: number): string;
}
interface I {
(x: number): string;
}
interface I2<T> {
(x: ... | {
"end_byte": 384,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/identicalCallSignatures3.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts_0_684 | // Optional parameters cannot also have initializer expressions, these are all errors
function foo(x?: number = 1) { }
var f = function foo(x?: number = 1) { }
var f2 = (x: number, y? = 1) => { }
foo(1);
foo();
f(1);
f();
f2(1);
f2(1, 2);
class C {
foo(x?: number = 1) { }
}
var c: C;
c.foo();
c.foo(1);
interfa... | {
"end_byte": 684,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint3.ts_0_837 | // Type parameters are in scope in their own and other type parameter lists
// Object types
//class C<T, U extends T, V extends U> {
// x: T;
// y: U;
// z: V;
// foo<W extends V>(x: W): T {
// var r: T;
// return x;
// }
//}
//class C2<V extends U, T, U extends T> {
// x: T;
// y: ... | {
"end_byte": 837,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint3.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts_0_395 | // String literal types are only valid in overload signatures
function foo(x: any);
function foo(x: 'hi') { }
class C {
foo(x: string);
foo(x: 'hi') { }
}
interface I {
(x: 'a');
(x: 'hi');
foo(x: 'a', y: 'a');
foo(x: 'hi', y: 'hi');
}
var a: {
(x: 'hi');
(x: 'a');
foo(x: 'hi');
... | {
"end_byte": 395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters.ts_0_398 | // Parameter properties are only valid in constructor definitions, not even in other forms of construct signatures
class C {
constructor(public x, private y) { }
}
class C2 {
constructor(public x) { }
}
class C3 {
constructor(private x) { }
}
interface I {
new (public x);
}
interface I2 {
new (... | {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts_0_1683 | // String indexer types constrain the types of named properties in their containing type
interface MyNumber extends Number {
foo: number;
}
class C {
[x: number]: string;
constructor() { } // ok
a: string; // ok
b: number; // ok
c: () => {} // ok
"d": string; // ok
"e": number; // ok... | {
"end_byte": 1683,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts_0_1728 | // String indexer types constrain the types of named properties in their containing type
interface MyString extends String {
foo: number;
}
class C {
[x: string]: string;
constructor() { } // ok
a: string; // ok
b: number; // error
c: () => {} // error
"d": string; // ok
"e": number;... | {
"end_byte": 1728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts_0_462 | // Multiple indexers of the same type are an error
class C {
[x: number]: string;
[x: number]: string;
}
interface I {
[x: number]: string;
[x: number]: string;
}
var a: {
[x: number]: string;
[x: number]: string;
}
var b: {
[x: number]: string;
[x: number]: string
} = { 1: '', "2": ... | {
"end_byte": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexingResults.ts_0_427 | class C {
[x: string]: string;
y = '';
}
var c: C;
var r1 = c['y'];
var r2 = c['a'];
var r3 = c[1];
interface I {
[x: string]: string;
y: string;
}
var i: I
var r4 = i['y'];
var r5 = i['a'];
var r6 = i[1];
var a: {
[x: string]: string;
y: string;
}
var r7 = a['y'];
var r8 = a['a'];
var r... | {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexingResults.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts_0_574 | // String indexer providing a constraint of a user defined type
class A {
foo(): string { return ''; }
}
class B extends A {
bar(): string { return ''; }
}
class Foo {
[x: string]: A;
a: A; // ok
b: B; // ok
c: number; // error
d: string; // error
}
interface Foo2 {
[x: string]: A;
... | {
"end_byte": 574,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleStringIndexers.ts_0_454 | // Multiple indexers of the same type are an error
class C {
[x: string]: string;
[x: string]: string;
}
interface I {
[x: string]: string;
[x: string]: string;
}
var a: {
[x: string]: string;
[x: string]: string;
}
var b: {
[x: string]: string;
[x: string]: string;
} = { y: '' }
cl... | {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleStringIndexers.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexingResults.ts_0_848 | class C {
[x: number]: string;
1 = '';
"2" = ''
}
var c: C;
var r1 = c['1'];
var r2 = c['2'];
var r3 = c['3'];
var r4 = c[1];
var r5 = c[2];
var r6 = c[3];
interface I {
[x: number]: string;
1: string;
"2": string;
}
var i: I
var r1 = i['1'];
var r2 = i['2'];
var r3 = i['3'];
var r4 = i[1];
v... | {
"end_byte": 848,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexingResults.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts_0_726 | // String indexer providing a constraint of a user defined type
class A {
foo(): string { return ''; }
}
class B extends A {
bar(): string { return ''; }
}
class Foo {
[x: number]: A;
1.0: A; // ok
2.0: B; // ok
"2.5": B // ok
3.0: number; // error
"4.0": string; // error
}
interface... | {
"end_byte": 726,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts_0_245 | class C {
"a b": number;
"a b": number;
static "c d": number;
static "c d": number;
}
interface I {
"a b": number;
"a b": number;
}
var a: {
"a b": number;
"a b": number;
}
var b = {
"a b": 1
"a b": 1
} | {
"end_byte": 245,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts_0_414 | // Each of these types has an error in it.
// String named and numeric named properties conflict if they would be equivalent after ToNumber on the property name.
class C {
"1": number;
"1.0": number; // not a duplicate
1.0: number;
}
interface I {
"1": number;
"1.": number; // not a duplicate
... | {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyAccess.ts_0_265 | class C {
"a b": number;
static "c d": number;
}
var c: C;
var r1 = c["a b"];
var r1b = C['c d'];
interface I {
"a b": number;
}
var i: I;
var r2 = i["a b"];
var a: {
"a b": number;
}
var r3 = a["a b"];
var b = {
"a b": 1
}
var r4 = b["a b"]; | {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts_0_208 | class C {
1: number;
1.0: number;
static 2: number;
static 2: number;
}
interface I {
2: number;
2.: number;
}
var a: {
1: number;
1: number;
}
var b = {
2: 1
2: 1
} | {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/propertyNamesOfReservedWords.ts_0_3119 | class C {
abstract;
as;
boolean;
break;
byte;
case;
catch;
char;
class;
continue;
const;
debugger;
default;
delete;
do;
double;
else;
enum;
export;
extends;
false;
final;
finally;
float;
for;
function;
goto;
... | {
"end_byte": 3119,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/propertyNamesOfReservedWords.ts"
} |
TypeScript/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/propertyNameWithoutTypeAnnotation.ts_0_212 | class C {
foo;
}
interface I {
foo;
}
var a: {
foo;
}
var b = {
foo: null
}
// These should all be of type 'any'
var r1 = (new C()).foo;
var r2 = (<I>null).foo;
var r3 = a.foo;
var r4 = b.foo; | {
"end_byte": 212,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/objectTypeLiteral/propertySignatures/propertyNameWithoutTypeAnnotation.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypesInvalidExtendsDeclaration.ts_0_85 | // @declaration: true
type Test<T> = T extends infer A extends B ? number : string;
| {
"end_byte": 85,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypesInvalidExtendsDeclaration.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypes1.ts_0_5783 | // @strict: true
// @declaration: true
type Unpacked<T> =
T extends (infer U)[] ? U :
T extends (...args: any[]) => infer U ? U :
T extends Promise<infer U> ? U :
T;
type T00 = Unpacked<string>; // string
type T01 = Unpacked<string[]>; // string
type T02 = Unpacked<() => string>; // string
type T03... | {
"end_byte": 5783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypes1.ts_5785_6433 | type T80 = MatchingKeys<test, void>;
type T81 = VoidKeys<test>;
// Repro from #22221
type MustBeString<T extends string> = T;
type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
type Test1 = EnsureIsString<"hello">; // "hello"
type Test2 = EnsureIsString<42>; // never
// Repros from #26856
func... | {
"end_byte": 6433,
"start_byte": 5785,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts_0_308 | type Something<T> = { test: string } & (T extends object ? {
arg: T
} : {
arg?: undefined
});
function testFunc2<A extends object>(a: A, sa: Something<A>) {
sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
sa = { test: 'bye', arg: a, arr: a } // excess
}
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/conditionalTypes2.ts_0_6129 | // @strict: true
// @declaration: true
interface Covariant<T> {
foo: T extends string ? T : number;
}
interface Contravariant<T> {
foo: T extends string ? keyof T : number;
}
interface Invariant<T> {
foo: T extends string ? keyof T : T;
}
function f1<A, B extends A>(a: Covariant<A>, b: Covariant<B>) {
... | {
"end_byte": 6129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/conditionalTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypesWithExtends1.ts_0_5304 | // @strict: true
// @declaration: true
// infer to tuple element
type X1<T extends any[]> =
T extends [infer U extends string] ? ["string", U] :
T extends [infer U extends number] ? ["number", U] :
never;
type X1_T1 = X1<["a"]>; // ["string", "a"]
type X1_T2 = X1<[1]>; // ["number", 1]
type X1_T3 = X1<[ob... | {
"end_byte": 5304,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypesWithExtends1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypesWithExtends1.ts_5305_5758 | type X21_T4 = X21<1 | 2, 2 | 3>; // [2, 2]
type X21_T5 = X21<1 | 2, 3>; // never
// from mongoose
type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
declare const x1: <T>() => (T extends infer U extends number ? 1 : 0);
function f1() {
return x1;
}
type Expec... | {
"end_byte": 5758,
"start_byte": 5305,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypesWithExtends1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/variance.ts_0_503 | // @strict: true
// Test cases for parameter variances affected by conditional types.
// Repro from #30047
interface Foo<T> {
prop: T extends unknown ? true : false;
}
const foo = { prop: true } as const;
const x: Foo<1> = foo;
const y: Foo<number> = foo;
const z: Foo<number> = x;
// Repro from #30118
class Ba... | {
"end_byte": 503,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/variance.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypesWithExtends2.ts_0_345 | // @strict: true
// infer twice with different constraints (same behavior as class/interface)
type X1<T> =
T extends { a: infer U extends string, b: infer U extends number } ? U :
never;
// infer cannot reference type params in same 'extends' clause
type X2<T> =
T extends { a: infer U, b: infer V extends ... | {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypesWithExtends2.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/conditionalTypes1.ts_0_5869 | // @strict: true
// @declaration: true
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
type T02 = Exclude<string | number | (() => void), Function>; // string | number
type T03 = Extract<string | number | (() => void)... | {
"end_byte": 5869,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/conditionalTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/conditionalTypes1.ts_5870_11327 | type Q3 = IsString<any>; // boolean
type Q4 = IsString<never>; // never
type N1 = Not<false>; // true
type N2 = Not<true>; // false
type N3 = Not<boolean>; // boolean
type A1 = And<false, false>; // false
type A2 = And<false, true>; // false
type A3 = And<true, false>; // false
type A4 = And<true, true>; // ... | {
"end_byte": 11327,
"start_byte": 5870,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/conditionalTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypes2.ts_0_613 | // @strict: true
// @declaration: true
// Repros from #22755
export declare function foo<T>(obj: T): T extends () => infer P ? P : never;
export function bar<T>(obj: T) {
return foo(obj);
}
export type BadNested<T> = { x: T extends number ? T : string };
export declare function foo2<T>(obj: T): T extends { [K i... | {
"end_byte": 613,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts_0_262 | // @strict: true
// @noEmit: true
// repro from https://github.com/microsoft/TypeScript/issues/54197
type Bar<K, T extends readonly unknown[]> = T extends readonly [any, ...infer X extends readonly K[]] ? X : never;
type Res1 = Bar<"a" | "b", ["a", "b", "b"]>
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/indexerWithTuple.ts_3_1616 | r strNumTuple: [string, number] = ["foo", 10];
var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]];
var unionTuple1: [number, string| number] = [10, "foo"];
var unionTuple2: [boolean, string| number] = [true, "foo"];
// no error
var idx0 = 0;
var idx1 = 1;
var ele10 = strNumTuple[0]; // string
var ele11 ... | {
"end_byte": 1616,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/indexerWithTuple.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples3.ts_0_68 | //@noImplicitAny: true
var a: [any];
var b = a = [undefined, null]; | {
"end_byte": 68,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples3.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/tupleElementTypes3.ts_0_28 | var [a, b] = [0, undefined]; | {
"end_byte": 28,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/tupleElementTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts_0_958 | // @strict: true
// @declaration: true
type T10 = string[];
type T11 = Array<string>;
type T12 = readonly string[];
type T13 = ReadonlyArray<string>;
type T20 = [number, number];
type T21 = readonly [number, number];
type T30 = readonly string; // Error
type T31<T> = readonly T; // Error
type T32 = readonly readon... | {
"end_byte": 958,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts_0_2022 | // @strict: true
type T1 = [string, number];
type T2 = [boolean] | [string, number];
type T3 = [string, ...number[]];
type T4 = [boolean] | [string, ...number[]];
type T10 = T1[0]; // string
type T11 = T1[1]; // number
type T12 = T1[2]; // undefined
type T1N = T1[number]; // string | number
type T20 = T2[0]; //... | {
"end_byte": 2022,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples7.ts_0_123 | //@noImplicitAny: true
var foo = function bar() {
let intermediate: [string];
return intermediate = [undefined];
}; | {
"end_byte": 123,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples7.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/typeInferenceWithTupleType.ts_0_925 | function combine<T, U>(x: T, y: U): [T, U] {
return [x, y];
}
var combineResult = combine("string", 10);
var combineEle1 = combineResult[0]; // string
var combineEle2 = combineResult[1]; // number
function zip<T, U>(array1: T[], array2: U[]): [[T, U]] {
if (array1.length != array2.length) {
return [[u... | {
"end_byte": 925,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/typeInferenceWithTupleType.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/tupleLengthCheck.ts_0_217 | declare const a: [number, string]
declare const rest: [number, string, ...boolean[]]
const a1 = a[1]
const a2 = a[2]
const a3 = a[1000]
const a4 = rest[1]
const a5 = rest[2]
const a6 = rest[3]
const a7 = rest[1000]
| {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/tupleLengthCheck.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/tupleElementTypes2.ts_0_37 | function f([a, b]: [number, any]) { } | {
"end_byte": 37,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/tupleElementTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples6.ts_0_47 | var [a, b] = [undefined, null];
a = "";
b = ""; | {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples6.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts_3_1119 | no error
var numStrTuple: [number, string] = [5, "hello"];
var numStrTuple2: [number, string] = [5, "foo", true];
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
... | {
"end_byte": 1119,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples2.ts_0_144 | //@noImplicitAny: true
var foo: () => [any] = function bar() {
let intermediate = bar();
intermediate = [""];
return [undefined];
}; | {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples2.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/variadicTuples1.ts_0_5723 | // @strict: true
// @declaration: true
// Variadics in tuple types
type TV0<T extends unknown[]> = [string, ...T];
type TV1<T extends unknown[]> = [string, ...T, number];
type TV2<T extends unknown[]> = [string, ...T, number, ...T];
type TV3<T extends unknown[]> = [string, ...T, ...number[], ...T];
// Normalization
... | {
"end_byte": 5723,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/variadicTuples1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/variadicTuples1.ts_5725_11821 | function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
t0 = t1;
t0 = t2;
t1 = t0; // Error
t1 = t2;
t2 = t0; // Error
t2 = t1; // Error
}
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
... | {
"end_byte": 11821,
"start_byte": 5725,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/variadicTuples1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/variadicTuples1.ts_11823_13636 | // No inference to ending optional elements (except with identical structure)
declare function f20<T extends unknown[] = []>(args: [...T, number?]): T;
function f21<U extends string[]>(args: [...U, number?]) {
let v1 = f20(args); // U
let v2 = f20(["foo", "bar"]); // [string]
let v3 = f20(["foo", 42]); ... | {
"end_byte": 13636,
"start_byte": 11823,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/variadicTuples1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/strictTupleLength.ts_0_384 | var t0: [];
var t1: [number];
var t2: [number, number];
var arr: number[];
var len0: 0 = t0.length;
var len1: 1 = t1.length;
var len2: 2 = t2.length;
var lena: number = arr.length;
var t1 = t2; // error
var t2 = t1; // error
type A<T extends any[]> = T['length'];
var b: A<[boolean]>;
var c: 1 = b;
t1 = arr; // erro... | {
"end_byte": 384,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/strictTupleLength.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/optionalTupleElements1.ts_0_846 | // @strict: true
// @declaration: true
type T1 = [number, string, boolean];
type T2 = [number, string, boolean?];
type T3 = [number, string?, boolean?];
type T4 = [number?, string?, boolean?];
type L1 = T1["length"];
type L2 = T2["length"];
type L3 = T3["length"];
type L4 = T4["length"];
type T5 = [number, string?, ... | {
"end_byte": 846,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/optionalTupleElements1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts_0_789 | interface StrNum extends Array<string|number> {
0: string;
1: number;
length: 2;
}
var x: [string, number];
var y: StrNum
var z: {
0: string;
1: number;
length: 2;
}
var [a, b, c] = x;
var [d, e, f] = y;
var [g, h, i] = z;
var j1: [number, number, number] = x;
var j2: [number, number, number] ... | {
"end_byte": 789,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/restTupleElements1.ts_0_2177 | // @strict: true
// @declaration: true
type T00 = [string?];
type T01 = [string, string?];
type T02 = [string?, string]; // Error
type T03 = [...string[]];
type T04 = [...[...string[]]];
type T05 = [...[...[...string[]]]];
type T06 = [string, ...string[]];
type T07 = [...string[], string]; // Error
type T08 = [...st... | {
"end_byte": 2177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/restTupleElements1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/variadicTuples3.ts_0_441 | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/58697
function test1<T extends any[], P extends any[]>(): [...T, ...P] {
let x: any[] = [];
return x;
}
function test2<T extends any[], P extends any[]>(): [...T, ...P] {
let x: [any, any] = [null, null];
return x;
}
functio... | {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/variadicTuples3.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/contextualTypeTupleEnd.ts_0_1262 | // @strict: true
// @noEmit: true
type Funcs = [...((arg: number) => void)[], (arg: string) => void];
declare function num(x: number): void;
declare function str(x: string): void;
declare function f1(...args: Funcs): void;
f1(); // Error
f1(x => str(x));
f1(x => num(x), x => str(x));
f1(x => num(x), x => num(x), x... | {
"end_byte": 1262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/contextualTypeTupleEnd.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/variadicTuples2.ts_0_4821 | // @strict: true
// @declaration: true
// Declarations
type V00 = [number, ...string[]];
type V01 = [...string[], number];
type V03 = [number, ...string[], number];
type V10 = [number, ...string[], ...boolean[]]; // Error
type V11 = [number, ...string[], boolean?]; // Error
type V12 = [number, string?, boolean]; ... | {
"end_byte": 4821,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/variadicTuples2.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/readonlyArraysAndTuples2.ts_0_562 | // @strict: true
// @declaration: true
// @emitDecoratorMetadata: true
// @experimentalDecorators: true
type T10 = string[];
type T11 = Array<string>;
type T12 = readonly string[];
type T13 = ReadonlyArray<string>;
type T20 = [number, number];
type T21 = readonly [number, number];
declare function f1(ma: string[], r... | {
"end_byte": 562,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/readonlyArraysAndTuples2.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/tupleElementTypes1.ts_0_51 | var [a, b]: [number, any] = [undefined, undefined]; | {
"end_byte": 51,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/tupleElementTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples5.ts_0_54 | //@noImplicitAny: true
var [a, b] = [undefined, null]; | {
"end_byte": 54,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples5.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/castingTuple.ts_3_1143 | terface I { }
class A { a = 10; }
class C implements I { c };
class D implements I { d };
class E extends A { e };
class F extends A { f };
enum E1 { one }
enum E2 { one }
// no error
var numStrTuple: [number, string] = [5, "foo"];
var emptyObjTuple = <[{}, {}]>numStrTuple;
var numStrBoolTuple = <[number, string, bool... | {
"end_byte": 1143,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/castingTuple.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples1.ts_0_107 | //@noImplicitAny: true
declare function foo<T extends [any]>(x: T): T;
var y = foo([undefined]);
y = [""]; | {
"end_byte": 107,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples1.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/tupleElementTypes4.ts_0_39 | function f([a, b] = [0, undefined]) { } | {
"end_byte": 39,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/tupleElementTypes4.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/wideningTuples4.ts_0_59 | var a: [any];
var b = a = [undefined, null];
b = ["", ""]; | {
"end_byte": 59,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/wideningTuples4.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts_0_52 | // @declaration: true
let x = <[]>[];
let y = x[0]; | {
"end_byte": 52,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts_0_54 | // @declaration: true
let x = [] as [];
let y = x[0]; | {
"end_byte": 54,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts_0_921 | // @declaration: true
export type Segment1 = [length: number, number];
export type Segment2 = [number, size: number];
export type List = [item: any, ...any];
export type List2 = [any, ...remainder: any];
export type Pair = [item: any, any?];
export type Pair2 = [any, last?: any];
export type Opt = [element: str... | {
"end_byte": 921,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/named/namedTupleMembers.ts_0_1923 | // @declaration: true
export type Segment = [length: number, count: number];
export type SegmentAnnotated = [
/**
* Size of message buffer segment handles
*/
length: number,
/**
* Number of segments handled at once
*/
count: number
];
declare var a: Segment;
declare var b: Segmen... | {
"end_byte": 1923,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/named/namedTupleMembers.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/named/partiallyNamedTuples2.ts_0_697 | // @strict: true
// @lib: esnext
// https://github.com/microsoft/TypeScript/issues/55693
interface MultiKeyMap<Keys extends readonly unknown[], Value> {
get<Key extends GetKeys<Keys>>(...key: Key): GetResult<Keys, Key, Value>;
}
type GetKeys<Keys extends readonly unknown[]> = Keys extends [
...infer Remain,
infe... | {
"end_byte": 697,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/named/partiallyNamedTuples2.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/named/partiallyNamedTuples.ts_0_1742 | type NamedAndAnonymous = [a: string, number];
function fa1(...args: NamedAndAnonymous) {}
function fa2(a: NamedAndAnonymous, ...args: NamedAndAnonymous) {}
type NamedAnonymousMixed = [a: string, number, c: number, NamedAndAnonymous];
function fb1(...args: NamedAnonymousMixed) {}
function fb2(a: NamedAnonymousMixed, ... | {
"end_byte": 1742,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/named/partiallyNamedTuples.ts"
} |
TypeScript/tests/cases/conformance/types/tuple/named/partiallyNamedTuples3.ts_0_158 | // @strict: true
// @lib: esnext
declare const tuple: [number, name: string, boolean, value: number, string];
const output = ((...args) => args)(...tuple);
| {
"end_byte": 158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/tuple/named/partiallyNamedTuples3.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverTypeErrors2.ts_0_550 | // @strictNullChecks: true
function f1() {
let x: never;
x = 1;
x = "abc";
x = false;
x = undefined;
x = null;
x = {};
x();
}
function f2(): never {
return;
}
function f3(): never {
return 1;
}
function f4(): never {
}
for (const n of f4()) {}
for (const n in f4()) {}
funct... | {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverTypeErrors2.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverInference.ts_0_784 | // @lib: es2015
// @strict: true
// @target: es2015
declare function f1<T>(x: T[]): T;
let neverArray: never[] = [];
let a1 = f1([]); // never
let a2 = f1(neverArray); // never
// Repro from #19576
type Comparator<T> = (x: T, y: T) => number;
interface LinkedList<T> {
comparator: Comparator<T>,
nodes: N... | {
"end_byte": 784,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverInference.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverIntersectionNotCallable.ts_0_68 | declare const f: { (x: string): number, a: "" } & { a: number }
f()
| {
"end_byte": 68,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverIntersectionNotCallable.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverType.ts_0_1609 | // @strictNullChecks: true
// @declaration: true
function error(message: string): never {
throw new Error(message);
}
function errorVoid(message: string) {
throw new Error(message);
}
function fail() {
return error("Something failed");
}
function failOrThrow(shouldFail: boolean) {
if (shouldFail) {... | {
"end_byte": 1609,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverType.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverUnionIntersection.ts_0_370 | // @strict: true
type T01 = string | never;
type T02 = string & never;
type T03 = string | number | never;
type T04 = string & number & never;
type T05 = any | never;
type T06 = any & never;
type T07 = undefined | never;
type T08 = undefined & never;
type T09 = null | never;
type T10 = null & never;
type T11 = { a: st... | {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverUnionIntersection.ts"
} |
TypeScript/tests/cases/conformance/types/never/neverTypeErrors1.ts_0_522 | function f1() {
let x: never;
x = 1;
x = "abc";
x = false;
x = undefined;
x = null;
x = {};
x();
}
function f2(): never {
return;
}
function f3(): never {
return 1;
}
function f4(): never {
}
for (const n of f4()) {}
for (const n in f4()) {}
function f5() {
let x: never[... | {
"end_byte": 522,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/never/neverTypeErrors1.ts"
} |
TypeScript/tests/cases/conformance/types/forAwait/types.forAwait.es2018.1.ts_0_842 | // @target: es2018
// @lib: esnext
// @noEmit: true
declare const asyncIterable: AsyncIterable<number>;
declare const iterable: Iterable<number>;
declare const iterableOfPromise: Iterable<Promise<number>>;
async function f1() {
let y: number;
for await (const x of asyncIterable) {
}
for await (const x o... | {
"end_byte": 842,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/forAwait/types.forAwait.es2018.1.ts"
} |
TypeScript/tests/cases/conformance/types/forAwait/types.forAwait.es2018.2.ts_0_438 | // @target: es2018
// @lib: esnext
// @noEmit: true
declare const asyncIterable: AsyncIterable<number>;
declare const iterable: Iterable<number>;
async function f() {
let y: number;
let z: string;
for await (const x of {}) {
}
for await (y of {}) {
}
for await (z of asyncIterable) {
}
... | {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/forAwait/types.forAwait.es2018.2.ts"
} |
TypeScript/tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts_0_276 | // @target: es2018
// @lib: es5
// @noEmit: true
async function f1() {
let y: number;
for await (const x of {}) {
}
for await (y of {}) {
}
}
async function* f2() {
let y: number;
for await (const x of {}) {
}
for await (y of {}) {
}
}
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts_4_218 | pe S = "a" | "b";
type T = S[] | S;
function f(foo: T) {
if (foo === "a") {
return foo;
}
else if (foo === "b") {
return foo;
}
else {
return (foo as S[])[0];
}
} | {
"end_byte": 218,
"start_byte": 4,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability02.ts_3_218 | @declaration: true
function f(x: "foo"): number;
function f(x: "foo"): number {
return 0;
}
function g(x: "bar"): number;
function g(x: "bar"): number {
return 0;
}
let a = f;
let b = g;
a = b;
b = a; | {
"end_byte": 218,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint02.ts_3_174 | @declaration: true
function foo<T extends "foo">(f: (x: T) => T) {
return f;
}
let f = foo((y: "foo" | "bar") => y === "foo" ? y : "foo");
let fResult = f("foo"); | {
"end_byte": 174,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts_0_652 | // @declaration: true
type Kind = "A" | "B"
interface Entity {
kind: Kind;
}
interface A extends Entity {
kind: "A";
a: number;
}
interface B extends Entity {
kind: "B";
b: string;
}
function hasKind(entity: Entity, kind: "A"): entity is A;
function hasKind(entity: Entity, kind: "B"): entity is... | {
"end_byte": 652,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts_3_765 | @declaration: true
let abc: "ABC" = "ABC";
let xyz: "XYZ" = "XYZ";
let abcOrXyz: "ABC" | "XYZ" = abc || xyz;
let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100;
let a = "" + abc;
let b = abc + "";
let c = 10 + abc;
let d = abc + 10;
let e = xyz + abc;
let f = abc + xyz;
let g = true + abc;
let h = abc + ... | {
"end_byte": 765,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithTemplateStrings02.ts_3_96 | @declaration: true
let abc: "AB\r\nC" = `AB
C`;
let de_NEWLINE_f: "DE\nF" = `DE${"\n"}F`; | {
"end_byte": 96,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithTemplateStrings02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability03.ts_3_220 | @declaration: true
function f(x: "foo"): number;
function f(x: string): number {
return 0;
}
function g(x: "foo"): number;
function g(x: string): number {
return 0;
}
let a = f;
let b = g;
a = b;
b = a; | {
"end_byte": 220,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability03.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts_4_173 | pe S = "a" | "b";
type T = S[] | S;
var foo: T;
switch (foo) {
case "a":
case "b":
break;
default:
foo = (foo as S[])[0];
break;
} | {
"end_byte": 173,
"start_byte": 4,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts_0_377 | // @declaration: true
type Kind = "A" | "B"
function kindIs(kind: Kind, is: "A"): kind is "A";
function kindIs(kind: Kind, is: "B"): kind is "B";
function kindIs(kind: Kind, is: Kind): boolean {
return kind === is;
}
var x: Kind = undefined;
if (kindIs(x, "A")) {
let a = x;
}
else {
let b = x;
}
if (!k... | {
"end_byte": 377,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts_3_173 | @declaration: true
declare function myRandBool(): boolean;
let a: "foo" = "foo";
let b = a || "foo";
let c: "foo" = b;
let d = b || "bar";
let e: "foo" | "bar" = d;
| {
"end_byte": 173,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts_3_225 | @declaration: true
declare function myRandBool(): boolean;
let a: "foo" = ("foo");
let b: "foo" | "bar" = ("foo");
let c: "foo" = (myRandBool ? "foo" : ("foo"));
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
| {
"end_byte": 225,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts_3_129 | @declaration: true
declare function f(x: (p: "foo" | "bar") => "foo");
f(y => {
const z = y = "foo";
return z;
}) | {
"end_byte": 129,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts_4_308 | pe S = "a" | "b";
type T = S[] | S;
var s: S;
var t: T;
var str: string;
////////////////
s = <S>t;
s = t as S;
s = <S>str;
s = str as S;
////////////////
t = <T>s;
t = s as T;
t = <T>str;
t = str as T;
////////////////
str = <string>s;
str = s as string;
str = <string>t;
str = t as string;
| {
"end_byte": 308,
"start_byte": 4,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.