_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/arrayconcat.ts_0_588
interface IOptions { name?: string; flag?: boolean; short?: string; usage?: string; set?: (s: string) => void; type?: string; experimental?: boolean; } class parser { public options: IOptions[]; public m() { this.options = this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }); } }
{ "end_byte": 588, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayconcat.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInConstructor6_Js.ts_0_177
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js class A { constructor() { /** * @type object */ this.foo = arguments; } }
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInConstructor6_Js.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileTypes.ts_0_961
// @module: commonjs // @outdir: out/ // @allowJs: true // @strictNullChecks: true // @fullEmitPaths: true // @resolveJsonModule: true // @declaration: true // @Filename: file1.ts import b = require('./b.json'); import c = require('./c.json'); import d = require('./d.json'); import e = require('./e.json'); import f = require('./f.json'); import g = require('./g.json'); let booleanLiteral: boolean, nullLiteral: null; let stringLiteral: string; let numberLiteral: number; booleanLiteral = b.a; stringLiteral = b.b; nullLiteral = b.c; booleanLiteral = b.d; const stringOrNumberOrNull: string | number | null = c[0]; stringLiteral = d; numberLiteral = e; numberLiteral = f[0]; booleanLiteral = g[0]; // @Filename: b.json { "a": true, "b": "hello", "c": null, "d": false } // @Filename: c.json ["a", null, "string"] // @Filename: d.json "dConfig" // @Filename: e.json -10 // @Filename: f.json [-10, 30] // @Filename: g.json [true, false]
{ "end_byte": 961, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileTypes.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts_0_690
// @target: es5 var _super = 10; // No Error class Foo { get prop1(): number { var _super = 10; // No error return 10; } set prop1(val: number) { var _super = 10; // No error } } class b extends Foo { get prop2(): number { var _super = 10; // Should be error return 10; } set prop2(val: number) { var _super = 10; // Should be error } } class c extends Foo { get prop2(): number { var x = () => { var _super = 10; // Should be error } return 10; } set prop2(val: number) { var x = () => { var _super = 10; // Should be error } } }
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts" }
TypeScript/tests/cases/compiler/classMemberWithMissingIdentifier.ts_0_27
class C { public {}; }
{ "end_byte": 27, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberWithMissingIdentifier.ts" }
TypeScript/tests/cases/compiler/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts_3_156
@target: es5 (x) => ({ "1": "one", "2": "two" } as { [key: string]: string })[x]; (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x;
{ "end_byte": 156, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.ts" }
TypeScript/tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts_0_248
// @target: es6 // @lib: es2015 declare var console: any; const arr: {y(): number}[] = []; for (let i = 0; i < 3; i++) { arr.push(class C { static x = i; static y = () => C.x * 2; }); } arr.forEach(C => console.log(C.y()));
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.ts_0_259
function f<T>() { function g<U extends T>(u: U): U { return null } return g; } var h: <V, W>(v: V, func: (v: V) => W) => W; var x = h("", f<string>()); // Call should succeed and x should be string. All type parameters should be instantiated to string
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.ts" }
TypeScript/tests/cases/compiler/moduleNewExportBug.ts_0_171
module mod1 { interface mInt { new (bar:any):any; foo (bar:any):any; } class C { public moo() {}} } var c : mod1.C; // ERROR: C should not be visible
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleNewExportBug.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationsAddUndefined.ts_0_436
// @isolatedDeclarations: true // @declaration: true // @strict: true // @filename: file1.ts type N = 1; export class Bar { c? = [2 as N] as const; c3? = 1 as N; readonly r = 1; f = 2; } // @filename: file2.ts export function foo(p = (ip = 10, v: number): void => {}): void{ } type T = number export function foo2(p = (ip = 10 as T, v: number): void => {}): void{} export class Bar2 { readonly r = 1; f = 2; }
{ "end_byte": 436, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationsAddUndefined.ts" }
TypeScript/tests/cases/compiler/es5-umd4.ts_0_181
// @target: ES5 // @sourcemap: false // @declaration: false // @module: umd class A { constructor () { } public B() { return 42; } } export = A;
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-umd4.ts" }
TypeScript/tests/cases/compiler/partialDiscriminatedUnionMemberHasGoodError.ts_0_271
interface TypeA { type: "A"; param: string; } interface TypeB { type: "B"; param: string; } type ValidType = TypeA | TypeB; interface Wrapper { types: ValidType[]; } const foo: Wrapper[] = []; foo.push({ types: [{ type: "A" }] });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/partialDiscriminatedUnionMemberHasGoodError.ts" }
TypeScript/tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts_0_47
// @target: ES5 enum E { x = -01, y = 02, }
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-oldStyleOctalLiteralInEnums.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts_0_244
// @noImplicitReferences: true // @typeRoots: /node_modules/phaser/types // @types: phaser // @traceResolution: true // @currentDirectory: / // @Filename: /node_modules/phaser/types/phaser.d.ts declare const a: number; // @Filename: /a.ts a;
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts" }
TypeScript/tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts_0_112
// @target: ES5 export class A { constructor () { } public B() { return 42; } }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithEnabledCompositeOption.ts_0_128
// @allowJs: true // @outFile: out.js // @composite: true // @filename: a.ts class c { } // @filename: b.js function foo() { }
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithEnabledCompositeOption.ts" }
TypeScript/tests/cases/compiler/nestedBlockScopedBindings1.ts_0_489
function a0() { { let x = 1; } { let x = 1; } } function a1() { { let x; } { let x = 1; } } function a2() { { let x = 1; } { let x; } } function a3() { { let x = 1; } switch (1) { case 1: let x; break; } } function a4() { { let x; } switch (1) { case 1: let x = 1; break; } }
{ "end_byte": 489, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings1.ts" }
TypeScript/tests/cases/compiler/parameterDestructuringObjectLiteral.ts_0_193
// @declaration: true // Repro from #22644 const fn1 = (options: { headers?: {} }) => { }; fn1({ headers: { foo: 1 } }); const fn2 = ({ headers = {} }) => { }; fn2({ headers: { foo: 1 } });
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterDestructuringObjectLiteral.ts" }
TypeScript/tests/cases/compiler/discriminantPropertyInference.ts_0_722
// @noImplicitAny: true // @strictNullChecks: true // Repro from #41759 type DiscriminatorTrue = { disc: true; cb: (x: string) => void; } type DiscriminatorFalse = { disc?: false; cb: (x: number) => void; } type Props = DiscriminatorTrue | DiscriminatorFalse; declare function f(options: DiscriminatorTrue | DiscriminatorFalse): any; // simple inference f({ disc: true, cb: s => parseInt(s) }); // simple inference f({ disc: false, cb: n => n.toFixed() }); // simple inference when strict-null-checks are enabled f({ disc: undefined, cb: n => n.toFixed() }); // requires checking type information since discriminator is missing from object f({ cb: n => n.toFixed() });
{ "end_byte": 722, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminantPropertyInference.ts" }
TypeScript/tests/cases/compiler/widenedTypes.ts_0_609
//@declaration: true null instanceof (() => { }); ({}) instanceof null; // Ok because null is a subtype of function null in {}; "" in null; for (var a in null) { } var t = [3, (3, null)]; t[3] = ""; var x: typeof undefined = 3; x = 3; var y; var u = [3, (y = null)]; u[3] = ""; var ob: { x: typeof undefined } = { x: "" }; // Highlights the difference between array literals and object literals var arr: string[] = [3, null]; // not assignable because null is not widened. BCT is {} var obj: { [x: string]: string; } = { x: 3, y: null }; // assignable because null is widened, and therefore BCT is any
{ "end_byte": 609, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/widenedTypes.ts" }
TypeScript/tests/cases/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName.ts_0_218
// @target: esnext // @module: commonjs,system // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/55038 namespace A { export const A = 0; } export { A } enum B { B } export { B }
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName.ts" }
TypeScript/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts_0_1249
// Repro from #7271 class C1 { item: string } class C2 { item: string[] } class C3 { item: string } function foo1(x: C1 | C2 | C3): string { if (x instanceof C1) { return x.item; } else if (x instanceof C2) { return x.item[0]; } else if (x instanceof C3) { return x.item; } return "error"; } function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } function foo2(x: C1 | C2 | C3): string { if (isC1(x)) { return x.item; } else if (isC2(x)) { return x.item[0]; } else if (isC3(x)) { return x.item; } return "error"; } // More tests class A { a: string } class A1 extends A { } class A2 { a: string } class B extends A { b: string } function goo(x: A) { if (x instanceof A) { x; // A } else { x; // never } if (x instanceof A1) { x; // A1 } else { x; // A } if (x instanceof A2) { x; // A2 } else { x; // A } if (x instanceof B) { x; // B } else { x; // A } }
{ "end_byte": 1249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts" }
TypeScript/tests/cases/compiler/extBaseClass2.ts_0_105
module N { export class C4 extends M.B { } } module M { export class C5 extends B { } }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extBaseClass2.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportWithExport.ts_0_1082
// @module: commonjs // @declaration: true // @filename: server.ts export var a = 10; export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; export var z1 = 10; export var z2 = 10; export var aaaa = 10; // @filename: client.ts export import { } from "./server"; export import { a } from "./server"; export var xxxx = a; export import { a as b } from "./server"; export var xxxx = b; export import { x, a as y } from "./server"; export var xxxx = x; export var xxxx = y; export import { x as z, } from "./server"; export var xxxx = z; export import { m, } from "./server"; export var xxxx = m; export import { a1, x1 } from "./server"; export var xxxx = a1; export var xxxx = x1; export import { a1 as a11, x1 as x11 } from "./server"; export var xxxx = a11; export var xxxx = x11; export import { z1 } from "./server"; export var z111 = z1; export import { z2 as z3 } from "./server"; export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports export import { aaaa } from "./server"; export import { aaaa as bbbb } from "./server";
{ "end_byte": 1082, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportWithExport.ts" }
TypeScript/tests/cases/compiler/functionAndImportNameConflict.ts_0_133
// @module: commonjs // @filename: f1.ts export function f() { } // @filename: f2.ts import {f} from './f1'; export function f() { }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionAndImportNameConflict.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts_0_491
// @noImplicitReferences: true // @traceResolution: true // @allowJs: true // @Filename: /foo/foo.ts export function foo() {} // @Filename: /bar/bar.js export function bar() {} // @Filename: /a.ts import { foo } from "foo"; import { bar } from "bar"; // @Filename: /tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "foo": ["foo/foo.ts"], "bar": ["bar/bar.js"] }, "allowJs": true, "outDir": "bin" } }
{ "end_byte": 491, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts_0_761
// @lib: es5 // @sourcemap: true declare var console: { log(msg: string): void; } type MultiSkilledRobot = [string, string[]]; var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; let [, skillA = ["noSkill", "noSkill"]] = multiRobotA; let [nameMB = "noName" ] = multiRobotB; let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; let [nameMC = "noName" ] = ["roomba", ["vacuum", "mopping"]]; let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vacuum", "mopping"]]; if (nameMB == nameMA) { console.log(skillA[0] + skillA[1]); }
{ "end_byte": 761, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/compiler/letDeclarations-es5.ts_0_211
// @target: ES5 let l1; let l2: number; let l3, l4, l5 :string, l6; let l7 = false; let l8: number = 23; let l9 = 0, l10 :string = "", l11 = null; for(let l11 in {}) { } for(let l12 = 0; l12 < 9; l12++) { }
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-es5.ts" }
TypeScript/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts_0_774
interface A { (key:string):void; } interface B extends A { (key:'foo'):string; } var b:B; // Should not error b('foo').charAt(0); interface A { (x: 'A1'): string; (x: string): void; } interface B extends A { (x: 'B1'): number; } interface A { (x: 'A2'): boolean; } interface B { (x: 'B2'): string[]; } interface C1 extends B { (x: 'C1'): number[]; } interface C2 extends B { (x: 'C2'): boolean[]; } interface C extends C1, C2 { (x: 'C'): string; } var c: C; // none of these lines should error var x1: string[] = c('B2'); var x2: number = c('B1'); var x3: boolean = c('A2'); var x4: string = c('A1'); var x5: void = c('A0'); var x6: number[] = c('C1'); var x7: boolean[] = c('C2'); var x8: string = c('C'); var x9: void = c('generic');
{ "end_byte": 774, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts" }
TypeScript/tests/cases/compiler/hidingCallSignatures.ts_0_313
interface C { new (a: string): string; } interface D extends C { (a: string): number; // Should be ok } interface E { (a: string): {}; } interface F extends E { (a: string): string; } var d: D; d(""); // number new d(""); // should be string var f: F; f(""); // string var e: E; e(""); // {}
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/hidingCallSignatures.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts_0_2172
// @noimplicitany: true var a = {}["hello"]; var b: string = { '': 'foo' }['']; var c = { get: (key: string) => 'foobar' }; c['hello']; const foo = c['hello']; var d = { set: (key: string) => 'foobar' }; const bar = d['hello']; { let e = { get: (key: string) => 'foobar', set: (key: string) => 'foobar' }; e['hello']; e['hello'] = 'modified'; e['hello'] += 1; e['hello'] ++; } { let e = { get: (key: string) => 'foobar', set: (key: string, value: string) => 'foobar' }; e['hello']; e['hello'] = 'modified'; e['hello'] += 1; e['hello'] ++; } { let e = { get: (key: "hello" | "world") => 'foobar', set: (key: "hello" | "world", value: string) => 'foobar' }; e['hello']; e['hello'] = 'modified'; e['hello'] += 1; e['hello'] ++; } { ({ get: (key: string) => 'hello', set: (key: string, value: string) => {} })['hello']; ({ get: (key: string) => 'hello', set: (key: string, value: string) => {} })['hello'] = 'modified'; ({ get: (key: string) => 'hello', set: (key: string, value: string) => {} })['hello'] += 1; ({ get: (key: string) => 'hello', set: (key: string, value: string) => {} })['hello'] ++; } { ({ foo: { get: (key: string) => 'hello', set: (key: string, value: string) => {} } }).foo['hello']; ({ foo: { get: (key: string) => 'hello', set: (key: string, value: string) => {} } }).foo['hello'] = 'modified'; ({ foo: { get: (key: string) => 'hello', set: (key: string, value: string) => {} } }).foo['hello'] += 1; ({ foo: { get: (key: string) => 'hello', set: (key: string, value: string) => {} } }).foo['hello'] ++; } const o = { a: 0 }; declare const k: "a" | "b" | "c"; o[k]; declare const k2: "c"; o[k2]; declare const sym : unique symbol; o[sym]; enum NumEnum { a, b } let numEnumKey: NumEnum; o[numEnumKey]; enum StrEnum { a = "a", b = "b" } let strEnumKey: StrEnum; o[strEnumKey]; interface MyMap<K, T> { get(key: K): T; set(key: K, value: T): void; } interface Dog { bark(): void; } let rover: Dog = { bark() {} }; declare let map: MyMap<Dog, string>; map[rover] = "Rover"; interface I { prop: MyMap<string, string> } declare const m: I; m.prop['a'];
{ "end_byte": 2172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts" }
TypeScript/tests/cases/compiler/importDeclFromTypeNodeInJsSource.ts_0_986
// @target: esnext // @module: commonjs // @allowJs: true // @checkJs: true // @declaration: true // @outDir: ./dist // @filename: /src/node_modules/@types/node/index.d.ts /// <reference path="events.d.ts" /> // @filename: /src/node_modules/@types/node/events.d.ts declare module "events" { namespace EventEmitter { class EventEmitter { constructor(); } } export = EventEmitter; } declare module "nestNamespaceModule" { namespace a1.a2 { class d { } } namespace a1.a2.n3 { class c { } } export = a1.a2; } declare module "renameModule" { namespace a.b { class c { } } import d = a.b; export = d; } // @filename: /src/b.js import { EventEmitter } from 'events'; import { n3, d } from 'nestNamespaceModule'; import { c } from 'renameModule'; export class Foo extends EventEmitter { } export class Foo2 extends n3.c { } export class Foo3 extends d { } export class Foo4 extends c { }
{ "end_byte": 986, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclFromTypeNodeInJsSource.ts" }
TypeScript/tests/cases/compiler/interfaceAssignmentCompat.ts_0_1097
module M { export enum Color { Green, Blue, Brown, } export interface IEye { color:number; } export interface IFrenchEye { coleur:number; } export function CompareEyes(a:IEye,b:IEye):number { return a.color-b.color; } export function CompareYeux(a:IFrenchEye,b:IFrenchEye):number { return a.coleur-b.coleur; } export function test() { var x:IEye[]= []; var result=""; x[0]={ color:Color.Brown }; x[1]={ color:Color.Blue }; x[2]={ color:Color.Green }; x=x.sort(CompareYeux); // parameter mismatch // type of z inferred from specialized array type var z=x.sort(CompareEyes); // ok for (var i=0,len=z.length;i<len;i++) { result+=((Color._map[z[i].color])+"\r\n"); } var eeks:IFrenchEye[] = []; for (var j=z.length=1;j>=0;j--) { eeks[j]=z[j]; // nope: element assignment } eeks=z; // nope: array assignment return result; } } M.test();
{ "end_byte": 1097, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticFuncOverridingProperty.ts_0_100
class a { static x: string; } class b extends a { static x() { return "20"; } }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticFuncOverridingProperty.ts" }
TypeScript/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts_0_845
// @strict: true // @exactOptionalPropertyTypes: true // @declaration: true declare function test<T>(x: { [key: string]: T }): T; declare let x1: { a?: string, b?: number }; declare let x2: { a?: string, b?: number | undefined }; const y1 = test(x1); const y2 = test(x2); var v1: Required<{ a?: string, b?: number }>; var v1: { a: string, b: number }; var v2: Required<{ a?: string, b?: number | undefined }>; var v2: { a: string, b: number | undefined }; var v3: Partial<{ a: string, b: string }>; var v3: { a?: string, b?: string }; var v4: Partial<{ a: string, b: string | undefined }>; var v4: { a?: string, b?: string | undefined }; var v5: Required<Partial<{ a: string, b: string }>>; var v5: { a: string, b: string }; var v6: Required<Partial<{ a: string, b: string | undefined }>>; var v6: { a: string, b: string | undefined };
{ "end_byte": 845, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts" }
TypeScript/tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts_0_644
// @target: es5 // @sourcemap: true class C { cProp = 10; foo() { return "this never gets used."; } constructor(value: number) { return { cProp: value, foo() { return "well this looks kinda C-ish."; } } } } class D extends C { dProp = () => this; constructor(a = 100) { super(a); if (Math.random() < 0.5) { "You win!" return { cProp: 1, dProp: () => this, foo() { return "You win!!!!!" } }; } else return null; } }
{ "end_byte": 644, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts" }
TypeScript/tests/cases/compiler/genericUnboundedTypeParamAssignability.ts_0_451
// @strict: true function f1<T>(o: T) { o.toString(); // error } function f2<T extends {}>(o: T) { o.toString(); // no error } function f3<T extends Record<string, any>>(o: T) { o.toString(); // no error } function user<T>(t: T) { f1(t); f2(t); // error in strict, unbounded T doesn't satisfy the constraint f3(t); // error in strict, unbounded T doesn't satisfy the constraint t.toString(); // error, for the same reason as f1() }
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericUnboundedTypeParamAssignability.ts" }
TypeScript/tests/cases/compiler/classOrderBug.ts_0_135
class bar { public baz: foo; constructor() { this.baz = new foo(); } } class baz {} class foo extends baz {}
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classOrderBug.ts" }
TypeScript/tests/cases/compiler/tsxAttributesHasInferrableIndex.tsx_0_474
// @strict: true // @jsx: react // @jsxFactory: createElement type AttributeValue = number | string | Date | boolean; interface Attributes { [key: string]: AttributeValue; } function createElement(name: string, attributes: Attributes | undefined, ...contents: string[]) { return name; } namespace createElement.JSX { type Element = string; } function Button(attributes: Attributes | undefined, contents: string[]) { return ''; } const b = <Button></Button>
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxAttributesHasInferrableIndex.tsx" }
TypeScript/tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts_0_611
// @target: ES6 // @preserveConstEnums: true export const enum e1 { a, b, c } const enum e2 { x, y, z } var x = e1.a; var y = e2.x; export module m1 { export const enum e3 { a, b, c } const enum e4 { x, y, z } var x1 = e1.a; var y1 = e2.x; var x2 = e3.a; var y2 = e4.x; } module m2 { export const enum e5 { a, b, c } const enum e6 { x, y, z } var x1 = e1.a; var y1 = e2.x; var x2 = e5.a; var y2 = e6.x; var x3 = m1.e3.a; }
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts" }
TypeScript/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts_3_276
r array1: [number, number] = [1, 2]; class B { test: number; test1: any; test2: any; method() { () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" } }
{ "end_byte": 276, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts" }
TypeScript/tests/cases/compiler/typeRootsFromMultipleNodeModulesDirectories.ts_0_569
// @noImplicitReferences: true // @traceResolution: true // @currentDirectory: /src // @Filename: /node_modules/@types/dopey/index.d.ts declare module "xyz" { export const x: number; } // @Filename: /foo/node_modules/@types/grumpy/index.d.ts declare module "pdq" { export const y: number; } // @Filename: /foo/node_modules/@types/sneezy/index.d.ts declare module "abc" { export const z: number; } // @Filename: /foo/bar/a.ts import { x } from "xyz"; import { y } from "pdq"; import { z } from "abc"; x + y + z; // @Filename: /foo/bar/tsconfig.json {}
{ "end_byte": 569, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeRootsFromMultipleNodeModulesDirectories.ts" }
TypeScript/tests/cases/compiler/restIntersection.ts_0_155
var intersection: { x: number, y: number } & { w: string, z: string }; var rest1: { y: number, w: string, z: string }; var {x, ...rest1 } = intersection;
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restIntersection.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts_0_354
// @noimplicitany: true var [a], {b}, c, d; // error var [a1 = undefined], {b1 = null}, c1 = undefined, d1 = null; // error var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error var [a5 = undefined] = []; // error
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts" }
TypeScript/tests/cases/compiler/parameterDecoratorsEmitCrash.ts_0_176
// @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/58269 declare var dec: any; export class C { @dec x: any; constructor(@dec x: any) {} }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterDecoratorsEmitCrash.ts" }
TypeScript/tests/cases/compiler/propertyAccessibility1.ts_0_69
class Foo { private privProp = 0; } var f = new Foo(); f.privProp;
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccessibility1.ts" }
TypeScript/tests/cases/compiler/emitBundleWithShebang2.ts_3_227
@outFile: outFile.js // @module: amd // @target: es5 // @Filename: test.ts #!/usr/bin/env gjs class Doo {} class Scooby extends Doo {} // @Filename: test2.ts #!/usr/bin/env js class Dood {} class Scoobyd extends Dood {}
{ "end_byte": 227, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitBundleWithShebang2.ts" }
TypeScript/tests/cases/compiler/declFileWithErrorsInInputDeclarationFile.ts_0_347
// @declaration: true // @Filename: declFile.d.ts declare module M { declare var x; declare function f(); declare module N { } declare class C { } } // @Filename: client.ts ///<reference path="declFile.d.ts" preserve="true"/> var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileWithErrorsInInputDeclarationFile.ts" }
TypeScript/tests/cases/compiler/switchCaseNarrowsMatchingClausesEvenWhenNonMatchingClausesExist.ts_0_877
export const narrowToLiterals = (str: string) => { switch (str) { case 'abc': { // inferred type as `abc` return str; } default: return 'defaultValue'; } }; export const narrowToString = (str: string, someOtherStr: string) => { switch (str) { case 'abc': { // inferred type should be `abc` return str; } case someOtherStr: { // `string` return str; } default: return 'defaultValue'; } }; export const narrowToStringOrNumber = (str: string | number, someNumber: number) => { switch (str) { case 'abc': { // inferred type should be `abc` return str; } case someNumber: { // inferred type should be `number` return str; } default: return 'defaultValue'; } };
{ "end_byte": 877, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/switchCaseNarrowsMatchingClausesEvenWhenNonMatchingClausesExist.ts" }
TypeScript/tests/cases/compiler/parameterPropertyReferencingOtherParameter.ts_0_74
class Foo { constructor(public x: number, public y: number = x) { } }
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterPropertyReferencingOtherParameter.ts" }
TypeScript/tests/cases/compiler/vararg.ts_0_874
module M { export class C { public f(x:string,...rest:number[]) { var sum=0; for (var i=0;i<rest.length;i++) { sum+=rest[i]; } result+=(x+": "+sum); return result; } public fnope(x:string,...rest:number) { } public fonly(...rest:string[]) { builder=""; for (var i=0;i<rest.length;i++) { builder+=rest[i]; } return builder; } } } var x=new M.C(); var result=""; result+=x.f(x,3,3); // bad first param result+=x.f(3,"hello",3); // bad second param result+=x.f("hello",3,3,3,3,3); // ok result+=x.f("hello"); // ok varargs length 0 result+=x.fonly(3); // ok conversion result+=x.fonly(x); // bad param result+=x.fonly("a"); // ok result+=x.fonly("a","b","c","d"); //ok
{ "end_byte": 874, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/vararg.ts" }
TypeScript/tests/cases/compiler/strictFunctionTypesErrors.ts_0_3401
export {} // @strict: true declare let f1: (x: Object) => Object; declare let f2: (x: Object) => string; declare let f3: (x: string) => Object; declare let f4: (x: string) => string; f1 = f2; // Ok f1 = f3; // Error f1 = f4; // Error f2 = f1; // Error f2 = f3; // Error f2 = f4; // Error f3 = f1; // Ok f3 = f2; // Ok f3 = f4; // Ok f4 = f1; // Error f4 = f2; // Ok f4 = f3; // Error type Func<T, U> = (x: T) => U; declare let g1: Func<Object, Object>; declare let g2: Func<Object, string>; declare let g3: Func<string, Object>; declare let g4: Func<string, string>; g1 = g2; // Ok g1 = g3; // Error g1 = g4; // Error g2 = g1; // Error g2 = g3; // Error g2 = g4; // Error g3 = g1; // Ok g3 = g2; // Ok g3 = g4; // Ok g4 = g1; // Error g4 = g2; // Ok g4 = g3; // Error declare let h1: Func<Func<Object, void>, Object>; declare let h2: Func<Func<Object, void>, string>; declare let h3: Func<Func<string, void>, Object>; declare let h4: Func<Func<string, void>, string>; h1 = h2; // Ok h1 = h3; // Ok h1 = h4; // Ok h2 = h1; // Error h2 = h3; // Error h2 = h4; // Ok h3 = h1; // Error h3 = h2; // Error h3 = h4; // Ok h4 = h1; // Error h4 = h2; // Error h4 = h3; // Error declare let i1: Func<Object, Func<Object, void>>; declare let i2: Func<Object, Func<string, void>>; declare let i3: Func<string, Func<Object, void>>; declare let i4: Func<string, Func<string, void>>; i1 = i2; // Error i1 = i3; // Error i1 = i4; // Error i2 = i1; // Ok i2 = i3; // Error i2 = i4; // Error i3 = i1; // Ok i3 = i2; // Error i3 = i4; // Error i4 = i1; // Ok i4 = i2; // Ok i4 = i3; // Ok interface Animal { animal: void } interface Dog extends Animal { dog: void } interface Cat extends Animal { cat: void } interface Comparer1<T> { compare(a: T, b: T): number; } declare let animalComparer1: Comparer1<Animal>; declare let dogComparer1: Comparer1<Dog>; animalComparer1 = dogComparer1; // Ok dogComparer1 = animalComparer1; // Ok interface Comparer2<T> { compare: (a: T, b: T) => number; } declare let animalComparer2: Comparer2<Animal>; declare let dogComparer2: Comparer2<Dog>; animalComparer2 = dogComparer2; // Error dogComparer2 = animalComparer2; // Ok // Crate<T> is invariant in --strictFunctionTypes mode interface Crate<T> { item: T; onSetItem: (item: T) => void; } declare let animalCrate: Crate<Animal>; declare let dogCrate: Crate<Dog>; // Errors below should elaborate the reason for invariance animalCrate = dogCrate; // Error dogCrate = animalCrate; // Error // Verify that callback parameters are strictly checked declare let fc1: (f: (x: Animal) => Animal) => void; declare let fc2: (f: (x: Dog) => Dog) => void; fc1 = fc2; // Error fc2 = fc1; // Error // Verify that callback parameters aren't loosely checked when types // originate in method declarations namespace n1 { class Foo { static f1(x: Animal): Animal { throw "wat"; } static f2(x: Dog): Animal { throw "wat"; }; } declare let f1: (cb: typeof Foo.f1) => void; declare let f2: (cb: typeof Foo.f2) => void; f1 = f2; f2 = f1; // Error } namespace n2 { type BivariantHack<Input, Output> = { foo(x: Input): Output }["foo"]; declare let f1: (cb: BivariantHack<Animal, Animal>) => void; declare let f2: (cb: BivariantHack<Dog, Animal>) => void; f1 = f2; f2 = f1; // Error }
{ "end_byte": 3401, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictFunctionTypesErrors.ts" }
TypeScript/tests/cases/compiler/typeInferenceFixEarly.ts_0_53
declare function f<T>(p: (t: T) => T): T; f(n => 3);
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInferenceFixEarly.ts" }
TypeScript/tests/cases/compiler/filesEmittingIntoSameOutputWithOutOption.ts_0_111
// @outFile: a.js // @module: amd // @filename: a.ts export class c { } // @filename: b.ts function foo() { }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/filesEmittingIntoSameOutputWithOutOption.ts" }
TypeScript/tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts_0_283
function foo<T>(n: { x: T; y: T }, m: T) { return m; } // these are all errors var x = foo({ x: 3, y: "" }, 4); var x2 = foo<number>({ x: 3, y: "" }, 4); var x3 = foo<string>({ x: 3, y: "" }, 4); var x4 = foo<number>({ x: "", y: 4 }, ""); var x5 = foo<string>({ x: "", y: 4 }, "");
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticFuncOverridingPropertyOfFuncType.ts_0_106
class a { static x: () => string; } class b extends a { static x() { return "20"; } }
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticFuncOverridingPropertyOfFuncType.ts" }
TypeScript/tests/cases/compiler/interfaceOnly.ts_0_73
// @declaration: true interface foo { foo(); f2 (f: ()=> void); }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceOnly.ts" }
TypeScript/tests/cases/compiler/ambientModuleWithClassDeclarationWithExtends.ts_0_64
declare module foo { class A { } class B extends A { } }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientModuleWithClassDeclarationWithExtends.ts" }
TypeScript/tests/cases/compiler/stripMembersOptionality.ts_0_290
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true // repro from #52494 declare const someVal: Required<{ fn?(key: string): string | null; }>; someVal.fn(""); declare const someVal2: Required<{ fn?: (key: string) => string | null; }>; someVal2.fn("");
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stripMembersOptionality.ts" }
TypeScript/tests/cases/compiler/indexWithoutParamType.ts_0_23
var y: { []; } // Error
{ "end_byte": 23, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexWithoutParamType.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportAmd.ts_0_1165
// @module: amd // @declaration: true // @filename: es6ImportNamedImportAmd_0.ts export var a = 10; export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; export var z1 = 10; export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImportAmd_1.ts import { } from "es6ImportNamedImportAmd_0"; import { a } from "es6ImportNamedImportAmd_0"; var xxxx = a; import { a as b } from "es6ImportNamedImportAmd_0"; var xxxx = b; import { x, a as y } from "es6ImportNamedImportAmd_0"; var xxxx = x; var xxxx = y; import { x as z, } from "es6ImportNamedImportAmd_0"; var xxxx = z; import { m, } from "es6ImportNamedImportAmd_0"; var xxxx = m; import { a1, x1 } from "es6ImportNamedImportAmd_0"; var xxxx = a1; var xxxx = x1; import { a1 as a11, x1 as x11 } from "es6ImportNamedImportAmd_0"; var xxxx = a11; var xxxx = x11; import { z1 } from "es6ImportNamedImportAmd_0"; var z111 = z1; import { z2 as z3 } from "es6ImportNamedImportAmd_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided import { aaaa } from "es6ImportNamedImportAmd_0"; // These are elided import { aaaa as bbbb } from "es6ImportNamedImportAmd_0";
{ "end_byte": 1165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportAmd.ts" }
TypeScript/tests/cases/compiler/nodeNextCjsNamespaceImportDefault2.ts_0_294
// @module: nodenext // @moduleResolution: nodenext // @outDir: ./out // @declaration: true // @filename: src/a.cts export const a: number = 1; export default 'string'; // @filename: src/foo.mts import d, {a} from './a.cjs'; import * as ns from './a.cjs'; export {d, a, ns}; d.a; ns.default.a;
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextCjsNamespaceImportDefault2.ts" }
TypeScript/tests/cases/compiler/recursiveArrayNotCircular.ts_0_889
type Action<T, P> = P extends void ? { type : T } : { type: T, payload: P } enum ActionType { Foo, Bar, Baz, Batch } type ReducerAction = | Action<ActionType.Bar, number> | Action<ActionType.Baz, boolean> | Action<ActionType.Foo, string> | Action<ActionType.Batch, ReducerAction[]> function assertNever(a: never): never { throw new Error("Unreachable!"); } function reducer(action: ReducerAction): void { switch(action.type) { case ActionType.Bar: const x: number = action.payload; break; case ActionType.Baz: const y: boolean = action.payload; break; case ActionType.Foo: const z: string = action.payload; break; case ActionType.Batch: action.payload.map(reducer); break; default: return assertNever(action); } }
{ "end_byte": 889, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveArrayNotCircular.ts" }
TypeScript/tests/cases/compiler/computedPropertiesInDestructuring1.ts_0_961
// destructuring in variable declarations let foo = "bar"; let {[foo]: bar} = {bar: "bar"}; let {["bar"]: bar2} = {bar: "bar"}; let foo2 = () => "bar"; let {[foo2()]: bar3} = {bar: "bar"}; let [{[foo]: bar4}] = [{bar: "bar"}]; let [{[foo2()]: bar5}] = [{bar: "bar"}]; function f1({["bar"]: x}: { bar: number }) {} function f2({[foo]: x}: { bar: number }) {} function f3({[foo2()]: x}: { bar: number }) {} function f4([{[foo]: x}]: [{ bar: number }]) {} function f5([{[foo2()]: x}]: [{ bar: number }]) {} // report errors on type errors in computed properties used in destructuring let [{[foo()]: bar6}] = [{bar: "bar"}]; let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; // destructuring assignment ({[foo]: bar} = {bar: "bar"}); ({["bar"]: bar2} = {bar: "bar"}); ({[foo2()]: bar3} = {bar: "bar"}); [{[foo]: bar4}] = [{bar: "bar"}]; [{[foo2()]: bar5}] = [{bar: "bar"}]; [{[foo()]: bar4}] = [{bar: "bar"}]; [{[(1 + {})]: bar4}] = [{bar: "bar"}];
{ "end_byte": 961, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertiesInDestructuring1.ts" }
TypeScript/tests/cases/compiler/genericImplements.ts_0_389
class A { a; }; class B { b; }; interface I { f<T extends A>(): T; } // { f: () => { a; } } // OK class X implements I { f<T extends B>(): T { return undefined; } } // { f: () => { b; } } // OK class Y implements I { f<T extends A>(): T { return undefined; } } // { f: () => { a; } } // OK class Z implements I { f<T>(): T { return undefined; } } // { f: <T>() => T }
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericImplements.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierRelatedSpans2.ts_0_279
// @pretty: true // @filename: file1.ts class A { } class B { } class C { } class D { } class E { } class F { } class G { } class H { } class I { } // @filename: file2.ts class A { } class B { } class C { } class D { } class E { } class F { } class G { } class H { } class I { }
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierRelatedSpans2.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst4.ts_0_15
const a: number
{ "end_byte": 15, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst4.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts_0_207
// @outdir: out/ // @resolveJsonModule: true // @Filename: file1.ts import b1 = require('./b.json'); let x = b1; import b2 = require('./b.json'); if (x) { x = b2; } // @Filename: b.json { [a]: 10 }
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts" }
TypeScript/tests/cases/compiler/exportEqualCallable.ts_0_252
//@module: amd // @Filename: exportEqualCallable_0.ts var server: { (): any; }; export = server; // @Filename: exportEqualCallable_1.ts ///<reference path='exportEqualCallable_0.ts'/> import connect = require('exportEqualCallable_0'); connect();
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualCallable.ts" }
TypeScript/tests/cases/compiler/taggedTemplateStringWithSymbolExpression01.ts_0_157
// taggedTemplateStringWithSymbolExpression01.ts declare function foo(template: any, val: symbol): number; let x!: symbol; let result: number = foo`${x}`;
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringWithSymbolExpression01.ts" }
TypeScript/tests/cases/compiler/unreachableJavascriptChecked.ts_0_218
// @Filename: unreachable.js // @allowJs: true // @checkJs: true // @outDir: out // @allowUnreachableCode: false function unreachable() { return f(); return 2; return 3; function f() {} return 4; }
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableJavascriptChecked.ts" }
TypeScript/tests/cases/compiler/unionTypeWithIndexAndMethodSignature.ts_0_165
// @strict: true interface Options { m(x: number): void; [key: string]: unknown; } declare function f(options: number | Options): void; f({ m(x) { }, });
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithIndexAndMethodSignature.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedJsxAttribute2.tsx_0_688
// @strict: true // @jsx: react // @esModuleInterop: true // @noEmit: true /// <reference path="/.lib/react16.d.ts" /> import React from "react"; import { ComponentPropsWithRef, ElementType } from "react"; function UnwrappedLink<T extends ElementType = ElementType>( props: Omit<ComponentPropsWithRef<ElementType extends T ? "a" : T>, "as">, ) { return <a></a>; } <UnwrappedLink onClick={(e) => {}} />; function UnwrappedLink2<T extends ElementType = ElementType>( props: Omit<ComponentPropsWithRef<ElementType extends T ? "a" : T>, "as"> & { as?: T; }, ) { return <a></a>; } <UnwrappedLink2 onClick={(e) => {}} />; <UnwrappedLink2 as="button" onClick={(e) => {}} />;
{ "end_byte": 688, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedJsxAttribute2.tsx" }
TypeScript/tests/cases/compiler/modulePrologueAMD.ts_0_50
// @module: amd "use strict"; export class Foo {}
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePrologueAMD.ts" }
TypeScript/tests/cases/compiler/interMixingModulesInterfaces4.ts_0_223
module A { export module B { export function createB(): number { return null; } } interface B { name: string; value: number; } } var x : number = A.B.createB();
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interMixingModulesInterfaces4.ts" }
TypeScript/tests/cases/compiler/newFunctionImplicitAny.ts_0_136
//@noimplicitany: true // No implicit any error given when newing a function (up for debate) function Test() { } var test = new Test();
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newFunctionImplicitAny.ts" }
TypeScript/tests/cases/compiler/es6ClassTest3.ts_0_227
module M { class Visibility { public foo() { }; private bar() { }; private x: number; public y: number; public z: number; constructor() { this.x = 1; this.y = 2; } } }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest3.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.ts_0_732
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [string, string[]]; var robotA: Robot = ["trimmer", ["trimming", "edging"]]; function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) { console.log(skillA); } function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { console.log(nameMB); } function foo3([nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["noSkill", "noSkill"]]: Robot) { console.log(nameMA); } foo1(robotA); foo1(["roomba", ["vacuum", "mopping"]]); foo2(robotA); foo2(["roomba", ["vacuum", "mopping"]]); foo3(robotA); foo3(["roomba", ["vacuum", "mopping"]]);
{ "end_byte": 732, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/compiler/moduleImportedForTypeArgumentPosition.ts_0_304
//@module: amd // @Filename: moduleImportedForTypeArgumentPosition_0.ts export interface M2C { } // @Filename: moduleImportedForTypeArgumentPosition_1.ts /**This is on import declaration*/ import M2 = require("moduleImportedForTypeArgumentPosition_0"); class C1<T>{ } class Test1 extends C1<M2.M2C> { }
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleImportedForTypeArgumentPosition.ts" }
TypeScript/tests/cases/compiler/inferentialTypingUsingApparentType1.ts_0_101
function foo<T extends (p: string) => number>(x: T): T { return undefined; } foo(x => x.length);
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingUsingApparentType1.ts" }
TypeScript/tests/cases/compiler/exportDefaultAsyncFunction.ts_0_77
// @target: es6 export default async function foo(): Promise<void> {} foo();
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultAsyncFunction.ts" }
TypeScript/tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.ts_0_4764
// @module: commonjs // @declaration: true class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; // Error <T extends privateClass>(): privateClass; // Error myMethod<T extends privateClass>(): privateClass; // Error } export interface publicInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } interface privateInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; <T extends privateClass>(): privateClass; myMethod<T extends privateClass>(): privateClass; } interface privateInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } export class publicClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { // Error } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { // Error } private myPrivateMethod<T extends privateClass>() { } } export class publicClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } class privateClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { } private myPrivateMethod<T extends privateClass>() { } } class privateClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } export function publicFunctionWithPrivateTypeParameters<T extends privateClass>() { // Error } export function publicFunctionWithPublicTypeParameters<T extends publicClass>() { } function privateFunctionWithPrivateTypeParameters<T extends privateClass>() { } function privateFunctionWithPublicTypeParameters<T extends publicClass>() { } export interface publicInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } interface privateInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } export class publicClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } class privateClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } export function publicFunctionWithPublicTypeParametersWithoutExtends<T>() { } function privateFunctionWithPublicTypeParametersWithoutExtends<T>() { } export interface publicInterfaceWithPrivatModuleTypeParameters { new <T extends privateModule.publicClass>(): privateModule.publicClass; // Error <T extends privateModule.publicClass>(): privateModule.publicClass; // Error myMethod<T extends privateModule.publicClass>(): privateModule.publicClass; // Error } export class publicClassWithWithPrivateModuleTypeParameters { static myPublicStaticMethod<T extends privateModule.publicClass>() { // Error } myPublicMethod<T extends privateModule.publicClass>() { // Error } } export function publicFunctionWithPrivateMopduleTypeParameters<T extends privateModule.publicClass>() { // Error } interface privateInterfaceWithPrivatModuleTypeParameters { new <T extends privateModule.publicClass>(): privateModule.publicClass; <T extends privateModule.publicClass>(): privateModule.publicClass; myMethod<T extends privateModule.publicClass>(): privateModule.publicClass; } class privateClassWithWithPrivateModuleTypeParameters { static myPublicStaticMethod<T extends privateModule.publicClass>() { } myPublicMethod<T extends privateModule.publicClass>() { } } function privateFunctionWithPrivateMopduleTypeParameters<T extends privateModule.publicClass>() { }
{ "end_byte": 4764, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.ts_4767_13909
export module publicModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; // Error <T extends privateClass>(): privateClass; // Error myMethod<T extends privateClass>(): privateClass; // Error } export interface publicInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } interface privateInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; <T extends privateClass>(): privateClass; myMethod<T extends privateClass>(): privateClass; } interface privateInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } export class publicClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { // Error } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { // Error } private myPrivateMethod<T extends privateClass>() { } } export class publicClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } class privateClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { } private myPrivateMethod<T extends privateClass>() { } } class privateClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } export function publicFunctionWithPrivateTypeParameters<T extends privateClass>() { // Error } export function publicFunctionWithPublicTypeParameters<T extends publicClass>() { } function privateFunctionWithPrivateTypeParameters<T extends privateClass>() { } function privateFunctionWithPublicTypeParameters<T extends publicClass>() { } export interface publicInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } interface privateInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } export class publicClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } class privateClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } export function publicFunctionWithPublicTypeParametersWithoutExtends<T>() { } function privateFunctionWithPublicTypeParametersWithoutExtends<T>() { } export interface publicInterfaceWithPrivatModuleTypeParameters { new <T extends privateModule.publicClass>(): privateModule.publicClass; // Error <T extends privateModule.publicClass>(): privateModule.publicClass; // Error myMethod<T extends privateModule.publicClass>(): privateModule.publicClass; // Error } export class publicClassWithWithPrivateModuleTypeParameters { static myPublicStaticMethod<T extends privateModule.publicClass>() { // Error } myPublicMethod<T extends privateModule.publicClass>() { // Error } } export function publicFunctionWithPrivateMopduleTypeParameters<T extends privateModule.publicClass>() { // Error } interface privateInterfaceWithPrivatModuleTypeParameters { new <T extends privateModule.publicClass>(): privateModule.publicClass; <T extends privateModule.publicClass>(): privateModule.publicClass; myMethod<T extends privateModule.publicClass>(): privateModule.publicClass; } class privateClassWithWithPrivateModuleTypeParameters { static myPublicStaticMethod<T extends privateModule.publicClass>() { } myPublicMethod<T extends privateModule.publicClass>() { } } function privateFunctionWithPrivateMopduleTypeParameters<T extends privateModule.publicClass>() { } } module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; <T extends privateClass>(): privateClass; myMethod<T extends privateClass>(): privateClass; } export interface publicInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } interface privateInterfaceWithPrivateTypeParameters { new <T extends privateClass>(): privateClass; <T extends privateClass>(): privateClass; myMethod<T extends privateClass>(): privateClass; } interface privateInterfaceWithPublicTypeParameters { new <T extends publicClass>(): publicClass; <T extends publicClass>(): publicClass; myMethod<T extends publicClass>(): publicClass; } export class publicClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { } private myPrivateMethod<T extends privateClass>() { } } export class publicClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } class privateClassWithWithPrivateTypeParameters { static myPublicStaticMethod<T extends privateClass>() { } private static myPrivateStaticMethod<T extends privateClass>() { } myPublicMethod<T extends privateClass>() { } private myPrivateMethod<T extends privateClass>() { } } class privateClassWithWithPublicTypeParameters { static myPublicStaticMethod<T extends publicClass>() { } private static myPrivateStaticMethod<T extends publicClass>() { } myPublicMethod<T extends publicClass>() { } private myPrivateMethod<T extends publicClass>() { } } export function publicFunctionWithPrivateTypeParameters<T extends privateClass>() { } export function publicFunctionWithPublicTypeParameters<T extends publicClass>() { } function privateFunctionWithPrivateTypeParameters<T extends privateClass>() { } function privateFunctionWithPublicTypeParameters<T extends publicClass>() { } export interface publicInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } interface privateInterfaceWithPublicTypeParametersWithoutExtends { new <T>(): publicClass; <T>(): publicClass; myMethod<T>(): publicClass; } export class publicClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } class privateClassWithWithPublicTypeParametersWithoutExtends { static myPublicStaticMethod<T>() { } private static myPrivateStaticMethod<T>() { } myPublicMethod<T>() { } private myPrivateMethod<T>() { } } export function publicFunctionWithPublicTypeParametersWithoutExtends<T>() { } function privateFunctionWithPublicTypeParametersWithoutExtends<T>() { } }
{ "end_byte": 13909, "start_byte": 4767, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.ts" }
TypeScript/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveScoped.ts_0_1202
// @noImplicitReferences: true // @typeRoots: /a/types,/a/node_modules,/a/node_modules/@types // @types: dummy // @traceResolution: true // @currentDirectory: / // @Filename: /a/types/dummy/index.d.ts export const dummy: number; // @Filename: /a/types/@scoped/typescache/index.d.ts export const typesCache: number; // @Filename: /a/types/mangled__typescache/index.d.ts export const mangledTypes: number; // @Filename: /a/node_modules/@scoped/nodemodulescache/index.d.ts export const nodeModulesCache: number; // @Filename: /a/node_modules/mangled__nodemodulescache/index.d.ts export const mangledNodeModules: number; // @Filename: /a/node_modules/@types/@scoped/attypescache/index.d.ts export const atTypesCache: number; // @Filename: /a/node_modules/@types/mangled__attypescache/index.d.ts export const mangledAtTypesCache: number; // @Filename: /a.ts import { typesCache } from "@scoped/typescache"; import { mangledTypes } from "@mangled/typescache"; import { nodeModulesCache } from "@scoped/nodemodulescache"; import { mangledNodeModules } from "@mangled/nodemodulescache"; import { atTypesCache } from "@scoped/attypescache"; import { mangledAtTypesCache } from "@mangled/attypescache";
{ "end_byte": 1202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveScoped.ts" }
TypeScript/tests/cases/compiler/declarationEmitComputedPropertyNameEnum2.ts_0_237
// @strict: true // @declaration: true // @emitDeclarationOnly: true // @filename: type.ts export type Type = { x?: { [Enum.A]: 0 } }; // @filename: index.ts import { type Type } from "./type"; export const foo = { ...({} as Type) };
{ "end_byte": 237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedPropertyNameEnum2.ts" }
TypeScript/tests/cases/compiler/gettersAndSettersAccessibility.ts_0_131
class C99 { private get Baz():number { return 0; } public set Baz(n:number) {} // error - accessors do not agree in visibility }
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/gettersAndSettersAccessibility.ts" }
TypeScript/tests/cases/compiler/yieldStringLiteral.ts_0_48
function yieldString() { yield 'literal'; }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/yieldStringLiteral.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedOptionalProperty.ts_0_376
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true // repro from https://github.com/microsoft/TypeScript/issues/55164 declare function match<T>(cb: (value: T) => boolean): T; declare function foo(pos: { x?: number; y?: number }): boolean; foo({ y: match(y => y > 0) }) declare function foo2(point: [number?]): boolean; foo2([match(y => y > 0)])
{ "end_byte": 376, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedOptionalProperty.ts" }
TypeScript/tests/cases/compiler/reverseMappedTypeLimitedConstraint.ts_0_438
type XNumber_ = { x: number } declare function foo_<T extends XNumber_>(props: {[K in keyof T & keyof XNumber_]: T[K]}): T; foo_({x: 1, y: 'foo'}); // ----------------------------------------------------------------------------------------- const checkType_ = <T>() => <U extends T>(value: { [K in keyof U & keyof T]: U[K] }) => value; const checked_ = checkType_<{x: number, y: string}>()({ x: 1 as number, y: "y", z: "z", });
{ "end_byte": 438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTypeLimitedConstraint.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationWithNonExistentNamedImport.ts_0_242
// @filename: foo.d.ts export = Foo; export as namespace Foo; declare namespace Foo { function foo(); } declare global { namespace Bar { } } // @filename: bar.d.ts import { Bar } from './foo'; export = Bar; export as namespace Bar;
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationWithNonExistentNamedImport.ts" }
TypeScript/tests/cases/compiler/implicitAnyWidenToAny.ts_0_737
//@noimplicitany: true // these should be errors var x = null; // error at "x" var x1 = undefined; // error at "x1" var widenArray = [null, undefined]; // error at "widenArray" var emptyArray = []; // these should not be error class AnimalObj { x:any; } var foo = 5; var bar = "Hello World"; var foo1: any = null; var foo2: any = undefined; var temp: number = 5; var c: AnimalObj = { x: null }; var array1 = ["Bob",2]; var array2: any[] = []; var array3: any[] = [null, undefined]; var array4: number[] = [null, undefined]; var array5 = <any[]>[null, undefined]; var objLit: { new (n: number): any; }; function anyReturnFunc(): any { } var obj0 = new objLit(1); var obj1 = anyReturnFunc();
{ "end_byte": 737, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyWidenToAny.ts" }
TypeScript/tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts_1_161
class A<T1, T2> { constructor(private map: (value: T1) => T2) { } } class B extends A<number> { constructor() { super(value => String(value)); } }
{ "end_byte": 161, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts" }
TypeScript/tests/cases/compiler/overloadResolutionOverCTLambda.ts_0_113
function foo(b: (item: number) => boolean) { } foo(a => a); // can not convert (number)=>bool to (number)=>number
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadResolutionOverCTLambda.ts" }
TypeScript/tests/cases/compiler/declarationEmitFunctionDuplicateNamespace.ts_0_113
// @declaration: true function f(a: 0): 0; function f(a: 1): 1; function f(a: 0 | 1) { return a; } f.x = 2;
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitFunctionDuplicateNamespace.ts" }
TypeScript/tests/cases/compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts_0_145
//@noUnusedLocals:true function f<T>() { } type T<T> = { }; interface I<T> { }; class C<T> { public m<V>() { } }; let l = <T>() => { };
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts" }
TypeScript/tests/cases/compiler/importTypeGenericArrowTypeParenthesized.ts_0_445
// @declaration: true // @filename: module.d.ts declare module "module" { export interface Modifier<T> { } export function fn<T>(x: T): Modifier<T>; } // @filename: index.ts import { fn } from "module"; export const fail1 = fn(<T>(x: T): T => x); export const fail2 = fn(function<T>(x: T): T { return x; }); export const works1 = fn((x: number) => x); type MakeItWork = <T>(x: T) => T; export const works2 = fn<MakeItWork>(x => x);
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importTypeGenericArrowTypeParenthesized.ts" }
TypeScript/tests/cases/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.ts_0_623
// @noErrorTruncation: true // @noImplicitAny: true // @allowJs: true // @checkJs: true // @outDir: built // @filename: index.js function Color(obj) { this.example = true }; Color.prototype = { negate: function () {return this;}, lighten: function (ratio) {return this;}, darken: function (ratio) {return this;}, saturate: function (ratio) {return this;}, desaturate: function (ratio) {return this;}, whiten: function (ratio) {return this;}, blacken: function (ratio) {return this;}, greyscale: function () {return this;}, clearer: function (ratio) {return this;}, toJSON: function () {return this.rgb();}, };
{ "end_byte": 623, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.ts" }
TypeScript/tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts_0_180
// @strict: true export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; export declare let y: { foo: { bar: number | undefined } }; x = y; y = x;
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts" }
TypeScript/tests/cases/compiler/enumAssignmentCompat2.ts_0_438
enum W { a, b, c, } module W { export class D { } } interface WStatic { a: W; b: W; c: W; } var x: WStatic = W; var y: typeof W = W; var z: number = W; // error var a: number = W.a; var b: typeof W = W.a; // error var c: typeof W.a = W.a; var d: typeof W = 3; // error var e: typeof W.a = 4; var f: WStatic = W.a; // error var g: WStatic = 5; // error var h: W = 3; var i: W = W.a; i = W.a; W.D; var p: W.D;
{ "end_byte": 438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumAssignmentCompat2.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability44.ts_0_78
class Foo { constructor(x: number) {} } const foo: { new(): Foo } = Foo;
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability44.ts" }