_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/moduleReopenedTypeSameBlock.ts_0_132
module M { export class C1 { } } module M { export interface I { n: number; } export class C2 { f(): I { return null; } } }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleReopenedTypeSameBlock.ts" }
TypeScript/tests/cases/compiler/letDeclarations-useBeforeDefinition.ts_0_78
// @target: ES6 { l1; let l1; } var v1; { v1; let v1 = 0; }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-useBeforeDefinition.ts" }
TypeScript/tests/cases/compiler/enumUsedBeforeDeclaration.ts_3_150
nst v: Color = Color.Green; const v2: ConstColor = ConstColor.Green; enum Color { Red, Green, Blue } const enum ConstColor { Red, Green, Blue }
{ "end_byte": 150, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumUsedBeforeDeclaration.ts" }
TypeScript/tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts_0_147
class a { get x() { return "20"; } set x(aValue: string) { } } class b extends a { x() { return "20"; } }
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts" }
TypeScript/tests/cases/compiler/superCallInsideObjectLiteralExpression.ts_0_129
class A { foo() { } } class B extends A { constructor() { var x = { x: super() } } }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallInsideObjectLiteralExpression.ts" }
TypeScript/tests/cases/compiler/indexedAccessTypeConstraints.ts_0_631
// @strict: true // Repro from #14557 interface IData<T> { content: T; } type Data<T> = { get: <K extends keyof T>(prop: K) => T[K]; }; class Parent<M> { constructor(private data: Data<M>) {} getData(): Data<M> { return this.data; } } export class Foo<C> extends Parent<IData<C>> { g...
{ "end_byte": 631, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessTypeConstraints.ts" }
TypeScript/tests/cases/compiler/superPropertyAccess.ts_1_1563
class MyBase { m1(a: string) { return a; } private p1() { } m2: () => void = function () { } d1: number = 42; private d2: number = 42; get value() {return 0 } set value(v: number) { } } class MyDerived extends MyBase { foo() { super.m1("hi"); ...
{ "end_byte": 1563, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyAccess.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst17.ts_0_661
// @target:es5 // @allowUnreachableCode: true 'use strict' declare function use(a: any); var x; for (let x = 10; ;) { use(x); } use(x); for (const x = 10; ;) { use(x); } for (; ;) { let x = 10; use(x); x = 1; } for (; ;) { const x = 10; use(x); } for (let x; ;) { use(x); x = 1;...
{ "end_byte": 661, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst17.ts" }
TypeScript/tests/cases/compiler/systemModule1.ts_0_53
// @target: es6 // @module: system export var x = 1;
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule1.ts" }
TypeScript/tests/cases/compiler/nestedBlockScopedBindings11.ts_0_116
var x; { let x; () => x; } var y; switch (1) { case 1: let y; () => y; break; }
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings11.ts" }
TypeScript/tests/cases/compiler/extendAndImplementTheSameBaseType2.ts_0_258
class C<T> { foo: number bar(): T { return null; } } class D extends C<string> implements C<number> { baz() { } } var d: D = new D(); var r: string = d.foo; var r2: number = d.foo; var r3: string = d.bar(); var r4: number = d.bar();
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendAndImplementTheSameBaseType2.ts" }
TypeScript/tests/cases/compiler/topLevelLambda3.ts_0_28
var f = () => {this.window;}
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/topLevelLambda3.ts" }
TypeScript/tests/cases/compiler/parenthesizedArrowExpressionASI.ts_0_68
const x = (a: any[]) => ( // comment undefined as number );
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parenthesizedArrowExpressionASI.ts" }
TypeScript/tests/cases/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.ts_0_587
// @target: es2015 // https://github.com/microsoft/TypeScript/issues/48771 class A { readonly #privateField: string; constructor(arg: { key: string }, public exposedField: number) { ({ key: this.#privateField } = arg); } log() { console.log(this.#privateField); console.log(this.exposedField); }...
{ "end_byte": 587, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.ts" }
TypeScript/tests/cases/compiler/jsDeclarationsInheritedTypes.ts_0_421
// @checkJs: true // @allowJs: true // @declaration: true // @emitDeclarationOnly: true // @outDir: ./dist // @filename: a.js /** * @typedef A * @property {string} a */ /** * @typedef B * @property {number} b */ class C1 { /** * @type {A} */ value; } class C2 extends C1 { /** * @ty...
{ "end_byte": 421, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationsInheritedTypes.ts" }
TypeScript/tests/cases/compiler/continueTarget2.ts_0_43
target: while (true) { continue target; }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueTarget2.ts" }
TypeScript/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts_0_60
function foo<T extends T>(x: T): number { return x; }
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterHasSelfAsConstraint.ts" }
TypeScript/tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions2.ts_3_142
@target: es6 function f(x: TemplateStringsArray, y: string, z: string) { } // Incomplete call, enough parameters. f `123qdawdrqw${ }${
{ "end_byte": 142, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions2.ts" }
TypeScript/tests/cases/compiler/fileWithNextLine3.ts_3_144
Note: there is a nextline (0x85) between the return and the // 0. It should be counted as a space and should not trigger ASI return…0;
{ "end_byte": 144, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fileWithNextLine3.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingAmd.ts_0_376
// @module: amd // @declaration: true // @target: ES5 // @filename: es6ImportDefaultBindingAmd_0.ts var a = 10; export default a; // @filename: es6ImportDefaultBindingAmd_1.ts import defaultBinding from "es6ImportDefaultBindingAmd_0"; var x = defaultBinding; import defaultBinding2 from "es6ImportDefaultBindingAmd_0";...
{ "end_byte": 376, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingAmd.ts" }
TypeScript/tests/cases/compiler/getterSetterSubtypeAssignment.ts_0_1854
// @target: es2015 // @strictNullChecks: true // @noImplicitThis: true class NumberOrUndefined { _x: number | undefined; get x(): number { return this._x ?? 0; } set x(value: number | undefined) { this._x = value; } additionAssignment() { this.x += 1; } subtractionAssignment() { ...
{ "end_byte": 1854, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getterSetterSubtypeAssignment.ts" }
TypeScript/tests/cases/compiler/contextualTyping3.ts_0_47
class foo { public bar:{id:number;} = {id:5}; }
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping3.ts" }
TypeScript/tests/cases/compiler/implicitAnyInCatch.ts_0_229
// @noimplicitany: true // this should not be an error try { } catch (error) { if (error.number === -2147024809) { } } for (var key in this) { } class C { public temp() { for (var x in this) { } } }
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyInCatch.ts" }
TypeScript/tests/cases/compiler/overloadOnConstConstraintChecks3.ts_0_228
class A { private x = 1} class B extends A {} class C extends A { public foo() { } } function foo(name: 'hi'): B; function foo(name: 'bye'): C; function foo(name: string): A; function foo(name: any): A { return null; }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstConstraintChecks3.ts" }
TypeScript/tests/cases/compiler/objectTypeWithOptionalProperty1.ts_4_42
var b = { x?: 1 // error }
{ "end_byte": 42, "start_byte": 4, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectTypeWithOptionalProperty1.ts" }
TypeScript/tests/cases/compiler/controlFlowCaching.ts_0_3203
// @strictNullChecks: true // Repro for #8401 function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { var isRtl = this._isRtl(); // chart mirroring // prepare variable var o = this.opt, ta = this.chart.theme.axis, position = o.position, leftBottom = position !== "rightOrTop", rot...
{ "end_byte": 3203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowCaching.ts" }
TypeScript/tests/cases/compiler/extendedUnicodeEscapeSequenceIdentifiers.ts_0_81
// @target: es6 const \u{0061} = 12; const a\u{0061} = 12; console.log(a + aa);
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendedUnicodeEscapeSequenceIdentifiers.ts" }
TypeScript/tests/cases/compiler/substitutionTypeForIndexedAccessType2.ts_0_392
interface Foo { foo: string|undefined } type Str<T extends string> = T type Bar<T> = T extends Foo ? T['foo'] extends string // Type 'T["foo"]' does not satisfy the constraint 'string'. // Type 'string | undefined' is not assignable to type 'string'. // Type 'undefined' is not assignable...
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/substitutionTypeForIndexedAccessType2.ts" }
TypeScript/tests/cases/compiler/stackDepthLimitCastingType.ts_0_1179
// @strict: true // @skipLibCheck: true // @filename: node_modules/backbone/index.d.ts declare global { interface JQueryXHR { } class Model<T = any, E = {}> { initialize(attributes?: T, options?: CombinedModelConstructorOptions<E, this>): void; fetch(options?: any): JQueryXHR; } interfac...
{ "end_byte": 1179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stackDepthLimitCastingType.ts" }
TypeScript/tests/cases/compiler/declFileTypeofModule.ts_0_179
// @declaration: true module m1 { export var c: string; } var m1_1 = m1; var m1_2: typeof m1; module m2 { export var d: typeof m2; } var m2_1 = m2; var m2_2: typeof m2;
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeofModule.ts" }
TypeScript/tests/cases/compiler/elidedJSImport1.ts_0_662
// @allowJs: true // @checkJs: true // @moduleResolution: node // @module: ES2020 // @outDir: out // @Filename: caller.js import * as fs from 'fs'; import TruffleContract from '@truffle/contract'; // Runtime err: this import is elided in transform console.log(fs); console.log('TruffleContract is ', typeof TruffleContr...
{ "end_byte": 662, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/elidedJSImport1.ts" }
TypeScript/tests/cases/compiler/parseCommaSeparatedNewlineNumber.ts_0_6
(a, 1)
{ "end_byte": 6, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseCommaSeparatedNewlineNumber.ts" }
TypeScript/tests/cases/compiler/unusedFunctionsinNamespaces6.ts_0_277
//@noUnusedLocals:true //@noUnusedParameters:true namespace Validation { var function1 = function() { } export function function2() { } function function3() { function1(); } function function4() { } export let a = function3; }
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedFunctionsinNamespaces6.ts" }
TypeScript/tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts_0_514
// @declaration: true function noArgs(): string { return null as any; } function oneArg(input: string): string { return null as any; } export class Wrapper { private proxy<T, U>(fn: (options: T) => U): (options: T) => U; private proxy<T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; ...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts" }
TypeScript/tests/cases/compiler/exportDefaultTypeClassAndValue.ts_0_94
const foo = 1 export default foo export default class Foo {} type Bar = {} export default Bar
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultTypeClassAndValue.ts" }
TypeScript/tests/cases/compiler/genericRestTypes.ts_0_1155
// @strict: true // Repro from #25793 // Gets the parameters of a function type as a tuple // Removes the first element from a tuple type Tail<T extends any[]> = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; type MyFunctionType = (foo: number, bar: string) => boolean; type Explic...
{ "end_byte": 1155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericRestTypes.ts" }
TypeScript/tests/cases/compiler/es6ImportWithoutFromClause.ts_0_212
// @target: es6 // @declaration: true // @declaration: true // @filename: es6ImportWithoutFromClause_0.ts export var a = 10; // @filename: es6ImportWithoutFromClause_1.ts import "es6ImportWithoutFromClause_0";
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportWithoutFromClause.ts" }
TypeScript/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts_0_3529
// @target: es5 const foo: any = {}; // properties foo.x = class { constructor () {} } foo.y = class { constructor () {} } // keywords foo.break = class { constructor () {} } foo.case = class { constructor () {} } foo.catch = class { constructor () {} } foo.class = class { constructor () {} }...
{ "end_byte": 3529, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts" }
TypeScript/tests/cases/compiler/recursiveTypeComparison.ts_0_493
// Before fix this would take an exceeding long time to complete (#1170) interface Observable<T> { // This member can't be of type T, Property<T>, or Observable<anything but T> needThisOne: Observable<T>; // Add more to make it slower expo1: Property<T[]>; // 0.31 seconds in check expo2: Property<...
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeComparison.ts" }
TypeScript/tests/cases/compiler/jsdocCastCommentEmit.ts_0_124
// allowJs: true // checkJs: true // outDir: out/ // filename: input.js function f() { return /* @type {number} */ 42; }
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocCastCommentEmit.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability22.ts_0_341
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var obj = {one: [true]}; export var __val__obj = obj; } __test2__.__val__obj = ...
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability22.ts" }
TypeScript/tests/cases/compiler/extendConstructSignatureInInterface.ts_0_106
interface C { new(x: number): C; } var CStatic: C; class E extends CStatic { } var e: E = new E(1);
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendConstructSignatureInInterface.ts" }
TypeScript/tests/cases/compiler/importAndVariableDeclarationConflict2.ts_0_100
module m { export var m = ''; } import x = m.m; class C { public foo() { var x = ''; } }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importAndVariableDeclarationConflict2.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationGlobal3.ts_0_341
// @module: commonjs // @declaration: true // @filename: f1.ts export class A {}; // @filename: f2.ts // change the shape of Array<T> import {A} from "./f1"; declare global { interface Array<T> { getCountAsString(): string; } } // @filename: f3.ts import "./f2"; let x = [1]; let y = x.getCountAsStr...
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationGlobal3.ts" }
TypeScript/tests/cases/compiler/parameterPropertyInConstructorWithPrologues.ts_0_1183
// https://github.com/microsoft/TypeScript/issues/48671 class C {} class Foo1 { constructor(private A: string) { "ngInject1"; } } class Foo2 { constructor(private A: string, private B: string) { "ngInject1"; "ngInject2"; } } class Foo3 { constructor(private A: string, private B: string, privat...
{ "end_byte": 1183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterPropertyInConstructorWithPrologues.ts" }
TypeScript/tests/cases/compiler/inheritFromGenericTypeParameter.ts_0_53
class C<T> extends T { } interface I<T> extends T { }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritFromGenericTypeParameter.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenEnumWithEnumMemberConflict.ts_0_43
enum Color { Color, Thing = Color }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenEnumWithEnumMemberConflict.ts" }
TypeScript/tests/cases/compiler/exportDefaultVariable.ts_0_103
// Regression test for #3018 declare var io: any; declare module 'module' { export default io; }
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultVariable.ts" }
TypeScript/tests/cases/compiler/randomSemicolons1.ts_0_18
; ; var a = 1; ;
{ "end_byte": 18, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/randomSemicolons1.ts" }
TypeScript/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue1.ts_0_971
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/37178 type A = { type: "A" }; type B = { type: "B" }; type AorB = A | B; const isA = (x: AorB): x is A => x.type === "A"; const isB = (x: AorB): x is B => x.type === "B"; function test1(x: AorB) { switch (true) { case isA(x): ...
{ "end_byte": 971, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue1.ts" }
TypeScript/tests/cases/compiler/reexportMissingDefault1.ts_0_144
// @esModuleInterop: true // @filename: b.ts export const b = null; // @filename: a.ts export { b } from "./b"; export { default } from "./b";
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportMissingDefault1.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts_0_451
interface Collection<T> { length: number; add(x: T): void; remove(x: T): boolean; } interface Combinators { forEach<T>(c: Collection<T>, f: (x: T) => Date): void; } var c2: Collection<number>; var _: Combinators; // errors on all 3 lines, bug was that r5 was the only line with errors var f = (x: numb...
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts" }
TypeScript/tests/cases/compiler/declarationEmitWithDefaultAsComputedName2.ts_0_379
// @declaration: true // @target: es5 // @filename: other.ts type Experiment<Name> = { name: Name; }; declare const createExperiment: <Name extends string>( options: Experiment<Name> ) => Experiment<Name>; export default createExperiment({ name: "foo" }); // @filename: main.ts import * as other2 from "./o...
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitWithDefaultAsComputedName2.ts" }
TypeScript/tests/cases/compiler/conditionalExpressions2.ts_0_328
// @allowUnreachableCode: true var a = false ? 1 : null; var b = false ? undefined : 0; var c = false ? 1 : 0; var d = false ? false : true; var e = false ? "foo" : "bar"; var f = false ? null : undefined; var g = true ? {g:5} : null; var h = [{h:5}, null]; function i() { if (true) { return { x: 5 }; } else { return n...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressions2.ts" }
TypeScript/tests/cases/compiler/contextualTypesNegatedTypeLikeConstraintInGenericMappedType3.ts_0_994
// @strict: true // @noEmit: true type MappedOmit<T, K extends keyof any> = { [P in keyof T as Exclude<P, K>]: T[P]; } type IntrinsicElements = { div: { onChange: (ev: Event) => void; }; span: { onChange: (ev: Event) => void; }; }; type ElementType = keyof IntrinsicElements; let DEFAULT_TABS_TAG = "...
{ "end_byte": 994, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypesNegatedTypeLikeConstraintInGenericMappedType3.ts" }
TypeScript/tests/cases/compiler/restParameters.ts_0_211
function f18(a?:string, ...b:number[]){} function f19(a?:string, b?:number, ...c:number[]){} function f20(a:string, b?:string, ...c:number[]){} function f21(a:string, b?:string, c?:number, ...d:number[]){}
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParameters.ts" }
TypeScript/tests/cases/compiler/constDeclarations-access2.ts_0_273
// @target: ES6 const x = 0 // Errors x = 1; x += 2; x -= 3; x *= 4; x /= 5; x %= 6; x <<= 7; x >>= 8; x >>>= 9; x &= 10; x |= 11; x ^= 12; x++; x--; ++x; --x; ++((x)); // OK var a = x + 1; function f(v: number) { } f(x); if (x) { } x; (x); -x; +x; x.toString();
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-access2.ts" }
TypeScript/tests/cases/compiler/privateVisibility.ts_0_422
class Foo { public pubMeth() {this.privMeth();} private privMeth() {} public pubProp = 0; private privProp = 0; } var f = new Foo(); f.privMeth(); // should not work f.privProp; // should not work f.pubMeth(); // should work f.pubProp; // should work module M { export class C { public pub = 0; private priv =...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateVisibility.ts" }
TypeScript/tests/cases/compiler/typeParameterExtendsPrimitive.ts_0_482
// #14473 function f<T extends number>() { var t: T; var v = { [t]: 0 } return t + t; } // #15501 interface I { x: number } type IdMap<T> = { [P in keyof T]: T[P] }; function g<T extends I>(i: IdMap<T>) { const n: number = i.x; return i.x * 2; } // #17069 function h<T extends Record<K,...
{ "end_byte": 482, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterExtendsPrimitive.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives4.ts_0_434
// @noImplicitReferences: true // @traceResolution: true // @declaration: true // @typeRoots: /types // @currentDirectory: / // $ comes from d.ts file - no need to add type reference directive // @filename: /ref.d.ts interface $ { x } // @filename: /types/lib/index.d.ts declare let $: { x: number } // @filename: /...
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives4.ts" }
TypeScript/tests/cases/compiler/declarationEmitDetachedComment2.ts_0_394
// @target: es5 // @module: commonjs // @declaration: true // @removeComments: true // @filename: test1.ts /*! Copyright 2015 MyCompany Inc. */ /** * Hello class */ class Hello { } // @filename: test2.ts /* A comment at the top of the file. */ /** * Hi class */ class Hi { } // @filename: test3.ts // A one-li...
{ "end_byte": 394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDetachedComment2.ts" }
TypeScript/tests/cases/compiler/letAndVarRedeclaration.ts_0_543
// @allowUnreachableCode: true // @target: es6 let e0 var e0; function e0() { } function f0() { let x1; var x1; function x1() { } } function f1() { let x; { var x; } { function x() { } } } module M0 { let x2; var x2; function x2() { } } module M1 { l...
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letAndVarRedeclaration.ts" }
TypeScript/tests/cases/compiler/inferenceOfNullableObjectTypesWithCommonBase.ts_0_812
// @strict: true function equal<T>(a: T, b: T) { } let v = null!; // Object types with common base types type B = { foo: string } type D = { foo: string; bar: number } equal(v as B, v as undefined | D) equal(v as undefined | D, v as B) equal<undefined | B>(v as B, v as undefined | D) equal<undefined | B>(v as und...
{ "end_byte": 812, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceOfNullableObjectTypesWithCommonBase.ts" }
TypeScript/tests/cases/compiler/castFunctionExpressionShouldBeParenthesized.ts_0_33
(function a() { } as any)().foo()
{ "end_byte": 33, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/castFunctionExpressionShouldBeParenthesized.ts" }
TypeScript/tests/cases/compiler/standaloneBreak.ts_0_6
break;
{ "end_byte": 6, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/standaloneBreak.ts" }
TypeScript/tests/cases/compiler/uniqueSymbolAllowsIndexInObjectWithIndexSignature.ts_0_261
// @lib: es6 // https://github.com/Microsoft/TypeScript/issues/21962 export const SYM = Symbol('a unique symbol'); export interface I { [SYM]: 'sym'; [x: string]: 'str'; } let a: I = {[SYM]: 'sym'}; // Expect ok let b: I = {[SYM]: 'str'}; // Expect error
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/uniqueSymbolAllowsIndexInObjectWithIndexSignature.ts" }
TypeScript/tests/cases/compiler/typeAliasDeclarationEmit3.ts_0_287
function f1(): void { for (let i = 0; i < 1; i++) type foo = []; console.log('f1'); } function f2(): void { while (true) type foo = []; console.log('f2'); } function f3(): void { if (true) type foo = []; console.log('f3'); }
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasDeclarationEmit3.ts" }
TypeScript/tests/cases/compiler/es5-umd.ts_0_168
// @target: ES5 // @sourcemap: false // @declaration: false // @module: umd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-umd.ts" }
TypeScript/tests/cases/compiler/exportStarForValues4.ts_0_253
// @module: amd // @filename: file1.ts export interface Foo { x } // @filename: file2.ts export interface A { x } export * from "file1" export * from "file3" var x = 1; // @filename: file3.ts export interface B { x } export * from "file2" var x = 1;
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportStarForValues4.ts" }
TypeScript/tests/cases/compiler/esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.ts_0_87
// @esModuleInterop: true import {default as a, default as b} from "m"; void a; void b;
{ "end_byte": 87, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.ts" }
TypeScript/tests/cases/compiler/errorCause.ts_0_608
// @target: es2021, es2022, esnext declare const a: unknown; let err = new Error("foo", { cause: new Error("bar") }); err.cause; let anotherErr = new Error("foo", { cause: a }); anotherErr.cause; new EvalError("foo", { cause: new Error("bar") }); new EvalError("foo", { cause: a }); new RangeError("foo", { cause: new...
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorCause.ts" }
TypeScript/tests/cases/compiler/inferenceExactOptionalProperties2.ts_0_1596
// @strict: true // @exactOptionalPropertyTypes: true // @noEmit: true type Values<T> = T[keyof T]; type EventObject = { type: string; }; interface ActorLogic<TEvent extends EventObject> { transition: (ev: TEvent) => unknown; } type UnknownActorLogic = ActorLogic<never>; interface ProvidedActor { src: string...
{ "end_byte": 1596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceExactOptionalProperties2.ts" }
TypeScript/tests/cases/compiler/objectLitGetterSetter.ts_12_299
var obj = {}; Object.defineProperty(obj, "accProperty", <PropertyDescriptor>({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }))
{ "end_byte": 299, "start_byte": 12, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLitGetterSetter.ts" }
TypeScript/tests/cases/compiler/moduledecl.ts_0_3692
// @declaration: true // @target: es5 module a { } module b.a { } module c.a.b { import ma = a; } module mImport { import d = a; import e = b.a; import d1 = a; import e1 = b.a; } module m0 { function f1() { } function f2(s: string); function f2(n: number); function f2(ns: a...
{ "end_byte": 3692, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduledecl.ts" }
TypeScript/tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts_0_169
// @target: es5 class a { x() { return "20"; } } class b extends a { get x() { return () => "20"; } set x(aValue) { } }
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts" }
TypeScript/tests/cases/compiler/letDeclarations-scopes-duplicates6.ts_0_91
// @target: ES6 // @Filename: file1.ts var var1 = 0; // @Filename: file2.ts let var1 = 0;
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-scopes-duplicates6.ts" }
TypeScript/tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts_0_205
class C { private x = 1; } class D extends C { } function foo(x: "hi", items: string[]): typeof foo; function foo(x: string, items: string[]): typeof foo { return null; } var a: D = foo("hi", []);
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts" }
TypeScript/tests/cases/compiler/unusedSwitchStatement.ts_0_256
//@noUnusedLocals:true //@noUnusedParameters:true switch (1) { case 0: let x; break; case 1: const c = 1; break; default: let z = 2; } switch (2) { case 0: let x; case 1: x=1; }
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedSwitchStatement.ts" }
TypeScript/tests/cases/compiler/incompleteObjectLiteral1.ts_0_28
var tt = { aa; } var x = tt;
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompleteObjectLiteral1.ts" }
TypeScript/tests/cases/compiler/exportRedeclarationTypeAliases.ts_0_107
// @module: commonjs export type Foo = number; export function Foo(): number; export function Foo(): any {}
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportRedeclarationTypeAliases.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationInAmbientModule4.ts_0_688
// @module: commonjs // @declaration: true; // @filename: O.d.ts declare module "Observable" { class Observable {} } declare module "M" { class Cls { x: number } } declare module "Map" { import { Cls } from "M"; module "Observable" { interface Observable { foo(): Cls; } ...
{ "end_byte": 688, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationInAmbientModule4.ts" }
TypeScript/tests/cases/compiler/computedEnumMemberSyntacticallyString.ts_0_248
// @isolatedModules: true,false // @noTypesAndSymbols: true // @target: esnext const BAR = 2..toFixed(0); enum Foo { A = `${BAR}`, B = "2" + BAR, C = (`${BAR}`), F = BAR, G = 2 + BAR, H = A, I = H + BAR, J = H }
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedEnumMemberSyntacticallyString.ts" }
TypeScript/tests/cases/compiler/intersectionApparentTypeCaching.ts_0_204
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/58175 type TX<T extends any[] & object> = T["length"]; type T0<U extends any[] & object> = U; type T1 = T0<string[]>;
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionApparentTypeCaching.ts" }
TypeScript/tests/cases/compiler/ambientEnumElementInitializer1.ts_0_25
declare enum E { e = 3 }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientEnumElementInitializer1.ts" }
TypeScript/tests/cases/compiler/unclosedExportClause02.ts_0_267
// @module: commonjs // @filename: t1.ts export var x = "x"; // @filename: t2.ts export { x, from "./t1"; // @filename: t3.ts export { from "./t1"; // @filename: t4.ts export { x as a from "./t1"; // @filename: t5.ts export { x as a, from "./t1";
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unclosedExportClause02.ts" }
TypeScript/tests/cases/compiler/constEnumSyntheticNodesComments.ts_0_345
const enum En { A, B, C, D } function assert<T>(x: T) { return x; } function verify(a: En) { switch (a) { case En.A: return assert<0>(a); case En["B"]: return assert<1>(a); case En[`C`]: return assert<2>(a); case En["\u{44}"]: ret...
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumSyntheticNodesComments.ts" }
TypeScript/tests/cases/compiler/commonSourceDir4.ts_0_138
// @useCaseSensitiveFileNames: true // @outDir: A:/ // @Filename: A:/foo/bar.ts var x: number; // @Filename: a:/foo/baz.ts var y: number;
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonSourceDir4.ts" }
TypeScript/tests/cases/compiler/doubleUnderStringLiteralAssignability.ts_0_150
var shouldBeOk: '__dunder' = '__dunder'; var bad: '__dunder' = 'no_dunder'; var okok: '___thunder' = '___thunder'; var alsoOk: '_sunder' = '_sunder';
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doubleUnderStringLiteralAssignability.ts" }
TypeScript/tests/cases/compiler/nonInferrableTypePropagation2.ts_0_846
// @strict: true export interface Predicate<A> { (a: A): boolean } interface Left<E> { readonly _tag: 'Left' readonly left: E } interface Right<A> { readonly _tag: 'Right' readonly right: A } type Either<E, A> = Left<E> | Right<A>; interface Refinement<A, B extends A> { (a: A): a is B } ...
{ "end_byte": 846, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonInferrableTypePropagation2.ts" }
TypeScript/tests/cases/compiler/systemNamespaceAliasEmit.ts_0_145
// @module: system namespace ns { const value = 1; } enum AnEnum { ONE, TWO } export {ns, AnEnum, ns as FooBar, AnEnum as BarEnum};
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemNamespaceAliasEmit.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithConstructorChildren.ts_0_296
module M { export var x = 3; class c { constructor(M, p = x) { } } } module M { class d { constructor(private M, p = x) { } } } module M { class d2 { constructor() { var M = 10; var p = x; } } }
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithConstructorChildren.ts" }
TypeScript/tests/cases/compiler/subclassThisTypeAssignable02.ts_0_987
// @allowJs: true // @checkJs: true // @strict: true // @outDir: ./out // @filename: tile1.ts interface Lifecycle<Attrs, State extends Lifecycle<Attrs, State>> { oninit?(vnode: Vnode<Attrs, State>): number; [_: number]: any; } interface Vnode<Attrs, State extends Lifecycle<Attrs, State>> { tag: Component<Attrs, St...
{ "end_byte": 987, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subclassThisTypeAssignable02.ts" }
TypeScript/tests/cases/compiler/mergedModuleDeclarationCodeGen4.ts_0_382
module superContain { export module contain { export module my.buz { export module data { export function foo() { } } } export module my.buz { export module data { export function bar(contain, my, buz, data) { ...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedModuleDeclarationCodeGen4.ts" }
TypeScript/tests/cases/compiler/genericTypeUsedWithoutTypeArguments1.ts_0_53
interface Foo<T> { } class Bar<T> implements Foo { }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeUsedWithoutTypeArguments1.ts" }
TypeScript/tests/cases/compiler/inheritedConstructorPropertyContextualType.ts_0_192
interface State { version: 2 } declare class Base<S> { state: S } class Assignment extends Base<State> { constructor() { super() this.state = { version: 2 } } }
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedConstructorPropertyContextualType.ts" }
TypeScript/tests/cases/compiler/commentsOnReturnStatement1.ts_0_195
// @removeComments: false class DebugClass { public static debugFunc() { // Start Debugger Test Code var i = 0; // End Debugger Test Code return true; } }
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnReturnStatement1.ts" }
TypeScript/tests/cases/compiler/es6ModuleConst.ts_0_382
// @target: ES6 export const a = "hello"; export const x: string = a, y = x; const b = y; const c: string = b, d = c; export module m1 { export const k = a; export const l: string = b, m = k; const n = m1.k; const o: string = n, p = k; } module m2 { export const k = a; export const l: string = b...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleConst.ts" }
TypeScript/tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts_0_1687
// @strict: true const fn1 = <Params>( params: Pick<Params, Exclude<keyof Params, never>>, ): Params => params; function fn2<T>(x: Exclude<T, never>) { var y: T = x; x = y; } const fn3 = <Params>( params: Pick<Params, Extract<keyof Params, keyof Params>>, ): Params => params; function fn4<T>(x: Extra...
{ "end_byte": 1687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyIndexing.ts_3_930
@noImplicitAny: true enum MyEmusEnum { emu } // Should be okay; should be a string. var strRepresentation1 = MyEmusEnum[0] // Should be okay; should be a string. var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] // Should be implicit 'any' ; property access fails, no string indexer. var strRepresentation3 = M...
{ "end_byte": 930, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyIndexing.ts" }
TypeScript/tests/cases/compiler/functionOverloads18.ts_0_79
function foo(bar:{a:number;}); function foo(bar:{a:string;}) { return {a:""} }
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads18.ts" }