_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedProperty2.ts_0_223 | // Basic recursive type
class List<T> {
data: T;
next: List<List<T>>;
}
var list1 = new List<number>();
var list2 = new List<number>();
var list3 = new List<string>();
list1 = list2; // ok
list1 = list3; // error | {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedProperty2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts_0_1184 | // Types with infinitely expanding recursive types are type checked nominally
class List<T> {
data: T;
next: List<List<T>>;
}
class MyList<T> {
data: T;
next: MyList<MyList<T>>;
}
var list1 = new List<number>();
var list2 = new List<string>();
var myList1 = new MyList<number>();
var myList2 = new My... | {
"end_byte": 1184,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/arrayLiteralsWithRecursiveGenerics.ts_0_475 | class List<T> {
data: T;
next: List<List<T>>;
}
class DerivedList<U> extends List<U> {
foo: U;
// next: List<List<U>>
}
class MyList<T> {
data: T;
next: MyList<MyList<T>>;
}
var list: List<number>;
var list2: List<string>;
var myList: MyList<number>;
var xs = [list, myList]; // {}[]
var ys =... | {
"end_byte": 475,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/arrayLiteralsWithRecursiveGenerics.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation2.ts_0_315 | // instantiating a derived type can cause an infinitely expanding type reference to be generated
// which could be used in an assignment check for constraint satisfaction
interface AA<T extends AA<T>> // now an error due to referencing type parameter in constraint
{
x: T
}
interface BB extends AA<AA<BB>>
{
} | {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeInGenericConstraint.ts_0_278 | class G<T> {
x: G<G<T>>; // infinitely expanding type reference
}
class Foo<T extends G<T>> { // error, constraint referencing itself
bar: T;
}
class D<T> {
x: G<G<T>>;
}
var c1 = new Foo<D<string>>(); // ok, circularity in assignment compat check causes success | {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeInGenericConstraint.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedProperty.ts_0_223 | // Basic recursive type
class List<T> {
data: T;
next: List<List<T>>;
}
var list1 = new List<number>();
var list2 = new List<number>();
var list3 = new List<string>();
list1 = list2; // ok
list1 = list3; // error | {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedProperty.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/nominalSubtypeCheckOfTypeParameter2.ts_0_229 | interface B<T> {
bar: T;
}
// ok
interface A<T> extends B<T> {
foo: T;
}
// ok
interface A2<T> extends B<B<string>> {
baz: T;
}
interface C<T> {
bam: T;
}
// ok
interface A3<T> extends B<C<T>> {
bing: T;
} | {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/nominalSubtypeCheckOfTypeParameter2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts_0_3641 | // @strict: true
// @declaration: true
type ValueOrArray<T> = T | Array<ValueOrArray<T>>;
const a0: ValueOrArray<number> = 1;
const a1: ValueOrArray<number> = [1, [2, 3], [4, [5, [6, 7]]]];
type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]];
const hypertextNode: HypertextNode =
... | {
"end_byte": 3641,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences2.ts_0_700 | // @checkjs: true
// @outdir: out/
// @filename: bug39372.js
// @declaration: true
/** @typedef {ReadonlyArray<Json>} JsonArray */
/** @typedef {{ readonly [key: string]: Json }} JsonRecord */
/** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */
/**
* @template T
* @typedef ... | {
"end_byte": 700,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughTypeInference.ts_0_226 | interface G<T> {
x: G<G<T>> // infinitely expanding type reference
y: T
}
function ff<T>(g: G<T>): void {
ff(g) // when infering T here we need to make sure to not descend into the structure of G<T> infinitely
}
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughTypeInference.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypesUsedAsFunctionParameters.ts_0_930 | class List<T> {
data: T;
next: List<List<T>>;
}
class MyList<T> {
data: T;
next: MyList<MyList<T>>;
}
function foo<T>(x: List<T>);
function foo<U>(x: List<U>); // error, duplicate
function foo<T>(x: List<T>) {
}
function foo2<T>(x: List<T>);
function foo2<U>(x: MyList<U>); // ok, nominally compared w... | {
"end_byte": 930,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypesUsedAsFunctionParameters.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts_0_510 | // instantiating a derived type can cause an infinitely expanding type reference to be generated
interface List<T> {
data: T;
next: List<T>;
owner: OwnerList<T>;
}
// will have an owner property that is an infinitely expanding type reference
interface OwnerList<U> extends List<List<U>> {
name: string;... | {
"end_byte": 510,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/typeAliasesDoNotMerge.ts_0_31 | export type A = {}
type A = {}
| {
"end_byte": 31,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/typeAliasesDoNotMerge.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/intrinsicKeyword.ts_0_462 | // @strict: true
let e1: intrinsic;
let e2: { intrinsic: intrinsic };
type TE1 = (intrinsic);
type TE2<intrinsic> = intrinsic;
type TE3<T extends intrinsic> = T;
type TE4<intrinsic extends intrinsic> = intrinsic;
type TE5<intrinsic extends intrinsic> = (intrinsic);
function f1() {
let intrinsic: intrinsic.intrins... | {
"end_byte": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/intrinsicKeyword.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts_0_495 | type T1 = { x: string }
// An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot.
interface I1 extends T1 { y: string }
class C1 implements T1 {
x: string;
}
// An interface can have multiple merged declarations, but a type alias for an object type litera... | {
"end_byte": 495,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/typeAliases.ts_0_1422 | // Writing a reference to a type alias has exactly the same effect as writing the aliased type itself.
type T1 = number;
var x1: number;
var x1: T1;
type T2 = string;
var x2: string;
var x2: T2;
type T3 = boolean;
var x3: boolean;
var x3: T3;
type T4 = void;
var x4: void;
var x4: T4;
type T5 = any;
var x5: any;
va... | {
"end_byte": 1422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/typeAliases.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/genericTypeAliases.ts_0_1127 | type Tree<T> = T | { left: Tree<T>, right: Tree<T> };
var tree: Tree<number> = {
left: {
left: 0,
right: {
left: 1,
right: 2
},
},
right: 3
};
type Lazy<T> = T | (() => T);
var ls: Lazy<string>;
ls = "eager";
ls = () => "lazy";
type Foo<T> = T | { x: Foo<T... | {
"end_byte": 1127,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/genericTypeAliases.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias01.ts_1_51 | var type;
var string;
var Foo;
type
Foo = string; | {
"end_byte": 51,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias01.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithClass.ts_0_199 | var v0: T0;
type T0 = string | I0;
class I0 {
x: T0;
}
var v3: T3;
type T3 = string | I3;
class I3 {
[x: number]: T3;
}
var v4: T4;
type T4 = string | I4;
class I4 {
[x: string]: T4;
}
| {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithClass.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts_0_280 | type StringTree = string | StringTreeCollection;
class StringTreeCollectionBase {
[n: number]: StringTree;
}
class StringTreeCollection extends StringTreeCollectionBase { }
var x: StringTree;
if (typeof x !== "string") {
x[0] = "";
x[0] = new StringTreeCollection;
} | {
"end_byte": 280,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts_0_1005 | // It is an error for the type specified in a type alias to depend on that type alias
// A type alias directly depends on the type it aliases.
type T0 = T0
type T0_1 = T0_2
type T0_2 = T0_3
type T0_3 = T0_1
// A type reference directly depends on the referenced type and each of the type arguments, if any.
interface I... | {
"end_byte": 1005,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/builtinIteratorReturn.ts_0_880 | // @target: esnext
// @noEmit: true
// @strictBuiltinIteratorReturn: *
declare const array: number[];
declare const map: Map<string, number>;
declare const set: Set<number>;
const i0 = array[Symbol.iterator]();
const i1 = array.values();
const i2 = array.keys();
const i3 = array.entries();
for (const x of array);
co... | {
"end_byte": 880,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/builtinIteratorReturn.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithInterface.ts_0_345 | var v0: T0;
type T0 = string | I0;
interface I0 {
x: T0;
}
var v1: T1;
type T1 = string | I1;
interface I1 {
(): T1;
}
var v2: T2;
type T2 = string | I2;
interface I2 {
new (): T2;
}
var v3: T3;
type T3 = string | I3;
interface I3 {
[x: number]: T3;
}
var v4: T4;
type T4 = string | I4;
interface I4 ... | {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithInterface.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/interfaceDoesNotDependOnBaseTypes.ts_0_184 | var x: StringTree;
if (typeof x !== "string") {
x.push("");
x.push([""]);
}
type StringTree = string | StringTreeArray;
interface StringTreeArray extends Array<StringTree> { } | {
"end_byte": 184,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/interfaceDoesNotDependOnBaseTypes.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias02.ts_1_83 | var type;
var string;
var Foo;
namespace container {
type
Foo = string;
} | {
"end_byte": 83,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias02.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts_0_113 | interface I {}
type any = I;
type number = I;
type boolean = I;
type string = I;
type void = I;
type object = I;
| {
"end_byte": 113,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts"
} |
TypeScript/tests/cases/conformance/types/typeAliases/intrinsicTypes.ts_0_1893 | // @strict: true
// @declaration: true
type TU1 = Uppercase<'hello'>; // "HELLO"
type TU2 = Uppercase<'foo' | 'bar'>; // "FOO" | "BAR"
type TU3 = Uppercase<string>; // Uppercase<string>
type TU4 = Uppercase<any>; // Uppercase<`${any}`>
type TU5 = Uppercase<never>; // never
type TU6 = Uppercase<42>; // Error
typ... | {
"end_byte": 1893,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeAliases/intrinsicTypes.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJs.ts_0_714 | // @target: esnext
// @lib: esnext
// @declaration: true
// @allowJs: true
// @checkJs: true
// @filename: uniqueSymbolsDeclarationsInJs.js
// @outFile: uniqueSymbolsDeclarationsInJs-out.js
// @useDefineForClassFields: false
// classes
class C {
/**
* @readonly
*/
static readonlyStaticCall = Symbol()... | {
"end_byte": 714,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJs.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts_0_7714 | // @target: esnext
// @lib: esnext
// @declaration: false
// @useDefineForClassFields: false
// declarations with call initializer
const constCall = Symbol();
let letCall = Symbol();
var varCall = Symbol();
// ambient declaration with type
declare const constType: unique symbol;
// declaration with type and call ini... | {
"end_byte": 7714,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJsErrors.ts_0_485 | // @target: esnext
// @lib: esnext
// @declaration: true
// @allowJs: true
// @checkJs: true
// @filename: uniqueSymbolsDeclarationsInJsErrors.js
// @outFile: uniqueSymbolsDeclarationsInJsErrors-out.js
// @useDefineForClassFields: false
class C {
/**
* @type {unique symbol}
*/
static readwriteStaticT... | {
"end_byte": 485,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJsErrors.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts_0_3875 | // @target: esnext
// @useDefineForClassFields: false
// declarations
declare const invalidUniqueType: unique number;
declare const {}: unique symbol;
declare let invalidLetType: unique symbol;
declare var invalidVarType: unique symbol;
// function arguments and return types
declare function invalidArgType(arg: uniqu... | {
"end_byte": 3875,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts_0_7134 | // @target: esnext
// @lib: esnext
// @declaration: true
// @useDefineForClassFields: false
// declarations with call initializer
const constCall = Symbol();
let letCall = Symbol();
var varCall = Symbol();
// ambient declaration with type
declare const constType: unique symbol;
// declaration with type and call init... | {
"end_byte": 7134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsPropertyNames.ts_0_1193 | // @target: esnext
// @lib: esnext
interface OpTypes {
readonly equal: unique symbol;
}
namespace OpNamespace {
export declare const equal: unique symbol;
}
const uniqueSymbol0 = Symbol.for("");
const uniqueSymbol1 = Symbol.for("");
function getUniqueSymbol0(): typeof uniqueSymbol0 {
return uniqueSymbol0;
}
... | {
"end_byte": 1193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsPropertyNames.ts"
} |
TypeScript/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts_0_1329 | // @target: esnext
// @lib: esnext
// @module: commonjs
// @declaration: true
// @useDefineForClassFields: false
declare const s: unique symbol;
interface I { readonly readonlyType: unique symbol; }
// not allowed when emitting declarations
export const obj = {
method1(p: typeof s): typeof s {
return p;
... | {
"end_byte": 1329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionWithIndexSignatures.ts_0_835 | // @strict: true
type A = { a: string };
type B = { b: string };
declare let sa1: { x: A & B };
declare let sa2: { x: A } & { x: B };
declare let ta1: { [key: string]: A & B };
declare let ta2: { [key: string]: A } & { [key: string]: B };
ta1 = sa1;
ta1 = sa2;
ta2 = sa1;
ta2 = sa2;
declare let sb1: { x: A } & { y: ... | {
"end_byte": 835,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionWithIndexSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts_3_354 | terface A { a: string }
interface B { b: string }
interface C { c: string }
// A & B is equivalent to B & A.
var y: A & B;
var y : B & A;
// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C.
var z : A & B & C;
var z : (A & B) & C;
var z : A & (B & C);
var ab : A & B;
var bc : B & C;
var z1: typeof ab... | {
"end_byte": 354,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionAsWeakTypeSource.ts_0_541 | interface X { x: string }
interface Y { y: number }
interface Z { z?: boolean }
type XY = X & Y;
const xy: XY = {x: 'x', y: 10};
const z1: Z = xy; // error, {xy} doesn't overlap with {z}
interface ViewStyle {
view: number
styleMedia: string
}
type Brand<T> = number & { __brand: T }
declare function create<T... | {
"end_byte": 541,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionAsWeakTypeSource.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeInference.ts_0_451 | function extend<T, U>(obj1: T, obj2: U): T & U {
var result: T & U;
obj1 = result;
obj2 = result;
result = obj1; // Error
result = obj2; // Error
return result;
}
var x = extend({ a: "hello" }, { b: 42 });
var s = x.a;
var n = x.b;
interface A<T> {
a: T;
}
interface B<U> {
b: U;
}
... | {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeInference.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts_0_251 | // Check that order is preserved in intersection types for purposes of
// overload resolution
type F = (s: string) => string;
type G = (x: any) => any;
var fg: F & G;
var gf: G & F;
var x = fg("abc");
var x: string;
var y = gf("abc");
var y: any;
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts_0_228 | var a: { a: string };
var b: { b: string };
var x: { a: string, b: string };
var y: { a: string } & { b: string };
a = x;
a = y;
x = a; // Error
y = a; // Error
b = x;
b = y;
x = b; // Error
y = b; // Error
x = y;
y = x;
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionReductionStrict.ts_0_2686 | // @strict: true
declare const sym1: unique symbol;
declare const sym2: unique symbol;
type T1 = string & 'a'; // 'a'
type T2 = 'a' & string & 'b'; // never
type T3 = number & 10; // 10
type T4 = 10 & number & 20; // never
type T5 = symbol & typeof sym1; // typeof sym1
type T6 = typeof sym1 & symbol & typeof sym... | {
"end_byte": 2686,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionReductionStrict.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionOfUnionNarrowing.ts_0_315 | // @strict: true
interface X {
a?: { aProp: string };
b?: { bProp: string };
}
type AorB = { a: object; b: undefined } | { a: undefined; b: object };
declare const q: X & AorB;
if (q.a !== undefined) {
q.a.aProp;
} else {
// q.b is previously incorrectly inferred as potentially undefined
q.b.bProp;
}
| {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionOfUnionNarrowing.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts_0_1181 | // @strict
const enum E { A, B, C, D, E, F }
let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c'
let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c'
let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c'
let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never
let x4: ('a' | 'b' | 'c') & ('b' ... | {
"end_byte": 1181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionNarrowing.ts_0_825 | // @strict: true
// Repros from #43130
function f1<T>(x: T & string | T & undefined) {
if (x) {
x; // Should narrow to T & string
}
}
function f2<T>(x: T & string | T & undefined) {
if (x !== undefined) {
x; // Should narrow to T & string
}
else {
x; // Should narrow to... | {
"end_byte": 825,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionNarrowing.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionReduction.ts_0_3452 | // @strict: false
declare const sym1: unique symbol;
declare const sym2: unique symbol;
type T1 = string & 'a'; // 'a'
type T2 = 'a' & string & 'b'; // never
type T3 = number & 10; // 10
type T4 = 10 & number & 20; // never
type T5 = symbol & typeof sym1; // typeof sym1
type T6 = typeof sym1 & symbol & typeof sy... | {
"end_byte": 3452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionReduction.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts_0_158 | export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string };
type Ex<T, U> = T extends U ? T : never;
declare let x: Ex<U, { kind?: 'A' }>
x.a
| {
"end_byte": 158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts_3_418 | pe LinkedList<T> = T & { next: LinkedList<T> };
interface Entity {
name: string;
}
interface Product extends Entity {
price: number;
}
var entityList: LinkedList<Entity>;
var s = entityList.name;
var s = entityList.next.name;
var s = entityList.next.next.name;
var s = entityList.next.next.next.name;
var pro... | {
"end_byte": 418,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionThisTypes.ts_0_644 | interface Thing1 {
a: number;
self(): this;
}
interface Thing2 {
b: number;
me(): this;
}
type Thing3 = Thing1 & Thing2;
type Thing4 = Thing3 & string[];
function f1(t: Thing3) {
t = t.self();
t = t.me().self().me();
}
interface Thing5 extends Thing4 {
c: string;
}
function f2(t: Thing5... | {
"end_byte": 644,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionThisTypes.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/commonTypeIntersection.ts_0_265 | declare let x1: { __typename?: 'TypeTwo' } & { a: boolean };
let y1: { __typename?: 'TypeOne' } & { a: boolean} = x1; // should error here
declare let x2: { __typename?: 'TypeTwo' } & string;
let y2: { __typename?: 'TypeOne' } & string = x2; // should error here
| {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/commonTypeIntersection.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts_3_1401 | An intersection type has those members that are present in any of its constituent types,
// with types that are intersections of the respective members in the constituent types
interface A { a: string }
interface B { b: string }
interface C { c: string }
var abc: A & B & C;
abc.a = "hello";
abc.b = "hello";
abc.c = ... | {
"end_byte": 1401,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts_0_1950 | // @target: es2015
// @module: commonjs
// @esModuleInterop: true
// @filename: intersectionsAndEmptyObjects.ts
// Empty object type literals are removed from intersections types
// that contain other object types
type A = { a: number };
type B = { b: string };
type C = {};
let x01: A & B;
let x02: A & C;
let x03: B... | {
"end_byte": 1950,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/contextualIntersectionType.ts_0_106 | var x: { a: (s: string) => string } & { b: (n: number) => number };
x = {
a: s => s,
b: n => n
};
| {
"end_byte": 106,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/contextualIntersectionType.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts_3_485 | terface A { a: string }
interface B { b: string }
interface C { c: string }
interface D { d: string }
var a: A;
var b: B;
var c: C;
var d: D;
var anb: A & B;
var aob: A | B;
var cnd: C & D;
var cod: C | D;
var x: A & B | C & D;
var y: (A | B) & (C | D);
a = anb; // Ok
b = anb; // Ok
anb = a;
anb = b;
x = anb; // ... | {
"end_byte": 485,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts_0_834 | type Guid = string & { $Guid }; // Tagged string type
type SerialNo = number & { $SerialNo }; // Tagged number type
function createGuid() {
return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid;
}
function createSerialNo() {
return 12345 as SerialNo;
}
let map1: { [x: string]: number } = {};
let gu... | {
"end_byte": 834,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts_0_692 | interface Base {
readonly value: number;
}
interface Identical {
readonly value: number;
}
interface Mutable {
value: number;
}
interface DifferentType {
readonly value: string;
}
interface DifferentName {
readonly other: number;
}
let base: Base;
base.value = 12 // error, lhs can't be a readonly pr... | {
"end_byte": 692,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts_0_1290 | // @strict: true
function f1<T extends string | number, U extends string | number>(x: T & U) {
// Combined constraint of 'T & U' is 'string | number'
let y: string | number = x;
}
function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) {
let y1: string | number = ... | {
"end_byte": 1290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts_0_368 | declare function f<T>(x: { prop: T }): T;
declare const a: { prop: string } & { prop: number };
declare const b: { prop: string & number };
f(a); // never
f(b); // never
// Repro from #18354
declare function f2<T, Key extends keyof T>(obj: {[K in keyof T]: T[K]}, key: Key): T[Key];
declare const obj: { a: string... | {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts"
} |
TypeScript/tests/cases/conformance/types/intersection/intersectionTypeInference3.ts_0_362 | // @strict: true
// @target: es2015
// Repro from #19682
type Nominal<Kind extends string, Type> = Type & {
[Symbol.species]: Kind;
};
type A = Nominal<'A', string>;
declare const a: Set<A>;
declare const b: Set<A>;
const c1 = Array.from(a).concat(Array.from(b));
// Simpler repro
declare function from<T>(): ... | {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/intersection/intersectionTypeInference3.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/enum/validEnumAssignments.ts_0_192 | enum E {
A,
B
}
var n: number;
var a: any;
var e: E;
n = e;
n = E.A;
a = n;
a = e;
a = E.A;
e = e;
e = E.A;
e = E.B;
e = n;
e = null;
e = undefined;
e = 1;
e = 1.;
e = 1.0;
e = -1; | {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/enum/validEnumAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts_0_161 | enum E {
A,
B
}
enum E2 {
A,
B
}
var e: E;
var e2: E2;
e = E2.A;
e2 = E.A;
e = <void>null;
e = {};
e = '';
function f<T>(a: T) {
e = a;
} | {
"end_byte": 161,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts_0_80 | var x: 'hi';
function f(x: 'hi');
function f(x: string);
function f(x: any) {
} | {
"end_byte": 80,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/numberPropertyAccess.ts_0_145 | var x = 1;
var a = x.toExponential();
var b = x.hasOwnProperty('toFixed');
var c = x['toExponential']();
var d = x['hasOwnProperty']('toFixed'); | {
"end_byte": 145,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/numberPropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts_0_427 | interface Number {
doStuff(): string;
}
interface NotNumber {
toString(radix?: number): string;
toFixed(fractionDigits?: number): string;
toExponential(fractionDigits?: number): string;
toPrecision(precision?: number): string;
valueOf(): number;
doStuff(): string;
}
var x = 1;
var a: Numbe... | {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/extendNumberInterface.ts_0_224 | interface Number {
doStuff(): string;
doOtherStuff<T>(x:T): T;
}
var x = 1;
var a: string = x.doStuff();
var b: string = x.doOtherStuff('hm');
var c: string = x['doStuff']();
var d: string = x['doOtherStuff']('hm'); | {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/extendNumberInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts_0_318 | var x = 1;
var a: boolean = x;
var b: string = x;
var c: void = x;
var d: typeof undefined = x;
class C { foo: string; }
var e: C = x;
interface I { bar: string; }
var f: I = x;
var g: { baz: string } = 1;
var g2: { 0: number } = 1;
module M { export var x = 1; }
M = x;
function i<T>(a: T) {
a = x;
}
i = x; | {
"end_byte": 318,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/validNumberAssignments.ts_0_113 | var x = 1;
var a: any = x;
var b: Object = x;
var c: number = x;
enum E { A };
var d: E = x;
var e = E.A;
e = x; | {
"end_byte": 113,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/validNumberAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts_0_39 | var x = 1;
var a: Number;
x = a;
a = x; | {
"end_byte": 39,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/null/validNullAssignments.ts_0_453 | var a: number = null;
var b: boolean = null;
var c: string = null;
var d: void = null;
var e: typeof undefined = null;
e = null; // ok
enum E { A }
E.A = null; // error
class C { foo: string }
var f: C;
f = null; // ok
C = null; // error
interface I { foo: string }
var g: I;
g = null; // ok
I = null; // error
modu... | {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/null/validNullAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/null/directReferenceToNull.ts_0_12 | var x: Null; | {
"end_byte": 12,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/null/directReferenceToNull.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts_0_235 | var x: typeof undefined;
enum E { A }
E = x;
E.A = x;
class C { foo: string }
var f: C;
C = x;
interface I { foo: string }
var g: I;
g = x;
I = x;
module M { export var x = 1; }
M = x;
function i<T>(a: T) { }
// BUG 767030
i = x; | {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/undefined/invalidUndefinedValues.ts_0_304 | var x: typeof undefined;
x = 1;
x = '';
x = true;
var a: void;
x = a;
x = null;
class C { foo: string }
var b: C;
x = C;
x = b;
interface I { foo: string }
var c: I;
x = c;
module M { export var x = 1; }
x = M;
x = { f() { } }
function f<T>(a: T) {
x = a;
}
x = f;
enum E { A }
x = E;
x = E.A; | {
"end_byte": 304,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/undefined/invalidUndefinedValues.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/undefined/directReferenceToUndefined.ts_0_36 | var x: Undefined;
var y = undefined; | {
"end_byte": 36,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/undefined/directReferenceToUndefined.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/undefined/validUndefinedAssignments.ts_0_303 | var x: typeof undefined;
var a: number = x;
var b: boolean = x;
var c: string = x;
var d: void = x;
var e: typeof undefined = x;
e = x; // should work
class C { foo: string }
var f: C;
f = x;
interface I { foo: string }
var g: I;
g = x;
var h: { f(): void } = x;
function i<T>(a: T) {
a = x;
} | {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/undefined/validUndefinedAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/undefined/validUndefinedValues.ts_0_39 | var x: typeof undefined;
x = undefined; | {
"end_byte": 39,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/undefined/validUndefinedValues.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts_0_223 | var x: void;
x = 1;
x = true;
x = '';
x = {}
class C { foo: string; }
var c: C;
x = C;
x = c;
interface I { foo: string; }
var i: I;
x = i;
module M { export var x = 1; }
x = M;
function f<T>(a: T) {
x = a;
}
x = f; | {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/void/invalidVoidValues.ts_0_253 | var x: void;
x = 1;
x = '';
x = true;
enum E { A }
x = E;
x = E.A;
class C { foo: string }
var a: C;
x = a;
interface I { foo: string }
var b: I;
x = b;
x = { f() {} }
module M { export var x = 1; }
x = M;
function f<T>(a: T) {
x = a;
}
x = f; | {
"end_byte": 253,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/void/invalidVoidValues.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/void/validVoidAssignments.ts_0_58 | var x: void;
var y: any;
var z: void;
y = x;
x = y;
x = z; | {
"end_byte": 58,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/void/validVoidAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/void/validVoidValues.ts_0_37 | var x: void;
x = undefined;
x = null; | {
"end_byte": 37,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/void/validVoidValues.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts_0_369 | var x: void;
var a: boolean = x;
var b: string = x;
var c: number = x;
var d: typeof undefined = x;
class C { foo: string; }
var e: C = x;
interface I { bar: string; }
var f: I = x;
var g: { baz: string } = 1;
var g2: { 0: number } = 1;
module M { export var x = 1; }
M = x;
function i<T>(a: T) {
a = x;
}
i = ... | {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/extendBooleanInterface.ts_0_229 | interface Boolean {
doStuff(): string;
doOtherStuff<T>(x: T): T;
}
var x = true;
var a: string = x.doStuff();
var b: string = x.doOtherStuff('hm');
var c: string = x['doStuff']();
var d: string = x['doOtherStuff']('hm'); | {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/extendBooleanInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts_0_43 | var x = true;
var a: Boolean;
x = a;
a = x; | {
"end_byte": 43,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/booleanPropertyAccess.ts_0_61 | var x = true;
var a = x.toString();
var b = x['toString'](); | {
"end_byte": 61,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/booleanPropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/boolInsteadOfBoolean.ts_0_39 | var x: bool;
var a: boolean = x;
x = a; | {
"end_byte": 39,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/boolInsteadOfBoolean.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts_0_226 | interface Boolean {
doStuff(): string;
}
interface NotBoolean {
doStuff(): string;
}
var x = true;
var a: Boolean;
var b: NotBoolean;
a = x;
a = b;
b = a;
b = x;
x = a; // expected error
x = b; // expected error
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts_0_366 | var x = true;
var a: number = x;
var b: string = x;
var c: void = x;
var d: typeof undefined = x;
enum E { A }
var e: E = x;
class C { foo: string }
var f: C = x;
interface I { bar: string }
var g: I = x;
var h: { (): string } = x;
var h2: { toString(): string } = x; // no error
module M { export var a = 1; }
M =... | {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/boolean/validBooleanAssignments.ts_0_89 | var x = true;
var a: any = x;
var b: Object = x;
var c: Boolean = x;
var d: boolean = x; | {
"end_byte": 89,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/boolean/validBooleanAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts_0_40 | var x = '';
var a: String;
x = a;
a = x; | {
"end_byte": 40,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts_0_1499 | interface String {
doStuff(): string;
}
interface NotString {
doStuff(): string;
toString(): string;
charAt(pos: number): string;
charCodeAt(index: number): number;
concat(...strings: string[]): string;
indexOf(searchString: string, position?: number): number;
lastIndexOf(searchString: ... | {
"end_byte": 1499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/extendStringInterface.ts_0_225 | interface String {
doStuff(): string;
doOtherStuff<T>(x:T): T;
}
var x = '';
var a: string = x.doStuff();
var b: string = x.doOtherStuff('hm');
var c: string = x['doStuff']();
var d: string = x['doOtherStuff']('hm'); | {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/extendStringInterface.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts_0_347 | var x = '';
var a: boolean = x;
var b: number = x;
var c: void = x;
var d: typeof undefined = x;
class C { foo: string; }
var e: C = x;
interface I { bar: string; }
var f: I = x;
var g: { baz: string } = 1;
var g2: { 0: number } = 1;
module M { export var x = 1; }
M = x;
function i<T>(a: T) {
a = x;
}
i = x;
... | {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/validStringAssignments.ts_0_85 | var x = '';
var a: any = x;
var b: Object = x;
var c: string = x;
var d: String = x; | {
"end_byte": 85,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/validStringAssignments.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/stringPropertyAccess.ts_0_133 | var x = '';
var a = x.charAt(0);
var b = x.hasOwnProperty('charAt');
var c = x['charAt'](0);
var e = x['hasOwnProperty']('toFixed'); | {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/stringPropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/primitives/string/stringPropertyAccessWithError.ts_0_52 | var x = '';
var d = x['charAt']('invalid'); // error | {
"end_byte": 52,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/primitives/string/stringPropertyAccessWithError.ts"
} |
TypeScript/tests/cases/conformance/types/any/anyPropertyAccess.ts_0_120 | var x: any;
var a = x.foo;
var b = x['foo'];
var c = x['fn']();
var d = x.bar.baz;
var e = x[0].foo;
var f = x['0'].bar; | {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/anyPropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/any/anyAsGenericFunctionCall.ts_0_231 | // any is considered an untyped function call
// can be called except with type arguments which is an error
var x: any;
var a = x<number>();
var b = x<string>('hello');
class C { foo: string; }
var c = x<C>(x);
var d = x<any>(x); | {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/anyAsGenericFunctionCall.ts"
} |
TypeScript/tests/cases/conformance/types/any/anyAsConstructor.ts_0_255 | // any is considered an untyped function call
// can be called except with type arguments which is an error
var x: any;
var a = new x();
var b = new x('hello');
var c = new x(x);
// grammar allows this for constructors
var d = new x<any>(x); // no error | {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/anyAsConstructor.ts"
} |
TypeScript/tests/cases/conformance/types/any/assignAnyToEveryType.ts_0_455 | // all of these are valid
var x: any;
var a: number = x;
var b: boolean = x;
var c: string = x;
var d: void = x;
var e = null;
e = x;
var f = undefined;
f = x;
enum E {
A
}
var g: E = x;
var g2 = E.A;
g2 = x;
class C {
foo: string;
}
var h: C = x;
interface I {
foo: string;
}
var i: I = x;
var j: {... | {
"end_byte": 455,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/assignAnyToEveryType.ts"
} |
TypeScript/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts_0_453 | declare var x: any;
if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function'
x();
x(1, 2, 3);
x("hello!");
x.prop;
}
if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object'
x.method();
x();
}
if (x instanceof Error) { // 'any' is narrowed t... | {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts"
} |
TypeScript/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts_0_698 | declare var x: any;
declare function isFunction(x): x is Function;
declare function isObject(x): x is Object;
declare function isAnything(x): x is {};
declare function isError(x): x is Error;
declare function isDate(x): x is Date;
if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function'
x();
... | {
"end_byte": 698,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts"
} |
TypeScript/tests/cases/conformance/types/any/anyAsFunctionCall.ts_0_167 | // any is considered an untyped function call
// can be called except with type arguments which is an error
var x: any;
var a = x();
var b = x('hello');
var c = x(x); | {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/anyAsFunctionCall.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.