_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts_0_241
// @target: ES5 // @verbatimModuleSyntax: true function foo1() { return E.A enum E { A } } function foo2() { return E.A const enum E { A } } const config = { a: AfterObject.A, }; const enum AfterObject { A = 2, }
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts" }
TypeScript/tests/cases/compiler/mappedTypePartialConstraints.ts_0_245
// Repro from #16985 interface MyInterface { something: number; } class MyClass<T extends MyInterface> { doIt(data : Partial<T>) {} } class MySubClass extends MyClass<MyInterface> {} function fn(arg: typeof MyClass) {}; fn(MySubClass);
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypePartialConstraints.ts" }
TypeScript/tests/cases/compiler/computedEnumTypeWidening.ts_0_1605
// @strict: true // @declaration: true declare function computed(x: number): number; enum E { A = computed(0), B = computed(1), C = computed(2), D = computed(3), } function f1() { const c1 = E.B; // Fresh E.B let v1 = c1; // E const c2 = c1; // Fresh E.B let v2 = c2; // E cons...
{ "end_byte": 1605, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedEnumTypeWidening.ts" }
TypeScript/tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts_0_100
// @target: ES6 // @outFile: out.js // @Filename: file1.ts c; // @Filename: file2.ts const c = 0;
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts" }
TypeScript/tests/cases/compiler/valueOfTypedArray.ts_0_749
// @target: es2020 // All declarations should pass, as valueOf has been specialized for all TypedArrays const typedArray0: Int8Array = (new Int8Array()).valueOf(); const typedArray1: Uint8Array = (new Uint8Array()).valueOf(); const typedArray2: Int16Array = (new Int16Array()).valueOf(); const typedArray3: Uint16Array ...
{ "end_byte": 749, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/valueOfTypedArray.ts" }
TypeScript/tests/cases/compiler/implicitAnyDeclareMemberWithoutType2.ts_0_257
// @noimplicitany: true // this should be an error class C { public x = null;// error at "x" public x1: string // no error constructor(c1, c2, c3: string) { } // error at "c1, c2" funcOfC(f1, f2, f3: number) { } // error at "f1,f2" }
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyDeclareMemberWithoutType2.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInstantiation1.ts_0_474
declare function map<S, T>(f: (x: S) => T): (a: S[]) => T[]; var e = <K>(x: string, y?: K) => x.length; var r99 = map(e); // should be {}[] for S since a generic lambda is not inferentially typed declare function map2<S extends { length: number }, T>(f: (x: S) => T): (a: S[]) => T[]; var e2 = <K>(x: string, y?: K) => ...
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInstantiation1.ts" }
TypeScript/tests/cases/compiler/addMoreOverloadsToBaseSignature.ts_0_94
interface Foo { f(): string; } interface Bar extends Foo { f(key: string): string; }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/addMoreOverloadsToBaseSignature.ts" }
TypeScript/tests/cases/compiler/baseTypePrivateMemberClash.ts_0_99
class X { private m: number; } class Y { private m: string; } interface Z extends X, Y { }
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseTypePrivateMemberClash.ts" }
TypeScript/tests/cases/compiler/checkDestructuringShorthandAssigment2.ts_0_123
// @noEmit: true // GH #38175 -- should not crash while checking let o: any, k: any; let { x } = { x: 1, ...o, [k]: 1 };
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkDestructuringShorthandAssigment2.ts" }
TypeScript/tests/cases/compiler/narrowingPastLastAssignmentInModule.ts_0_605
// @strict: true // @noEmit: true // @target: esnext function action(f: Function) {} // Narrowings are not preserved for exported mutable variables export let x1: string | number; x1 = "abc"; action(() => { x1 /* string | number */ }); export { x2 }; let x2: string | number; x2 = "abc"; action(() => { x2 /* string ...
{ "end_byte": 605, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingPastLastAssignmentInModule.ts" }
TypeScript/tests/cases/compiler/verbatim-declarations-parameters.ts_0_687
// @strictNullChecks: true // @declaration: true type Map = {} & { [P in string]: any } type MapOrUndefined = Map | undefined | "dummy" export class Foo { constructor( // Type node is accurate, preserve public reuseTypeNode?: Map | undefined, public reuseTypeNode2?: Exclude<MapOrUndefined, "dummy">, ...
{ "end_byte": 687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/verbatim-declarations-parameters.ts" }
TypeScript/tests/cases/compiler/checkInfiniteExpansionTermination.ts_0_335
// Regression test for #1002 // Before fix this code would cause infinite loop interface IObservable<T> { n: IObservable<T[]>; // Needed, must be T[] } // Needed interface ISubject<T> extends IObservable<T> { } interface Foo { x } interface Bar { y } var values: IObservable<Foo>; var values2: ISubject<Bar>; val...
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkInfiniteExpansionTermination.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends5.ts_0_261
// @declaration: true namespace Test { export interface IFace { } export class SomeClass implements IFace { } export class Derived extends getClass<IFace>() { } export function getClass<T>() : new() => T { return SomeClass as (new() => T); } }
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends5.ts" }
TypeScript/tests/cases/compiler/typeParameterOrderReversal.ts_0_255
interface X<T> { n: T; } // Only difference here is order of type parameters function uFirst<U extends X<T>, T>(x: U) { } function tFirst<T, U extends X<T>>(x: U) { } var z: X<number> = null; // Both of these should be allowed uFirst(z); tFirst(z);
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterOrderReversal.ts" }
TypeScript/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix4.ts_0_797
// @strict: true // @noEmit: true declare function test1( arg: { a: (arg: number) => void } & { [k: string]: (arg: any) => void }, ): unknown; test1({ a: (arg) => {}, b: (arg) => {}, }); declare function test2( arg: { a: (arg: { foo: string }) => void } & { [k: string]: (arg: { foo: any }) => void; }, ...
{ "end_byte": 797, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix4.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationExportAssignment.ts_0_72
//@module: amd // @sourcemap: true class a { public c; } export = a;
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationExportAssignment.ts" }
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations4.ts_0_94
// @target: es6 // @module: amd let { toString } = 1; { let { toFixed } = 1; } export {};
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations4.ts" }
TypeScript/tests/cases/compiler/contextualTyping33.ts_0_116
function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){return 1;}, function(){return "foo"}]);
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping33.ts" }
TypeScript/tests/cases/compiler/systemModuleDeclarationMerging.ts_0_186
// @module: system // @isolatedModules: true export function F() {} export module F { var x; } export class C {} export module C { var x; } export enum E {} export module E { var x; }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleDeclarationMerging.ts" }
TypeScript/tests/cases/compiler/unusedPrivateVariableInClass5.ts_0_180
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { private x: string; private y: string; public z: string; constructor() { this.x; } }
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateVariableInClass5.ts" }
TypeScript/tests/cases/compiler/classMemberInitializerWithLamdaScoping3.ts_0_610
// @Filename: classMemberInitializerWithLamdaScoping3_0.ts var field1: string; // @Filename: classMemberInitializerWithLamdaScoping3_1.ts declare var console: { log(msg?: any): void; }; export class Test1 { constructor(private field1: string) { } messageHandler = () => { console.log(field1); //...
{ "end_byte": 610, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberInitializerWithLamdaScoping3.ts" }
TypeScript/tests/cases/compiler/implicitAnyDeclareFunctionWithoutFormalType.ts_0_415
// @noimplicitany: true // these should be errors function foo(x) { }; function bar(x: number, y) { }; // error at "y"; no error at "x" function func2(a, b, c) { }; // error at "a,b,c" function func3(...args) { }; // error at "args" function func4(z= null, w= undefined) { }; // error at "z,w" // these shoul...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyDeclareFunctionWithoutFormalType.ts" }
TypeScript/tests/cases/compiler/reservedNameOnModuleImportWithInterface.ts_0_213
declare module test { interface mi_string { } module mi_string { } // Should error; imports both a type and a module, which means it conflicts with the 'string' type. import string = mi_string; }
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reservedNameOnModuleImportWithInterface.ts" }
TypeScript/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter.ts_0_109
function foo<T extends U, U>(y: T, z: U) { return y; } module foo { export var x: T; var y = <T>1; }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter.ts" }
TypeScript/tests/cases/compiler/declarationEmitPreserveReferencedImports.ts_0_315
// @declaration: true // @strict: true // @filename: utils.ts export interface Evt { } // @filename: decl.ts import {Evt} from './utils' export const o = <T>(o: T) => () : T => null! // @filename: main.ts import { o } from './decl' import { Evt } from './utils' export const f = { o: o({ v: null! as Evt}) };
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPreserveReferencedImports.ts" }
TypeScript/tests/cases/compiler/declarationEmitUsingAlternativeContainingModules2.ts_0_5534
// @strict: true // @declaration: true // @module: nodenext // @moduleResolution: nodenext // @target: esnext // @filename: node_modules/@tanstack/vue-query/build/modern/useQuery-CPqkvEsh.d.ts type QueryKey = ReadonlyArray<unknown>; interface Register {} type DefaultError = Register extends { defaultError: infer T...
{ "end_byte": 5534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitUsingAlternativeContainingModules2.ts" }
TypeScript/tests/cases/compiler/recursiveBaseCheck4.ts_0_46
class M<T> extends M<string> { } (new M).blah;
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveBaseCheck4.ts" }
TypeScript/tests/cases/compiler/destructureOptionalParameter.ts_0_584
// @strictNullChecks: true // @declaration: true declare function f1({ a, b }?: { a: number, b: string }): void; function f2({ a, b }: { a: number, b: number } = { a: 0, b: 0 }) { a; b; } // Repro from #8681 interface Type { t: void } interface QueryMetadata { q: void } interface QueryMetadataFactory { ...
{ "end_byte": 584, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructureOptionalParameter.ts" }
TypeScript/tests/cases/compiler/esmNoSynthesizedDefault.ts_0_454
// @target: esnext // @module: preserve, esnext // @moduleResolution: bundler // @Filename: /node_modules/mdast-util-to-string/package.json { "type": "module" } // @Filename: /node_modules/mdast-util-to-string/index.d.ts export function toString(): string; // @Filename: /index.ts import mdast, { toString } from 'mda...
{ "end_byte": 454, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esmNoSynthesizedDefault.ts" }
TypeScript/tests/cases/compiler/declFileMethods.ts_0_5817
// @target: ES5 // @declaration: true // @removeComments: false // @module: commonjs // @Filename: declFileMethods_0.ts export class c1 { /** This comment should appear for foo*/ public foo() { } /** This is comment for function signature*/ public fooWithParameters(/** this is comment about a*/a: s...
{ "end_byte": 5817, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileMethods.ts" }
TypeScript/tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts_0_587
interface IProps { iconProp?: string; nestedProp?: { testBool?: boolean; } } interface INestedProps { nestedProps?: IProps; } // These are the types of errors we want: const propB1: IProps | number = { INVALID_PROP_NAME: 'share', iconProp: 'test' }; // Nested typing works here and we also get...
{ "end_byte": 587, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts" }
TypeScript/tests/cases/compiler/commentOnStaticMember1.ts_0_59
class Greeter { //Hello World static foo(){ } }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnStaticMember1.ts" }
TypeScript/tests/cases/compiler/ambientClassOverloadForFunction.ts_0_53
declare class foo{}; function foo() { return null; }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientClassOverloadForFunction.ts" }
TypeScript/tests/cases/compiler/relatedViaDiscriminatedTypeNoError2.ts_0_236
// @strict: true type AObjOrBObj = { name: "A" } | { name: "B" }; type AOrBObj = { name: "A" | "B" }; type Generic<T extends AObjOrBObj> = T; type T = Generic<AOrBObj>; declare let x: AObjOrBObj; declare let y: AOrBObj; x = y; y = x;
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/relatedViaDiscriminatedTypeNoError2.ts" }
TypeScript/tests/cases/compiler/shebang.ts_0_80
#!/usr/bin/env node var foo = 'I wish the generated JS to be executed in node';
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shebang.ts" }
TypeScript/tests/cases/compiler/classdecl.ts_0_1485
// @declaration: true // @target: es5 class a { //constructor (); constructor (n: number); constructor (s: string); constructor (ns: any) { } public pgF() { } public pv; public get d() { return 30; } public set d(a: number) { } public static get p2() { ...
{ "end_byte": 1485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classdecl.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExport6.ts_0_80
// @declaration: true // @target: es6 export class A {} export default new A();
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExport6.ts" }
TypeScript/tests/cases/compiler/whileStatementInnerComments.ts_0_108
/*a*/ while /*b*/ ( /*c*/ false /*d*/ ) /*e*/ {} /*a*/ do /*b*/ {} /*c*/ while /*d*/ ( /*e*/ true /*f*/ );
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/whileStatementInnerComments.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts_0_324
// 3.8.4 Assignment Compatibility interface Callable { call(blah: any); // also works for 'apply' } var x: Callable; // Should fail x = ''; x = ['']; x = 4; x = {}; // Should work function f() { }; x = f; function fn(c: Callable) { } // Should Fail fn(''); fn(['']); fn(4); fn({}); // Should work fn(a => { ...
{ "end_byte": 324, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructor.ts_0_82
// @sourcemap: true class Greeter { public a = 10; public nameA = "Ten"; }
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructor.ts" }
TypeScript/tests/cases/compiler/unresolvedTypeAssertionSymbol.ts_0_30
var x = 1; var y = <asdf>x;
{ "end_byte": 30, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unresolvedTypeAssertionSymbol.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts_3_56
@declaration: true type A<T extends Unknown> = {}
{ "end_byte": 56, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsVisibility1.ts_0_4534
// @strict: true // @target: esnext class Base { get PublicPublic() { return 0; } set PublicPublic(v) { return; } get PublicProtected() { return 0; } protected set PublicProtected(v) { return; } get PublicPrivate() { return 0; } private set PublicPrivate(v) { return; } protected get Prot...
{ "end_byte": 4534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsVisibility1.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts_0_235
//@noUnusedLocals:true //@noUnusedParameters:true function greeter(person: string, person2: string) { var unused = 20; var maker = function (child: string): void { var unused2 = 22; } person2 = "dummy value"; }
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts" }
TypeScript/tests/cases/compiler/augmentedTypesModules2.ts_0_660
// module then function module m2 { } function m2() { }; // ok since the module is not instantiated module m2a { var y = 2; } function m2a() { }; // error since the module is instantiated module m2b { export var y = 2; } function m2b() { }; // error since the module is instantiated function m2c() { }; module m2c {...
{ "end_byte": 660, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesModules2.ts" }
TypeScript/tests/cases/compiler/functionType.ts_0_78
function salt() {} salt.apply("hello", []); (new Function("return 5"))();
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionType.ts" }
TypeScript/tests/cases/compiler/assignmentToParenthesizedExpression1.ts_0_16
var x; (1, x)=0;
{ "end_byte": 16, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToParenthesizedExpression1.ts" }
TypeScript/tests/cases/compiler/coAndContraVariantInferences5.ts_0_503
// @strict: true // @noEmit: true type Thing = 'a' | 'b'; function f( options: SelectOptions<Thing>, onChange: (status: Thing | null) => void, ): void { select({ options, onChange, }); } declare function select<KeyT extends string>(props: SelectProps<KeyT>): void; type SelectProps<Ke...
{ "end_byte": 503, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/coAndContraVariantInferences5.ts" }
TypeScript/tests/cases/compiler/unionSignaturesWithThisParameter.ts_0_186
// @strict: true // Repro from #20802 function x<T>(ctor: { (this: {}, v: T): void; new(v: T): void; } | { (v: T): void; new(v: T): void; }, t: T) { new ctor(t); }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionSignaturesWithThisParameter.ts" }
TypeScript/tests/cases/compiler/booleanLiteralsContextuallyTypedFromUnion.tsx_0_928
// @strict: true // @jsx: preserve // @skipLibCheck: true // @libFiles: lib.d.ts,react.d.ts interface A { isIt: true; text: string; } interface B { isIt: false; value: number; } type C = A | B; const isIt = Math.random() > 0.5; const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; const cc: C = isIt ? { isI...
{ "end_byte": 928, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/booleanLiteralsContextuallyTypedFromUnion.tsx" }
TypeScript/tests/cases/compiler/objectLiteral1.ts_0_21
var v30 = {a:1, b:2};
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteral1.ts" }
TypeScript/tests/cases/compiler/moduleAliasInterface.ts_0_963
module _modes { export interface IMode { } export class Mode { } } // _modes. // produces an internal error - please implement in derived class module editor { import modes = _modes; var i : modes.IMode; // If you just use p1:modes, the compiler accepts it - should be an error class Bug { cons...
{ "end_byte": 963, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAliasInterface.ts" }
TypeScript/tests/cases/compiler/comparableRelationBidirectional.ts_0_587
// @strict: true // @noEmit: true enum AutomationMode { NONE = "", TIME = "time", SYSTEM = "system", LOCATION = "location", } interface ThemePreset { id: string; } interface Automation { mode: AutomationMode; } interface UserSettings { presets: ThemePreset[]; automation: Automation; ...
{ "end_byte": 587, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/comparableRelationBidirectional.ts" }
TypeScript/tests/cases/compiler/specializedSignatureInInterface.ts_0_107
interface A { (key:string):void; } interface B extends A { (key:'foo'):string; (key:'bar'):string; }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializedSignatureInInterface.ts" }
TypeScript/tests/cases/compiler/mixingApparentTypeOverrides.ts_0_485
type Constructor<T> = new(...args: any[]) => T; function Tagged<T extends Constructor<{}>>(Base: T) { return class extends Base { _tag: string; constructor(...args: any[]) { super(...args); this._tag = ""; } }; } class A { toString () { return "class A"; } } class B extends Tagged(...
{ "end_byte": 485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixingApparentTypeOverrides.ts" }
TypeScript/tests/cases/compiler/duplicatePackage_globalMerge.ts_0_624
// @noImplicitReferences: true // @Filename: /src/index.ts import * as React from 'react'; export var x = 1 // @Filename: /tests/index.ts import * as React from 'react'; export var y = 2 // @Filename: /tests/node_modules/@types/react/package.json { "name": "@types/react", "version": "16.4.6" } // @Filename: /tests/no...
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage_globalMerge.ts" }
TypeScript/tests/cases/compiler/implicitAnyGenericTypeInference.ts_0_862
// @noimplicitany: true // @target: esnext interface Comparer<T> { compareTo<U>(x: T, y: U): U; } var c: Comparer<any>; c = { compareTo: (x, y) => { return y; } }; var r = c.compareTo(1, ''); declare function f1<T>(cb: () => T): void; f1(() => null); declare function f2<T>(cb: () => PromiseLike<T>): void; f2(as...
{ "end_byte": 862, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyGenericTypeInference.ts" }
TypeScript/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts_0_49
function f(...args: any[]) { } f `\t\n\v\f\r\\`;
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts_0_260
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @target: ESNext export function foo() {} foo.apply = () => {} foo.call = ()=> {} foo.bind = ()=> {} foo.caller = ()=> {} foo.toString = ()=> {} foo.length = 10 foo.length = 10
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts" }
TypeScript/tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts_0_72
module Alpha { export var x = 100; } class Beta extends Alpha.x { }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts" }
TypeScript/tests/cases/compiler/exportDefaultProperty2.ts_0_268
// This test is just like exportEqualsProperty2, but with `export default`. // @Filename: a.ts class C { static B: number; } namespace C { export interface B { c: number } } export default C.B; // @Filename: b.ts import B from "./a"; const x: B = { c: B };
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultProperty2.ts" }
TypeScript/tests/cases/compiler/deeplyDependentLargeArrayMutation.ts_0_931
// @allowJs: true // @checkJs: true // @noEmit: true // @target: es6 // @filename: foo.js // repro from #26031 function build() { var arr = []; arr[arr.length] = 'value'; arr[arr.length] = 'value'; arr[arr.length] = 'value'; arr[arr.length] = 'value'; arr[arr.length] = 'value'; arr[arr.le...
{ "end_byte": 931, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deeplyDependentLargeArrayMutation.ts" }
TypeScript/tests/cases/compiler/tsxNoTypeAnnotatedSFC.tsx_0_229
// @jsx: preserve // not _actually_ making react available in this test to regression test #22948 import * as React from 'react'; const Test123 = () => <div/>; function testComponent(props) { return <Test123 {...props}/>; }
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxNoTypeAnnotatedSFC.tsx" }
TypeScript/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts_0_476
function f1() { for (let [x, y] = [1, 2]; x < y; ++x, --y) { let a = () => x++ + y++; if (x == 1) break; else if (y == 2) y = 5; else return; } } function f2() { for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { ...
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts" }
TypeScript/tests/cases/compiler/unusedMethodsInInterface.ts_0_107
//@noUnusedLocals:true //@noUnusedParameters:true interface I1 { f1(); f2(x: number, y: string); }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedMethodsInInterface.ts" }
TypeScript/tests/cases/compiler/ambientNameRestrictions.ts_0_59
export declare namespace Foo { export var static: any; }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientNameRestrictions.ts" }
TypeScript/tests/cases/compiler/incrementalConfig.ts_0_92
// @incremental: true // @Filename: /a.ts const x = 10; // @Filename: /tsconfig.json { }
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incrementalConfig.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationParenType.ts_0_220
// @target: ES5 // @declaration: true class c { private p: string; } var x: (() => c)[] = [() => new c()]; var y = [() => new c()]; var k: (() => c) | string = (() => new c()) || ""; var l = (() => new c()) || "";
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationParenType.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.ts_0_2911
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } interface Robot { name: string; skill: string; } interface MultiRobot { name: string; skills: { primary?: string; secondary?: string; }; } let robots: Robot[] = [{ name: "mower", skill: "mowing" }, {...
{ "end_byte": 2911, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts_0_180
// @declaration: true // @filename: a.ts interface I {} export function f(): I { return null as I; } // @filename: b.ts import {f} from "./a"; export function q() {} q.val = f();
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts" }
TypeScript/tests/cases/compiler/functionOverloads27.ts_0_112
function foo():string; function foo(bar:string):number; function foo(bar?:any):any{ return '' } var x = foo(5);
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads27.ts" }
TypeScript/tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts_0_60
// @sourceRoot: local // @inlineSourceMap: true var a = 10;
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts" }
TypeScript/tests/cases/compiler/dynamicModuleTypecheckError.ts_0_125
//@module: commonjs export var x = 1; for(var i = 0; i < 30; i++) { x = i * 1000; // should not be an error here }
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicModuleTypecheckError.ts" }
TypeScript/tests/cases/compiler/super.ts_0_488
class Base { constructor() { var x; } public foo() { return "base"; } public bar() { return "basebar"; } } class Sub1 extends Base { public foo() { return "sub1" + super.foo() + super.bar(); } } class SubSub1 extends Sub1 { public foo() { r...
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/super.ts" }
TypeScript/tests/cases/compiler/compilerOptionsOutDirAndNoEmit.ts_0_68
// @outDir: outDir // @noEmit: true // @fileName: a.ts class c { }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/compilerOptionsOutDirAndNoEmit.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationVariables.ts_0_73
// @sourcemap: true var a = 10; var b; var c = 10, d, e; var c2, d2 = 10;
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationVariables.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts_0_317
//@noUnusedLocals:true //@noUnusedParameters:true var greeter = function (person: string, person2: string) { var unused = 20; var maker = function (child: string): void { var unused2 = 22; } var maker2 = function (child2: string): void { var unused3 = 23; } maker2(person2); }
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts" }
TypeScript/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts_0_283
// Repro from #13346 interface Chainable<T> { value(): T; mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; } declare function chain<T>(t: T): Chainable<T>; const square = (x: number) => x * x; const v = chain({a: 1, b: 2}).mapValues(square).value();
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts" }
TypeScript/tests/cases/compiler/noStrictGenericChecks.ts_0_189
// @noStrictGenericChecks: true type A = <T, U>(x: T, y: U) => [T, U]; type B = <S>(x: S, y: S) => [S, S]; function f(a: A, b: B) { a = b; // Error disabled here b = a; // Ok }
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noStrictGenericChecks.ts" }
TypeScript/tests/cases/compiler/missingImportAfterModuleImport.ts_0_585
//@module: commonjs // @declaration: true // @Filename: missingImportAfterModuleImport_0.ts declare module "SubModule" { class SubModule { public static StaticVar: number; public InstanceVar: number; constructor(); } export = SubModule; } // @Filename: missingImportAfterModuleImpor...
{ "end_byte": 585, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingImportAfterModuleImport.ts" }
TypeScript/tests/cases/compiler/restUnion2.ts_0_249
// @strictNullChecks: true declare const undefinedUnion: { n: number } | undefined; var rest2: { n: number }; var {...rest2 } = undefinedUnion; declare const nullUnion: { n: number } | null; var rest3: { n: number }; var {...rest3 } = nullUnion;
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restUnion2.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters2.ts_3_189
@declaration: true export type Bar<X, Y, Z> = () => [X, Y, Z]; export type Baz<M, N> = Bar<M, string, N>; export type Baa<Y> = Baz<boolean, Y>; export const y = (x: Baa<number>) => 1
{ "end_byte": 189, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters2.ts" }
TypeScript/tests/cases/compiler/typeArgumentInferenceApparentType2.ts_0_177
//@target: ES6 function method<T>(iterable: Iterable<T>): T { function inner<U extends Iterable<T>>() { var u: U; var res: T = method(u); } return; }
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentInferenceApparentType2.ts" }
TypeScript/tests/cases/compiler/isolatedModulesAmbientConstEnum.ts_0_117
// @isolatedModules: true // @target: es6 // @filename: file1.ts declare const enum E { X = 1} export var y = E.X;
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesAmbientConstEnum.ts" }
TypeScript/tests/cases/compiler/forInStatement5.ts_0_49
var a: string; var expr: any; for (a in expr) { }
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement5.ts" }
TypeScript/tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.ts_0_854
// @lib: es2015 // @strict: true // @noImplicitAny: false // @allowJs: true // @checkJs: true // @noEmit: true // @fileName: jsdocArrayObjectPromiseImplicitAny.js /** @type {Array} */ var anyArray = [5]; /** @type {Array<number>} */ var numberArray = [5]; /** * @param {Array} arr * @return {Array} */ function ret...
{ "end_byte": 854, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.ts" }
TypeScript/tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts_0_444
// @isolatedModules: true,false // @noTypesAndSymbols: true // @target: esnext // @filename: ./foo.ts import { BAR } from './bar'; const LOCAL = 'LOCAL'; enum Foo { A = `${BAR}`, B = LOCAL, C = B, D = C + 'BAR', E1 = (`${BAR}`) as string, // We could recognize these, E2 = `${BAR}`!, // but B...
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts" }
TypeScript/tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts_0_83
interface Foo<T> { new (x: number): Foo<T>; } var f2: Foo<number> = new Foo(3);
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts" }
TypeScript/tests/cases/compiler/constEnumNoEmitReexport.ts_0_766
// @filename: ConstEnum.ts export const enum MyConstEnum { Foo, Bar }; // @filename: ImportExport.ts import { MyConstEnum } from './ConstEnum'; export { MyConstEnum }; // @filename: ImportExportDefault.ts import { MyConstEnum } from './ConstEnum'; export default MyConstEnum; // @filename: ReExportDefault.ts exp...
{ "end_byte": 766, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumNoEmitReexport.ts" }
TypeScript/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts_0_336
var obj1: {}; obj1.length; var obj2: Object; obj2.length; function concat<T>(x: T, y: T): T { return null; } var result = concat(1, ""); // error var elementCount = result.length; function concat2<T, U>(x: T, y: U) { return null; } var result2 = concat2(1, ""); // result2 will be number|string var elementCount2 = r...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts" }
TypeScript/tests/cases/compiler/specializationsShouldNotAffectEachOther.ts_1_282
interface Series { data: string[]; } var series: Series; function foo() { var seriesExtent = (series) => null; var series2: number[]; series2.map(seriesExtent); return null; } var keyExtent2: any[] = series.data.map(function (d: string) { return d; });
{ "end_byte": 282, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializationsShouldNotAffectEachOther.ts" }
TypeScript/tests/cases/compiler/assignmentCompat1.ts_0_306
var x = { one: 1 }; var y: { [index: string]: any }; var z: { [index: number]: any }; x = y; // Error y = x; // Ok because index signature type is any x = z; // Error z = x; // Ok because index signature type is any y = "foo"; // Error z = "foo"; // OK, string has numeric indexer z = false; // Error
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompat1.ts" }
TypeScript/tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts_0_29
var test: any[] = new any[1];
{ "end_byte": 29, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts" }
TypeScript/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx_0_274
// @jsx: react // @strict: true /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; declare const Tag: keyof React.ReactHTML; const classes = ""; const rest: {} = {}; const children: any[] = []; <Tag className={classes} {...rest}> {children} </Tag>
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx" }
TypeScript/tests/cases/compiler/ignoredJsxAttributes.tsx_0_428
// @strict: true // @jsx: react /// <reference path="/.lib/react16.d.ts" /> // Repro from #44797 import * as React from "react"; interface Props { foo: string; [dataProp: string]: string; } declare function Yadda(props: Props): JSX.Element; let props: Props = { foo: "", "data-yadda": 42, // Error ...
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ignoredJsxAttributes.tsx" }
TypeScript/tests/cases/compiler/systemModule10_ES5.ts_0_203
// @target: es5 // @module: system // @isolatedModules: true import n, {x} from 'file1' import n2 = require('file2'); export {x} export {x as y} export {n} export {n as n1} export {n2} export {n2 as n3}
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule10_ES5.ts" }
TypeScript/tests/cases/compiler/errorMessagesIntersectionTypes04.ts_0_313
interface A { a; } interface B { b; } function f<T, U extends A, V extends U>(): void { let num: number; let bool: boolean; let str: string; let a_and_b: A & B; let num_and_bool: number & boolean; num = a_and_b; bool = a_and_b; str = a_and_b; str = num_and_bool; }
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorMessagesIntersectionTypes04.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts_3_77
@sourcemap: true var {x} = { x: 20 }; var { a, b } = { a: 30, b: 40 };
{ "end_byte": 77, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedJsxChildren.tsx_0_1083
// @strict: true // @jsx: react // @esModuleInterop: true // @noEmit: true /// <reference path="/.lib/react16.d.ts" /> import React from 'react'; // repro from https://github.com/microsoft/TypeScript/issues/53941 declare namespace DropdownMenu { interface BaseProps { icon: string; label: string; } inte...
{ "end_byte": 1083, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedJsxChildren.tsx" }