_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/convertKeywords.ts_0_16
var abstract;
{ "end_byte": 16, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/convertKeywords.ts" }
TypeScript/tests/cases/compiler/wideningWithTopLevelTypeParameter.ts_0_1057
// @strict: true // @noEmit: true type C1<T> = T extends unknown ? T | undefined : never; type C2<T> = T extends unknown ? T | undefined : never; type C3<T> = T extends unknown ? T | undefined : never; type C4<T> = T extends unknown ? T | undefined : never; declare function f0<T>(x: T): [T]; declare function f1<T>(x:...
{ "end_byte": 1057, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/wideningWithTopLevelTypeParameter.ts" }
TypeScript/tests/cases/compiler/declFileWithInternalModuleNameConflictsInExtendsClause3.ts_0_241
// @declaration: true module X.A.C { export interface Z { } } module X.A.B.C { export class W implements X.A.C.Z { // This needs to be referred as X.A.C.Z as A has conflict } } module X.A.B.C { export module A { } }
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileWithInternalModuleNameConflictsInExtendsClause3.ts" }
TypeScript/tests/cases/compiler/promiseTypeStrictNull.ts_0_6552
// @target: es6 // @strictNullChecks: true declare var p: Promise<boolean>; declare var x: any; async function A() { const a = await p; return a; } async function B() { const a = await p; return 1; } async function C() { try { const a = await p; return 1; } catch (e) { ...
{ "end_byte": 6552, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseTypeStrictNull.ts" }
TypeScript/tests/cases/compiler/promiseTypeStrictNull.ts_6553_6818
const pc6 = p.then(() => Promise.reject("1"), () => {}); const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
{ "end_byte": 6818, "start_byte": 6553, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseTypeStrictNull.ts" }
TypeScript/tests/cases/compiler/implementsClauseAlreadySeen.ts_0_68
class C { } class D implements C implements C { baz() { } }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implementsClauseAlreadySeen.ts" }
TypeScript/tests/cases/compiler/taggedTemplatesInModuleAndGlobal.ts_0_489
// @module: commonjs // @target: es5 // @filename: global.ts namespace n { function id<T>(x: T): T { return x; } function templateObjectFactory() { return id`hello world`; } let result = templateObjectFactory() === templateObjectFactory(); } // @filename: module.ts export { } funct...
{ "end_byte": 489, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesInModuleAndGlobal.ts" }
TypeScript/tests/cases/compiler/generatorES6InAMDModule.ts_0_68
// @target: es6 // @module: amd export function* foo() { yield }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6InAMDModule.ts" }
TypeScript/tests/cases/compiler/uniqueSymbolJs.ts_0_228
// @target: esnext // @checkJs: true // @allowJs: true // @noEmit: true // @filename: ./a.js /** @type {unique symbol} */ const foo = Symbol(); /** @typedef {{ [foo]: boolean }} A */ /** @typedef {{ [key: foo] boolean }} B */
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/uniqueSymbolJs.ts" }
TypeScript/tests/cases/compiler/duplicateLabel3.ts_0_111
// @allowUnusedLabels: true target: while (true) { function f() { target: while (true) { } } }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateLabel3.ts" }
TypeScript/tests/cases/compiler/doubleUnderscoreLabels.ts_0_265
function doThing() { __call: while (true) { aLabel: for (let i = 0; i < 10; i++) { if (i === 3) { break __call; } if (i === 5) { break aLabel; } } } } doThing();
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doubleUnderscoreLabels.ts" }
TypeScript/tests/cases/compiler/breakInIterationOrSwitchStatement4.ts_0_37
for (var i in something) { break; }
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakInIterationOrSwitchStatement4.ts" }
TypeScript/tests/cases/compiler/substitutionTypePassedToExtends.ts_0_252
// @strict: true // @target: esnext type Foo1<A,B> = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' type Bar1<T extends unknown[][]> = T type Foo2<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : 'else' type Bar2<T extends Set<unknown[]>> = T
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/substitutionTypePassedToExtends.ts" }
TypeScript/tests/cases/compiler/selfInLambdas.ts_0_611
// @lib: es5 // @noImplicitAny: true // @noImplicitThis: true interface MouseEvent { x: number; y: number; } declare var window: Window; interface Window { onmousemove: (ev: MouseEvent) => any; } var o = { counter: 0, start: function() { window.onmousemove = () => { thi...
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfInLambdas.ts" }
TypeScript/tests/cases/compiler/defaultValueInConstructorOverload1.ts_0_68
class C { constructor(x = ''); constructor(x = '') { } }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultValueInConstructorOverload1.ts" }
TypeScript/tests/cases/compiler/nodeResolution3.ts_0_155
// @module: commonjs // @moduleResolution: node // @filename: node_modules/b/index.d.ts export var x: number; // @filename: a.ts import y = require("b");
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution3.ts" }
TypeScript/tests/cases/compiler/jsFileClassSelfReferencedProperty.ts_0_178
// @allowJs: true // @noEmit: true // @filename: foo.js export class StackOverflowTest { constructor () { this.testStackOverflow = this.testStackOverflow.bind(this) } }
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileClassSelfReferencedProperty.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFile.ts_0_320
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import b1 = require('./b.json'); let x = b1.a; import b2 = require('./b.json'); if (x) { let b = b2.b; x = (b1.b === b); } // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFile.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationEmitBlockedCorrectly.ts_0_146
// @allowJs: true // @filename: a.ts class c { } // @filename: b.ts // this should be emitted class d { } // @filename: a.js function foo() { }
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationEmitBlockedCorrectly.ts" }
TypeScript/tests/cases/compiler/selfReferencingFile2.ts_0_82
///<reference path='../selfReferencingFile2.ts'/> class selfReferencingFile2 { }
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReferencingFile2.ts" }
TypeScript/tests/cases/compiler/duplicatePackage_referenceTypes.ts_0_616
// @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts /// <reference types="foo" /> import { Foo } from "foo"; export const foo: Foo; // @Filename: /node_modules/a/node_modules/foo/index.d.ts export class Foo { private x; } // @Filename: /node_modules/a/node_modules/foo/package.json { "name": "foo"...
{ "end_byte": 616, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage_referenceTypes.ts" }
TypeScript/tests/cases/compiler/unusedImports_entireImportDeclaration.ts_0_322
// @noUnusedLocals: true // @Filename: /a.ts export const a = 0; export const b = 0; export default 0; // @Filename: /b.ts import d1, { a as a1, b as b1 } from "./a"; import d2, * as ns from "./a"; import d3, { a as a2, b as b2 } from "./a"; d3; import d4, * as ns2 from "./a"; d4; import d5, * as ns3 from "./a"; ns3...
{ "end_byte": 322, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports_entireImportDeclaration.ts" }
TypeScript/tests/cases/compiler/collisionRestParameterInType.ts_0_359
var v1: (_i: number, ...restParameters) => void; // no error - no code gen var v2: { (_i: number, ...restParameters); // no error - no code gen new (_i: number, ...restParameters); // no error - no code gen foo(_i: number, ...restParameters); // no error - no code gen prop: (_i: number, ...restParameter...
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionRestParameterInType.ts" }
TypeScript/tests/cases/compiler/memberVariableDeclarations1.ts_0_520
// from spec class Employee { public name: string; public address: string; public retired = false; public manager: Employee = null; public reports: Employee[] = []; } class Employee2 { public name: string; public address: string; public retired: boolean; public manager: Employee; ...
{ "end_byte": 520, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/memberVariableDeclarations1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationFunctions.ts_0_344
// @sourcemap: true var greetings = 0; function greet(greeting: string): number { greetings++; return greetings; } function greet2(greeting: string, n = 10, x?: string, ...restParams: string[]): number { greetings++; return greetings; } function foo(greeting: string, n = 10, x?: string, ...restParams: s...
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationFunctions.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredTypeAlias4.ts_3_117
@declaration: true function f<A>() { type Foo<T> = T | { x: Foo<T> }; var x: Foo<A[]>; return x; }
{ "end_byte": 117, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredTypeAlias4.ts" }
TypeScript/tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts_0_110
// @target: ES5 // @module: amd if (true) { function foo() { } foo(); // ok } export = foo; // not ok
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts" }
TypeScript/tests/cases/compiler/aliasUsageInObjectLiteral.ts_0_768
// @module: commonjs // @Filename: aliasUsageInObjectLiteral_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInObjectLiteral_moduleA.ts import Backbone = require("./aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { // interesting ...
{ "end_byte": 768, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInObjectLiteral.ts" }
TypeScript/tests/cases/compiler/arrayToLocaleStringES2020.ts_0_3412
// @target: es2020 let str: string; const arr = [1, 2, 3]; str = arr.toLocaleString(); // OK str = arr.toLocaleString('en-US'); // OK str = arr.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // OK const dates: readonly Date[] = [new Date(), new Date()]; str = dates.toLocaleString(); // OK str = date...
{ "end_byte": 3412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayToLocaleStringES2020.ts" }
TypeScript/tests/cases/compiler/jsDeclarationEmitDoesNotRenameImport.ts_0_656
// @allowJs: true // @declaration: true // @emitDeclarationOnly: true // @strict: false // @strictNullChecks: true // @filename: test/Test.js /** @module test/Test */ class Test {} export default Test; // @filename: Test.js /** @module Test */ class Test {} export default Test; // @filename: index.js import Test from '...
{ "end_byte": 656, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationEmitDoesNotRenameImport.ts" }
TypeScript/tests/cases/compiler/commonSourceDirectory.ts_0_733
// Test that importing a file from `node_modules` does not affect calculation of the common source directory. // @noImplicitReferences: true // @moduleResolution: node // @fullEmitPaths: true // @filename: /node_modules/foo/index.ts export const x = 0; // @filename: /types/bar.d.ts declare module "bar" { export c...
{ "end_byte": 733, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonSourceDirectory.ts" }
TypeScript/tests/cases/compiler/numericMethodName1.ts_0_21
class C { 1 = 2; }
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericMethodName1.ts" }
TypeScript/tests/cases/compiler/genericClassImplementingGenericInterfaceFromAnotherModule.ts_0_136
// @declaration: true module foo { export interface IFoo<T> { } } module bar { export class Foo<T> implements foo.IFoo<T> { } }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassImplementingGenericInterfaceFromAnotherModule.ts" }
TypeScript/tests/cases/compiler/importHelpers.ts_0_1240
// @importHelpers: true // @target: es5 // @module: commonjs // @moduleResolution: classic // @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: external.ts export class A { } export class B extends A { } declare var dec: any; @dec class C { method(@dec x: number) { } } function id<T...
{ "end_byte": 1240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpers.ts" }
TypeScript/tests/cases/compiler/APISample_compile.ts_3_1621
@module: commonjs // @skipLibCheck: true // @noImplicitAny:true // @strictNullChecks:true // @noTypesAndSymbols: true // @filename: node_modules/typescript/package.json { "name": "typescript", "types": "/.ts/typescript.d.ts" } // @filename: APISample_compile.ts /* * Note: This test is a public API sample. T...
{ "end_byte": 1621, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/APISample_compile.ts" }
TypeScript/tests/cases/compiler/cachedModuleResolution4.ts_0_222
// @moduleResolution: classic // @traceResolution: true // @filename: /a/b/foo.d.ts export declare let x: number // @filename: /a/b/c/lib.ts import {x} from "foo"; // @filename: /a/b/c/d/e/app.ts import {x} from "foo";
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cachedModuleResolution4.ts" }
TypeScript/tests/cases/compiler/contextualTyping39.ts_0_57
var foo = <{ (): number; }> function() { return "err"; };
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping39.ts" }
TypeScript/tests/cases/compiler/typeParametersInStaticMethods.ts_0_68
class foo<T> { static M(x: (x: T) => { x: { y: T } }) { } }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParametersInStaticMethods.ts" }
TypeScript/tests/cases/compiler/genericFunctionHasFreshTypeArgs.ts_0_60
function f(p: <T>(x: T) => void) { }; f(x => f(y => x = y));
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionHasFreshTypeArgs.ts" }
TypeScript/tests/cases/compiler/internalAliasFunctionInsideTopLevelModuleWithExport.ts_0_191
//@module: amd // @declaration: true export module a { export function foo(x: number) { return x; } } export import b = a.foo; export var bVal = b(10); export var bVal2 = b;
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasFunctionInsideTopLevelModuleWithExport.ts" }
TypeScript/tests/cases/compiler/global.ts_0_93
module M { export function f(y:number) { return x+y; } } var x=10; M.f(3);
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/global.ts" }
TypeScript/tests/cases/compiler/targetTypeCalls.ts_0_423
var fra1: (v:any)=>string = function() { return function (v:string) {return v;}; }() // should work var fra2: (v:any)=>number = function() { return function () { return 0; } }() // should work var fra3: (v:any)=>string = function() { return function() { return function(v) {return v;};}(); }() // should work var fra4: ...
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeCalls.ts" }
TypeScript/tests/cases/compiler/errorsWithInvokablesInUnions01.ts_0_477
interface ConstructableA { new(): { somePropA: any }; } interface IDirectiveLinkFn<TScope> { (scope: TScope): void; } interface IDirectivePrePost<TScope> { pre?: IDirectiveLinkFn<TScope>; post?: IDirectiveLinkFn<TScope>; } export let blah: IDirectiveLinkFn<number> | ConstructableA | IDirectivePrePost<n...
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorsWithInvokablesInUnions01.ts" }
TypeScript/tests/cases/compiler/incompatibleExports1.ts_0_264
declare module "foo" { export interface x { a: string } interface y { a: Date } export = y; } declare module "baz" { export module a { export var b: number; } module c { export var c: string; } export = c; }
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompatibleExports1.ts" }
TypeScript/tests/cases/compiler/mutuallyRecursiveInference.ts_0_215
class T<A> { a: A; b: any } class L<RT extends { a: 'a' | 'b', b: any }> extends T<RT[RT['a']]> { m() { this.a } } class X extends L<X> { a: 'a' | 'b' b: number m2() { this.a } }
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mutuallyRecursiveInference.ts" }
TypeScript/tests/cases/compiler/baseExpressionTypeParameters.ts_0_223
// Repro from #17829 function base<T>() { class Base { static prop: T; } return Base; } class Gen<T> extends base<T>() {} // Error, T not in scope class Spec extends Gen<string> {} <string>Spec.prop;
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseExpressionTypeParameters.ts" }
TypeScript/tests/cases/compiler/unreachableFlowAfterFinally.ts_0_159
// @noImplicitReturns: true function f() { let x = 100; try { throw "WAT" } catch (e) { } finally { return x; } }
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableFlowAfterFinally.ts" }
TypeScript/tests/cases/compiler/privacyFunc.ts_0_4331
module m1 { export class C1_public { private f1() { } } class C2_private { } export class C3_public { constructor (m1_c3_c1: C1_public); constructor (m1_c3_c2: C2_private); //error constructor (m1_c3_c1_2: any) { } private f1_private(m1_c3_f...
{ "end_byte": 4331, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunc.ts" }
TypeScript/tests/cases/compiler/commonJsUnusedLocals.ts_0_127
// @noUnusedLocals: true // @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js const x = 0; exports.y = 1;
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonJsUnusedLocals.ts" }
TypeScript/tests/cases/compiler/es5-commonjs5.ts_0_129
// @target: ES5 // @sourcemap: false // @declaration: false // @module: commonjs export default function () { return "test"; }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-commonjs5.ts" }
TypeScript/tests/cases/compiler/interfaceImplementation5.ts_0_514
interface I1 { getset1:number; } class C1 implements I1 { public get getset1(){return 1;} } class C2 implements I1 { public set getset1(baz:number){} } class C3 implements I1 { public get getset1(){return 1;} public set getset1(baz:number){} } class C4 implements I1 { public get getset1(){va...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceImplementation5.ts" }
TypeScript/tests/cases/compiler/functionCall12.ts_0_138
function foo(a:string, b?:number, c?:string){} foo('foo', 1); foo('foo'); foo(); foo(1, 'bar'); foo('foo', 1, 'bar'); foo('foo', 1, 3);
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall12.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationsImports4.ts_0_808
// @module: amd // @declaration: true // @outFile: f.js // @filename: a.ts export class A {} // @filename: b.ts export class B {x: number;} // @filename: c.d.ts declare module "C" { class Cls {y: string; } } // @filename: d.d.ts declare module "D" { import {A} from "a"; import {B} from "b"; module "...
{ "end_byte": 808, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationsImports4.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredDefaultExportType2.ts_0_108
// @declaration: true // @module: commonjs // test.ts export = { foo: [], bar: undefined, baz: null }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredDefaultExportType2.ts" }
TypeScript/tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts_0_577
const a = { a: 1 } const b = [1] if ({ a: 1 } === { a: 1 }) { } if ([1] === [1]) { } if (a === { a: 1 }) { } if (b === [1]) { } if ({ a: 1 } === a) { } if ([1] === b) { } if ({ a: 1 } !== { a: 1 }) { } if ([1] !== [1]) { } if (a !== { a: 1 }) { } if (b !== [1]) { } if ({ a: 1 } !== a) { } if ([1] !== b) { } if ({ a:...
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts" }
TypeScript/tests/cases/compiler/declarationEmitPartialReuseComputedProperty.ts_0_298
// @strict: true // @declaration: true // @target: es2020 // @filename: a.ts export const n = "A" export const poz = 1; export const neg = -1; export const o = () => null! as { [n]: string, foo: string, [poz]: number, [neg]: number } // @filename: b.ts import { o } from "./a"; export const g = o
{ "end_byte": 298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPartialReuseComputedProperty.ts" }
TypeScript/tests/cases/compiler/conflictingMemberTypesInBases.ts_0_230
interface A { m: string; } interface B extends A { } interface C { m: number; } interface D extends C { } interface E extends B { } // Error here for extending B and D interface E extends D { } // No duplicate error here
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictingMemberTypesInBases.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInFunction1.ts_0_72
//@noUnusedLocals:true //@noUnusedParameters:true function f1<T>() { }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInFunction1.ts" }
TypeScript/tests/cases/compiler/thisInArrowFunctionInStaticInitializer1.ts_0_130
function log(a) { } class Vector { static foo = () => { // 'this' should be allowed in a static initializer. log(this); } }
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInArrowFunctionInStaticInitializer1.ts" }
TypeScript/tests/cases/compiler/misspelledJsDocTypedefTags.ts_0_285
// @allowJs: true // @noEmit: true // @filename: a.js /** @typedef {{ endTime: number, screenshots: number}} A.<b>*/ Animation.AnimationModel.ScreenshotCapture.Request; /** @typedef {{ endTime: number, screenshots: !B.<string>}} */ Animation.AnimationModel.ScreenshotCapture.Request;
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/misspelledJsDocTypedefTags.ts" }
TypeScript/tests/cases/compiler/objectLiteralEnumPropertyNames.ts_0_689
// Fixes #16887 enum Strs { A = 'a', B = 'b' } type TestStrs = { [key in Strs]: string } const x: TestStrs = { [Strs.A]: 'xo', [Strs.B]: 'xe' } const ux = { [Strs.A]: 'xo', [Strs.B]: 'xe' } const y: TestStrs = { ['a']: 'yo', ['b']: 'ye' } const a = 'a'; const b = 'b'; const z: TestStrs =...
{ "end_byte": 689, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralEnumPropertyNames.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts_0_709
// @module: commonjs // @filename: map.ts import { Observable } from "observable" (<any>Observable.prototype).map = function() { } declare module "observable" { interface Observable<T> { map<U>(proj: (e:T) => U): Observable<U> } namespace Observable { let someAnotherValue: number; } }...
{ "end_byte": 709, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts" }
TypeScript/tests/cases/compiler/errorTypesAsTypeArguments.ts_0_48
interface Foo<A> { bar(baz: Foo<B>): Foo<C>; }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorTypesAsTypeArguments.ts" }
TypeScript/tests/cases/compiler/declarationMerging1.ts_0_142
// @filename: file1.ts class A { protected _f: number; getF() { return this._f; } } // @filename: file2.ts interface A { run(); }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationMerging1.ts" }
TypeScript/tests/cases/compiler/declFileTypeofInAnonymousType.ts_0_315
// @declaration: true module m1 { export class c { } export enum e { weekday, weekend, holiday } } var a: { c: m1.c; }; var b = { c: m1.c, m1: m1 }; var c = { m1: m1 }; var d = { m: { mod: m1 }, mc: { cl: m1.c }, me: { en: m1.e }, mh: m1.e.holiday };
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeofInAnonymousType.ts" }
TypeScript/tests/cases/compiler/controlFlowSelfReferentialLoop.ts_0_3949
// @noimplicitany: true // Repro from #12319 function md5(string:string): void { function FF(a,b,c,d,x,s,ac) { return 0; }; function GG(a,b,c,d,x,s,ac) { return 0; }; function HH(a,b,c,d,x,s,ac) { return 0; }; function II(a,b,c,d,x,s,ac) { return 0; ...
{ "end_byte": 3949, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowSelfReferentialLoop.ts" }
TypeScript/tests/cases/compiler/exportDefaultFunctionInNamespace.ts_0_133
namespace ns_function { export default function () {} } namespace ns_async_function { export default async function () {} }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultFunctionInNamespace.ts" }
TypeScript/tests/cases/compiler/invalidUnicodeEscapeSequance2.ts_0_13
var arg\uxxxx
{ "end_byte": 13, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidUnicodeEscapeSequance2.ts" }
TypeScript/tests/cases/compiler/amdDependencyComment2.ts_0_81
//@module: amd ///<amd-dependency path='bar'/> import m1 = require("m2") m1.f();
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdDependencyComment2.ts" }
TypeScript/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInLambda.ts_0_185
declare function alert(message?: any): void; var x = { doStuff: (callback) => () => { var _this = 2; return callback(_this); } } alert(x.doStuff(x => alert(x)));
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInLambda.ts" }
TypeScript/tests/cases/compiler/genericSpecializations2.ts_0_417
class IFoo<T> { foo<T>(x: T): T { // no error on implementors because IFoo's T is different from foo's T return null; } } class IntFooBad implements IFoo<number> { foo<string>(x: string): string { return null; } } class StringFoo2 implements IFoo<string> { foo<string>(x: string): string { retu...
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericSpecializations2.ts" }
TypeScript/tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts_0_135
// @module: commonjs // @declaration: true // @filename: server.ts export var a = 10; // @filename: client.ts export import "server";
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts" }
TypeScript/tests/cases/compiler/augmentedTypesInterface.ts_0_397
// interface then interface interface i { foo(): void; } interface i { bar(): number; } // interface then class interface i2 { foo(): void; } class i2 { bar() { return 1; } } // interface then enum interface i3 { // error foo(): void; } enum i3 { One }; // error // interface then i...
{ "end_byte": 397, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesInterface.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals2_1.ts_0_417
// @module: amd // @filename: file1.d.ts declare module "file1" { function foo(): void; export = foo; } // @filename: file2.ts /// <reference path="file1.d.ts"/> import x = require("file1"); // should error since './file1' does not have namespace meaning declare module "file1" { interface A { a } } /...
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals2_1.ts" }
TypeScript/tests/cases/compiler/readonlyAssignmentInSubclassOfClassExpression.ts_0_139
class C extends (class {} as new () => Readonly<{ attrib: number }>) { constructor() { super() this.attrib = 2 } }
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyAssignmentInSubclassOfClassExpression.ts" }
TypeScript/tests/cases/compiler/classNonUniqueSymbolMethodHasSymbolIndexer.ts_0_403
// @target: es6 // @strict: true // @declaration: true declare const a: symbol; export class A { [a]() { return 1 }; } declare const e1: A[typeof a]; // no error, `A` has `symbol` index type Constructor = new (...args: any[]) => {}; declare function Mix<T extends Constructor>(classish: T): T & (new (...args: any[]...
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classNonUniqueSymbolMethodHasSymbolIndexer.ts" }
TypeScript/tests/cases/compiler/capturedVarInLoop.ts_0_153
// @target: es5 for (var i = 0; i < 10; i++) { var str = 'x', len = str.length; let lambda1 = (y) => { }; let lambda2 = () => lambda1(len); }
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedVarInLoop.ts" }
TypeScript/tests/cases/compiler/commentOnParameter2.ts_3_128
nction commentedParameters( /* Parameter a */ a /* End of parameter a */ /* Parameter b */ , b /* End of parameter b */ ){}
{ "end_byte": 128, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnParameter2.ts" }
TypeScript/tests/cases/compiler/spreadExpressionContextualTypeWithNamespace.ts_0_659
// @filename: spreadExpressionContextualTypeWithNamespace_0.ts // Repro from #44179 with some modification function func() {} class klass {} const obj = { x: true }; export { func, klass, obj }; export function exportedDirectly() {} // @filename: spreadExpressionContextualTypeWithNamespace_1.ts import * as stuff f...
{ "end_byte": 659, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadExpressionContextualTypeWithNamespace.ts" }
TypeScript/tests/cases/compiler/inferentialTypingWithFunctionType2.ts_0_83
function identity<A>(a: A): A { return a; } var x = [1, 2, 3].map(identity)[0];
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingWithFunctionType2.ts" }
TypeScript/tests/cases/compiler/interMixingModulesInterfaces2.ts_0_205
module A { export interface B { name: string; value: number; } module B { export function createB(): B { return null; } } } var x: A.B = null;
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interMixingModulesInterfaces2.ts" }
TypeScript/tests/cases/compiler/reactNamespaceMissingDeclaration.tsx_0_89
//@jsx: react //@reactNamespace: myReactLib // Error myReactLib not declared <foo data/>
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactNamespaceMissingDeclaration.tsx" }
TypeScript/tests/cases/compiler/aliasesInSystemModule1.ts_0_328
// @module: system // @isolatedModules: true import alias = require('foo'); import cls = alias.Class; export import cls2 = alias.Class; let x = new alias.Class(); let y = new cls(); let z = new cls2(); module M { export import cls = alias.Class; let x = new alias.Class(); let y = new cls(); let z = new cls2...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasesInSystemModule1.ts" }
TypeScript/tests/cases/compiler/recursiveGetterAccess.ts_0_61
class MyClass { get testProp() { return this.testProp; } }
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveGetterAccess.ts" }
TypeScript/tests/cases/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.ts_0_428
// @strict: true // @checkJs: true // @noEmit: true // @filename: index.js /** * @template T * @param {(value: T, index: number) => boolean} predicate * @returns {T} */ function filter(predicate) { return /** @type {any} */ (null); } const a = filter( /** * @param {number} [pose] */ (pose) => true );...
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.ts" }
TypeScript/tests/cases/compiler/es6ClassTest5.ts_0_159
class C1T5 { foo: (i: number, s: string) => number = (i) => { return i; } } module C2T5 {} class bigClass { public break = 1; }
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest5.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationOfAlias.ts_0_228
// @Filename: /a.ts interface I {} export default I; // @Filename: /b.ts export {}; declare module './a' { export default interface I { x: number; } } // @Filename: /c.ts import I from "./a"; function f(i: I) { i.x; }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationOfAlias.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInLambda3.ts_0_112
//@noUnusedLocals:true //@noUnusedParameters:true class A<T> { public x: T; } var y: new <T,U>(a:T)=>void;
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInLambda3.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts_0_715
// @target: ES5 // @module: commonjs // @declaration: true module m { class private1 { } module m2 { export class public1 { } } export var x: { x: private1; y: m2.public1; (): m2.public1[]; method(): private1; [n: number]: private1; [...
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts" }
TypeScript/tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts_0_100
// @lib: es5 function boo { static test() static test(name:string) static test(name?:any){ } }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarInLambda.ts_0_185
declare function alert(message?: any): void; var x = { doStuff: (callback) => () => { var _this = 2; return callback(this); } } alert(x.doStuff(x => alert(x)));
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarInLambda.ts" }
TypeScript/tests/cases/compiler/constDeclarationShadowedByVarDeclaration2.ts_0_156
// @target: ES6 // No errors, const declaration is not shadowed function outer() { const x = 0; function inner() { var x = "inner"; } }
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarationShadowedByVarDeclaration2.ts" }
TypeScript/tests/cases/compiler/nativeToBoxedTypes.ts_0_179
var N = new Number(); var n = 100; n = N; var S = new String(); var s = "foge"; s = S; var B = new Boolean(); var b = true; b = B; var sym: symbol; var Sym: Symbol; sym = Sym;
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nativeToBoxedTypes.ts" }
TypeScript/tests/cases/compiler/moduleWithTryStatement1.ts_0_54
module M { try { } catch (e) { } } var v = M;
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleWithTryStatement1.ts" }
TypeScript/tests/cases/compiler/unusedVariablesWithUnderscoreInBindingElement.ts_0_1800
// @noUnusedLocals: true function t1() { const [_a1, b1] = [1, 2]; console.log(b1); const [a2, _b2] = [1, 2]; console.log(a2); const [_a3, _b3] = [1, 2]; } function t2() { const [_a1, b1] = [1, 2]; const [a2, _b2] = [1, 2]; const [a3, b3] = [1, 2]; } function t3() { const [_a1, ...
{ "end_byte": 1800, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesWithUnderscoreInBindingElement.ts" }
TypeScript/tests/cases/compiler/privacyAccessorDeclFile.ts_0_5494
// @target: ES5 // @module: commonjs // @declaration: true // @Filename:privacyAccessorDeclFile_externalModule.ts class privateClass { } export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass { // Error return null; } ...
{ "end_byte": 5494, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyAccessorDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyAccessorDeclFile.ts_5496_11656
export module publicModule { class privateClass { } export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass { // Error return null; } private static get myPrivateStaticMethod(): privat...
{ "end_byte": 11656, "start_byte": 5496, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyAccessorDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyAccessorDeclFile.ts_11658_18889
module privateModule { class privateClass { } export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass { return null; } private static get myPrivateStaticMethod(): privateClass { ...
{ "end_byte": 18889, "start_byte": 11658, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyAccessorDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyAccessorDeclFile.ts_18891_29726
module publicModuleInGlobal { class privateClass { } export class publicClass { } module privateModule { class privateClass { } export class publicClass { } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMetho...
{ "end_byte": 29726, "start_byte": 18891, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyAccessorDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyAccessorDeclFile.ts_29732_31861
class privateClassWithWithPrivateSetAccessorTypes { static set myPublicStaticMethod(param: privateClass) { } private static set myPrivateStaticMethod(param: privateClass) { } set myPublicMethod(param: privateClass) { } private set myPrivateMethod(param: privateCla...
{ "end_byte": 31861, "start_byte": 29732, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyAccessorDeclFile.ts" }