_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/ambientClassDeclaredBeforeBase.ts_0_104
// @filename: a.d.ts declare namespace ns { class SecondNS extends FirstNS { } class FirstNS { } }
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientClassDeclaredBeforeBase.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndEnumInGlobal.ts_0_73
enum _this { // Error _thisVal1, _thisVal2, } var f = () => this;
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndEnumInGlobal.ts" }
TypeScript/tests/cases/compiler/declFilePrivateStatic.ts_0_273
// @declaration: true // @target: es5 class C { private static x = 1; static y = 1; private static a() { } static b() { } private static get c() { return 1; } static get d() { return 1; } private static set e(v) { } static set f(v) { } }
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFilePrivateStatic.ts" }
TypeScript/tests/cases/compiler/enumAssignmentCompat7.ts_0_383
// @strict: true // @strictFunctionTypes: false namespace first { export enum E { A = 1 } } namespace second { export enum E { A = 2 } } class Base { method(param: first.E) { } } class Derived extends Base { override method(param: second.E) { } } function overloadingFunction(): first.E function overloadingFunction(): second.E { return second.E.B }
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumAssignmentCompat7.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability41.ts_0_446
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 class classWithTwoPrivate<T,U> { constructor(private one: T, private two: U) {} } var x6 = new classWithTwoPrivate(1, "a");; export var __val__x6 = x6; } __test2__.__val__x6 = __test1__.__val__obj4
{ "end_byte": 446, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability41.ts" }
TypeScript/tests/cases/compiler/importedEnumMemberMergedWithExportedAliasIsError.ts_0_182
// @filename: enum.ts export enum Enum { A, B } // @filename: alias.ts import {Enum} from "./enum"; import EnumA = Enum.A; export type EnumA = [string] | [string, number];
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importedEnumMemberMergedWithExportedAliasIsError.ts" }
TypeScript/tests/cases/compiler/relatedViaDiscriminatedTypeNoError.ts_0_227
class Model { constructor(public flag: boolean) {} } type DiscriminatedUnion = { flag: true } | { flag: false }; class A<T extends DiscriminatedUnion> { constructor(public model: T) { } } class B extends A<Model> { }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/relatedViaDiscriminatedTypeNoError.ts" }
TypeScript/tests/cases/compiler/conditionalEqualityTestingNullability.ts_0_332
// @strict: true export type Equals<A1 extends any, A2 extends any> = (<A>() => A extends A1 ? 1 : 0) extends (<A>() => A extends A2 ? 1 : 0) ? 1 : 0 interface Foo<T> { x : () => T } declare const a: Foo<Date>; declare const b: Foo<Date | null>; //Expected 0, Actual 1 type ShouldBe0 = Equals<typeof a, typeof b>;
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalEqualityTestingNullability.ts" }
TypeScript/tests/cases/compiler/exportDefaultMarksIdentifierAsUsed.ts_0_214
// @target: es2017 // @module: commonjs // @strict: true // @allowJs: true // @outDir: /dist // @filename: a.js const Obj = {}; export default Obj; // @filename: b.js import Obj from './a'; Obj.fn = function() {};
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultMarksIdentifierAsUsed.ts" }
TypeScript/tests/cases/compiler/functionExpressionWithResolutionOfTypeOfSameName01.ts_3_54
terface f { } var x = function f() { <f>f; }
{ "end_byte": 54, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionWithResolutionOfTypeOfSameName01.ts" }
TypeScript/tests/cases/compiler/constructorOverloads5.ts_1_505
interface IArguments {} declare module M { export function RegExp(pattern: string): RegExp; export function RegExp(pattern: string, flags: string): RegExp; export class RegExp { constructor(pattern: string); constructor(pattern: string, flags: string); exec(string: string): string[]; test(string: string): boolean; source: string; global: boolean; ignoreCase: boolean; multiline: boolean; lastIndex: boolean; } }
{ "end_byte": 505, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads5.ts" }
TypeScript/tests/cases/compiler/declarationEmitQualifiedAliasTypeArgument.ts_0_458
// @declaration: true // @filename: bbb.d.ts export interface INode<T> { data: T; } export function create<T>(): () => INode<T>; // @filename: lib.d.ts export type G<T extends string> = { [P in T]: string }; export enum E { A = "a", B = "b" } export type T = G<E>; export type Q = G<E.A>; // @filename: index.ts import { T, Q } from "./lib"; import { create } from "./bbb"; export const fun = create<T>(); export const fun2 = create<Q>();
{ "end_byte": 458, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitQualifiedAliasTypeArgument.ts" }
TypeScript/tests/cases/compiler/noImplicitReturnsInAsync2.ts_0_977
// @target: es6 // @noImplicitReturns: true // Should be an error, Promise<number>, currently retorted correctly async function test3(isError: boolean = true) { if (isError === true) { return 6; } } // Should not be an error, Promise<any>, currently **not** working async function test4(isError: boolean = true) { if (isError === true) { return undefined; } } // should not be error, Promise<any> currently working correctly async function test5(isError: boolean = true): Promise<any> { //should not be error if (isError === true) { return undefined; } } // should be error, currently reported correctly async function test6(isError: boolean = true): Promise<number> { if (isError === true) { return undefined; } } // infered to be Promise<void>, should not be an error, currently reported correctly async function test7(isError: boolean = true) { if (isError === true) { return; } }
{ "end_byte": 977, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitReturnsInAsync2.ts" }
TypeScript/tests/cases/compiler/referenceSatisfiesExpression.ts_0_418
let a = 10; --(a satisfies number); ++(a satisfies number); (a satisfies number)++; (a satisfies number)--; let b: number; (b satisfies number) = 10; let c: number; [(c satisfies number)] = [10]; let d: number, e = 1; ({ d: (e satisfies number) } = { d: 10 }); let g = 1 for ((g satisfies number) of [10]) { console.log(g) } let x: string = "hello" for ((x satisfies string) in { a: 10 }) { console.log(x) }
{ "end_byte": 418, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/referenceSatisfiesExpression.ts" }
TypeScript/tests/cases/compiler/missingCloseParenStatements.ts_0_275
var a1, a2, a3 = 0; if ( a1 && (a2 + a3 > 0) { while( (a2 > 0) && a1 { do { var i = i + 1; a1 = a1 + i; with ((a2 + a3 > 0) && a1 { console.log(x); } } while (i < 5 && (a1 > 5); } }
{ "end_byte": 275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingCloseParenStatements.ts" }
TypeScript/tests/cases/compiler/classExtendsInterface_not.ts_0_28
class C extends "".bogus {}
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsInterface_not.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierEnum.ts_0_528
// Test the error message when attempting to merge an enum with a class, an interface, or a function. // @Filename: duplicateIdentifierEnum_A.ts enum A { bar } class A { foo: number; } interface B { foo: number; } const enum B { bar } const enum C { } function C() { return 0; } enum D { bar } class E { foo: number; } // also make sure the error appears when trying to merge an enum in a separate file. // @Filename: duplicateIdentifierEnum_B.ts function D() { return 0; } enum E { bar }
{ "end_byte": 528, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierEnum.ts" }
TypeScript/tests/cases/compiler/typeofSimple.ts_0_256
var v = 3; var v2: typeof v; var v3: string = v2; // Not assignment compatible interface I<T> { x: T; } interface J { } var numberJ: typeof J; //Error, cannot reference type in typeof var numberI: I<typeof v2>; var fun: () => I<number>; numberI = fun();
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofSimple.ts" }
TypeScript/tests/cases/compiler/declarationFilesWithTypeReferences3.ts_0_220
// @declaration: true // @filename: /a/node_modules/@types/node/index.d.ts interface Error2 { stack2: string; } // @filename: /a/app.ts /// <reference types="node"/> function foo(): Error2 { return undefined; }
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFilesWithTypeReferences3.ts" }
TypeScript/tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts_0_124
// @target: es5 declare let doSomething; for (let a1 of []) for (let a2 of a1.someArray) doSomething(() => a2);
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts" }
TypeScript/tests/cases/compiler/moduleVisibilityTest3.ts_0_442
module _modes { export interface IMode { } 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 { constructor(p1: modes, p2: modes.Mode) {// should be an error on p2 - it's not exported var x:modes.Mode; } } }
{ "end_byte": 442, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleVisibilityTest3.ts" }
TypeScript/tests/cases/compiler/exportStarFromEmptyModule.ts_0_540
// @target: es5 // @module: commonjs // @declaration: true // @filename: exportStarFromEmptyModule_module1.ts export class A { static r; } // @filename:exportStarFromEmptyModule_module2.ts // empty // @filename: exportStarFromEmptyModule_module3.ts export * from "./exportStarFromEmptyModule_module2"; export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } // @filename: exportStarFromEmptyModule_module4.ts import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error
{ "end_byte": 540, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportStarFromEmptyModule.ts" }
TypeScript/tests/cases/compiler/enumGenericTypeClash.ts_0_36
class X<A,B,C> { } enum X { MyVal }
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumGenericTypeClash.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithFunctionChildren.ts_0_236
module M { export var x = 3; function fn(M, p = x) { } } module M { function fn2() { var M; var p = x; } } module M { function fn3() { function M() { var p = x; } } }
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithFunctionChildren.ts" }
TypeScript/tests/cases/compiler/tripleSlashInCommentNotParsed.ts_0_61
/* /// <reference path="non-existing-file.d.ts" /> */ void 0;
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tripleSlashInCommentNotParsed.ts" }
TypeScript/tests/cases/compiler/duplicateErrorClassExpression.ts_0_382
// @strict: true interface ComplicatedTypeBase { [s: string]: ABase; } interface ComplicatedTypeDerived { [s: string]: ADerived; } interface ABase { a: string; } interface ADerived { b: string; } class Base { foo!: ComplicatedTypeBase; } const x = class Derived extends Base { foo!: ComplicatedTypeDerived; } let obj: { 3: string } = { 3: "three" }; obj[x];
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateErrorClassExpression.ts" }
TypeScript/tests/cases/compiler/functionOverloads6.ts_0_108
class foo { static fnOverload(); static fnOverload(foo:string); static fnOverload(foo?: any){ } }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads6.ts" }
TypeScript/tests/cases/compiler/constDeclarations-validContexts.ts_0_1401
// @allowUnreachableCode: true // @target: ES6 // Control flow statements with blocks if (true) { const c1 = 0; } else { const c2 = 0; } while (true) { const c3 = 0; } do { const c4 = 0; } while (true); var obj; with (obj) { const c5 = 0; } for (var i = 0; i < 10; i++) { const c6 = 0; } for (var i2 in {}) { const c7 = 0; } if (true) { label: const c8 = 0; } while (false) { label2: label3: label4: const c9 = 0; } // Try/catch/finally try { const c10 = 0; } catch (e) { const c11 = 0; } finally { const c12 = 0; } // Switch switch (0) { case 0: const c13 = 0; break; default: const c14 = 0; break; } // blocks { const c15 = 0; { const c16 = 0 label17: const c17 = 0; } } // global const c18 = 0; // functions function F() { const c19 = 0; } var F2 = () => { const c20 = 0; }; var F3 = function () { const c21 = 0; }; // modules module m { const c22 = 0; { const c23 = 0; } } // methods class C { constructor() { const c24 = 0; } method() { const c25 = 0; } get v() { const c26 = 0; return c26; } set v(value) { const c27 = value; } } // object literals var o = { f() { const c28 = 0; }, f2: () => { const c29 = 0; } }
{ "end_byte": 1401, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-validContexts.ts" }
TypeScript/tests/cases/compiler/missingCloseBrace.ts_0_64
function base_init() { { } function me() { }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingCloseBrace.ts" }
TypeScript/tests/cases/compiler/arrayDestructuringInSwitch1.ts_0_624
export type Expression = BooleanLogicExpression | 'true' | 'false'; export type BooleanLogicExpression = ['and', ...Expression[]] | ['not', Expression]; export function evaluate(expression: Expression): boolean { if (Array.isArray(expression)) { const [operator, ...operands] = expression; switch (operator) { case 'and': { return operands.every((child) => evaluate(child)); } case 'not': { return !evaluate(operands[0]); } default: { throw new Error(`${operator} is not a supported operator`); } } } else { return expression === 'true'; } }
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayDestructuringInSwitch1.ts" }
TypeScript/tests/cases/compiler/shorthandPropertyAssignmentInES6Module.ts_0_265
// @target: ES6 // @module: commonjs // @filename: existingModule.ts export var x = 1; // @filename: test.ts import {x} from './existingModule'; import {foo} from './missingModule'; declare function use(a: any): void; const test = { x, foo }; use(x); use(foo);
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shorthandPropertyAssignmentInES6Module.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts_0_169
// @declaration: true class Foo { private static readonly A = "a"; private readonly B = "b"; private static readonly C = 42; private readonly D = 42; }
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts" }
TypeScript/tests/cases/compiler/noImplicitUseStrict_commonjs.ts_0_69
// @module: commonjs // @noImplicitUseStrict: true export var x = 0;
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitUseStrict_commonjs.ts" }
TypeScript/tests/cases/compiler/es6ExportClause.ts_0_278
// @target: es6 // @declaration: true // @filename: server.ts class c { } interface i { } module m { export var x = 10; } var x = 10; module uninstantiated { } export { c }; export { c as c2 }; export { i, m as instantiatedModule }; export { uninstantiated }; export { x };
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportClause.ts" }
TypeScript/tests/cases/compiler/systemModuleTargetES6.ts_0_282
// @target: ES6 // @module: System export class MyClass { } export class MyClass2 { static value = 42; static getInstance() { return MyClass2.value; } } export function myFunction() { return new MyClass(); } export function myFunction2() { return new MyClass2(); }
{ "end_byte": 282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleTargetES6.ts" }
TypeScript/tests/cases/compiler/argumentsAsPropertyName.ts_0_352
// target: es5 type MyType = { arguments: Array<string> } declare function use(s: any); function myFunction(myType: MyType) { for (let i = 0; i < 10; i++) { use(myType.arguments[i]); // create closure so that tsc will turn loop body into function const x = 5; [1, 2, 3].forEach(function(j) { use(x); }) } }
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsAsPropertyName.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts_3_41
@sourcemap: true var [x] = [1, 2];
{ "end_byte": 41, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts" }
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts_0_77
var v: any[]; function foo(a = v[1 + 1]) { } function bar(a = v[1 + 1]) { }
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts" }
TypeScript/tests/cases/compiler/metadataOfUnion.ts_0_433
// @experimentalDecorators: true // @emitDecoratorMetadata: true function PropDeco(target: Object, propKey: string | symbol) { } class A { } class B { @PropDeco x: "foo" | A; @PropDeco y: true | boolean; @PropDeco z: "foo" | boolean; } enum E { A, B, C, D } class D { @PropDeco a: E.A; @PropDeco b: E.B | E.C; @PropDeco c: E; @PropDeco d: E | number; }
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataOfUnion.ts" }
TypeScript/tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx_0_761
// @jsx: preserve // @filename: index.tsx namespace JSX { export interface Element {} } type Props<T> = PropsBase<string> | PropsWithConvert<T>; interface PropsBase<T> { data: T; } interface PropsWithConvert<T> extends PropsBase<T> { convert: (t: T) => string; } function ShouldInferFromData<T>(props: Props<T>): JSX.Element { return <div />; } // Sanity check: function call equivalent versions work fine ShouldInferFromData({ data: "1" }); ShouldInferFromData({ data: "1", convert: n => "" + n }); ShouldInferFromData({ data: 2, convert: n => "" + n }); const f1 = <ShouldInferFromData data={"1"} />; const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />; const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
{ "end_byte": 761, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxInferenceShouldNotYieldAnyOnUnions.tsx" }
TypeScript/tests/cases/compiler/prettyFileWithErrorsAndTabs.ts_0_111
// @pretty: true function f() { { const x: string = 12; const y: string = 12; const z: string = 12; } }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prettyFileWithErrorsAndTabs.ts" }
TypeScript/tests/cases/compiler/functionAndPropertyNameConflict.ts_0_85
class C65 { public aaaaa() { } public get aaaaa() { return 1; } }
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionAndPropertyNameConflict.ts" }
TypeScript/tests/cases/compiler/commentInMethodCall.ts_0_77
//commment here var s: string[]; s.map(// do something function () { });
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentInMethodCall.ts" }
TypeScript/tests/cases/compiler/letAsIdentifierInStrictMode.ts_0_56
"use strict"; var let = 10; var a = 10; let = 30; let a;
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letAsIdentifierInStrictMode.ts" }
TypeScript/tests/cases/compiler/noCheckRequiresEmitDeclarationOnly.ts_0_71
// @noCheck: true // @strict: true export const a: number = "not ok";
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCheckRequiresEmitDeclarationOnly.ts" }
TypeScript/tests/cases/compiler/jsExportAssignmentNonMutableLocation.ts_0_327
// @declaration: true // @emitDeclarationOnly: true // @allowJs: true // @checkJs: true // @module: commonjs // @target: es6 // @filename: file.js const customSymbol = Symbol("custom"); // This is a common pattern in Node’s built-in modules: module.exports = { customSymbol, }; exports.customSymbol2 = Symbol("custom");
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsExportAssignmentNonMutableLocation.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyParametersInAmbientFunctions.ts_3_1158
@noImplicitAny: true // No implicit-'any' errors. declare function d_f1(): void; // Implicit-'any' errors for x. declare function d_f2(x): void; // No implicit-'any' errors. declare function d_f3(x: any): void; // Implicit-'any' errors for x, y, and z. declare function d_f4(x, y, z): void; // Implicit-'any' errors for x, and z. declare function d_f5(x, y: any, z): void; // Implicit-'any[]' errors for r. declare function d_f6(...r): void; // Implicit-'any'/'any[]' errors for x, r. declare function d_f7(x, ...r): void; // Implicit-'any' errors for x1, y2, x3, and y3. declare function d_f8(x1, y1: number): any; declare function d_f8(x2: string, y2): any; declare function d_f8(x3, y3): any; // No implicit-'any' errors. declare var d_f9: () => string; // Implicit-'any' error for x. declare var d_f10: (x) => string; // Implicit-'any' errors for x, y, and z. declare var d_f11: (x, y, z) => string; // Implicit-'any' errors for x and z. declare var d_f12: (x, y: any, z) => string; // Implicit-'any[]' error for r. declare var d_f13: (...r) => string; // Implicit-'any'/'any[]' errors for x, r. declare var d_f14: (x, ...r) => string;
{ "end_byte": 1158, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyParametersInAmbientFunctions.ts" }
TypeScript/tests/cases/compiler/modulePreserve5.ts_0_290
// @module: preserve // @target: esnext // @resolveJsonModule: true // @noEmit: true // @noTypesAndSymbols: true // @Filename: data.json {} // @Filename: main.ts import data1 from "./data.json" with { type: "json" }; const data2 = await import("./data.json", { with: { type: "json" } });
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePreserve5.ts" }
TypeScript/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.ts_0_383
// @module: nodenext // @outDir: ./dist // @declarationDir: ./types // @declaration: true // @filename: package.json { "name": "@this/package", "type": "module", "exports": { ".": { "default": "./dist/index.js", "types": "./types/index.d.ts" } } } // @filename: index.ts import * as me from "@this/package"; me.thing(); export function thing(): void {}
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationModuleSyntax.ts_0_49
// @allowJs: true // @filename: a.js module M { }
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationModuleSyntax.ts" }
TypeScript/tests/cases/compiler/arrowFunctionWithObjectLiteralBody4.ts_0_41
// @target: es6 var v = a => <any><any>{}
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionWithObjectLiteralBody4.ts" }
TypeScript/tests/cases/compiler/shorthandOfExportedEntity01_targetES2015_CommonJS.ts_0_141
// @target: ES2015 // @module: commonjs // @declaration: true export const test = "test"; export function foo () { const x = { test }; }
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shorthandOfExportedEntity01_targetES2015_CommonJS.ts" }
TypeScript/tests/cases/compiler/typeVariableConstraintIntersections.ts_0_2574
// @strict: true // @noEmit: true type T00<K extends "a" | "b"> = K & "a"; type T01<K extends "a" | "b"> = K & "c"; type T02<K extends "a" | "b"> = K & string; type T10<K extends string> = K & "a"; type T11<K extends string> = K & "c"; type T12<K extends string> = K & string; type T20<K extends "a" | "b" | "c"> = K & ("a" | "b" | "c"); type T21<K extends "a" | "b" | "c"> = ("a" | "b" | "c") & K; type T22<K extends "a" | "b" | "c"> = K & ("a" | "b"); type T23<K extends "a" | "b" | "c"> = ("a" | "b") & K; type T30<K extends "a" | "b"> = K & ("a" | "b" | "c"); type T31<K extends "a" | "b"> = ("a" | "b" | "c") & K; type T32<K extends "a" | "b"> = K & ("a" | "b"); type T33<K extends "a" | "b"> = ("a" | "b") & K; type T40<K extends {}> = K & undefined; type T41<K extends {}> = K & null; type T42<K extends {}> = K & object; type T43<K extends {}> = K & {}; type T50<K extends "a" | 0> = K & "a"; type T51<K extends "a" | 0> = K & "b"; type T52<K extends "a" | 0> = K & string; type T53<K extends "a" | 0> = K & 0; type T54<K extends "a" | 0> = K & 1; type T55<K extends "a" | 0> = K & number; type T60<T extends "a" | "b", U extends T> = U & "a"; type T61<T extends "a" | "b", U extends T> = U & ("a" | "b"); type T62<T extends "a" | "b", U extends T> = U & ("a" | "b" | "c"); type T63<T extends "a" | "b", U extends T> = U & string; type T70<T extends "a" | "b", U extends T | "c"> = U & "a"; type T71<T extends "a" | "b", U extends T | "c"> = U & ("a" | "b"); type T72<T extends "a" | "b", U extends T | "c"> = U & ("a" | "b" | "c"); type T73<T extends "a" | "b", U extends T | "c"> = U & string; declare function isA(x: any): x is "a"; declare function isB(x: any): x is "b"; declare function isC(x: any): x is "c"; function foo<K extends "a" | "b">(x: K) { if (isA(x)) { x; // K & "a" } if (isB(x)) { x; // K & "b" } if (isC(x)) { x; // never } if (isA(x) || isB(x)) { x; // K } if (!(isA(x) || isB(x))) { return; } x; // K } // Example from #30581 type OptionOne = { kind: "one"; s: string; }; type OptionTwo = { kind: "two"; x: number; y: number; }; type Options = OptionOne | OptionTwo; type OptionHandlers = { [K in Options['kind']]: (option: Options & { kind: K }) => string; } const optionHandlers: OptionHandlers = { "one": option => option.s, "two": option => option.x + "," + option.y, }; function handleOption<K extends Options['kind']>(option: Options & { kind: K }): string { const kind = option.kind; const handler = optionHandlers[kind]; return handler(option); };
{ "end_byte": 2574, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeVariableConstraintIntersections.ts" }
TypeScript/tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExport.ts_0_200
//@module: commonjs // @declaration: true export module a { export module b { export class c { } } } export module c { import b = a.b; export var x: b.c = new b.c(); }
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts_0_1838
// @strict: true function test(x: boolean): boolean { return x; } let state = true; if (state) { test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); test(state as any && state); }
{ "end_byte": 1838, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticFuncOverridingAccessor.ts_0_168
class a { static get x() { return "20"; } static set x(aValue: string) { } } class b extends a { static x() { return "20"; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticFuncOverridingAccessor.ts" }
TypeScript/tests/cases/compiler/cloduleWithDuplicateMember1.ts_0_211
class C { get x() { return 1; } static get x() { return ''; } static foo() { } } module C { export var x = 1; } module C { export function foo() { } export function x() { } }
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleWithDuplicateMember1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPattern2.ts_0_3157
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [number, string, string]; type MultiSkilledRobot = [string, [string, string]]; let robotA: Robot = [1, "mower", "mowing"]; function getRobot() { return robotA; } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; function getMultiRobot() { return multiRobotA; } let nameA: string, primarySkillA: string, secondarySkillA: string; let numberB: number, nameB: string; let numberA2: number, nameA2: string, skillA2: string, nameMA: string; let numberA3: number, robotAInfo: (number | string)[], multiRobotAInfo: (string | [string, string])[]; let i: number; for ([, nameA] = robotA, i = 0; i < 1; i++) { console.log(nameA); } for ([, nameA] = getRobot(), i = 0; i < 1; i++) { console.log(nameA); } for ([, nameA] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { console.log(nameA); } for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { console.log(primarySkillA); } for ([, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { console.log(primarySkillA); } for ([, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { console.log(primarySkillA); } for ([numberB] = robotA, i = 0; i < 1; i++) { console.log(numberB); } for ([numberB] = getRobot(), i = 0; i < 1; i++) { console.log(numberB); } for ([numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { console.log(numberB); } for ([nameB] = multiRobotA, i = 0; i < 1; i++) { console.log(nameB); } for ([nameB] = getMultiRobot(), i = 0; i < 1; i++) { console.log(nameB); } for ([nameB] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { console.log(nameB); } for ([numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { console.log(nameA2); } for ([numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { console.log(nameA2); } for ([numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { console.log(nameA2); } for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { console.log(nameMA); } for ([nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { console.log(nameMA); } for ([nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { console.log(nameMA); } for ([numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { console.log(numberA3); } for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { console.log(numberA3); } for ([numberA3, ...robotAInfo] = <Robot>[2, "trimmer", "trimming"], i = 0; i < 1; i++) { console.log(numberA3); } for ([...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { console.log(multiRobotAInfo); } for ([...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { console.log(multiRobotAInfo); } for ([...multiRobotAInfo] = <MultiSkilledRobot>["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { console.log(multiRobotAInfo); }
{ "end_byte": 3157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPattern2.ts" }
TypeScript/tests/cases/compiler/readonlyMembers.ts_0_1200
// @target: es5 interface X { readonly a: number; readonly b?: number; } var x: X = { a: 0 }; x.a = 1; // Error x.b = 1; // Error class C { readonly a: number; readonly b = 1; get c() { return 1 } constructor() { this.a = 1; // Ok this.b = 1; // Ok this.c = 1; // Error const f = () => { this.a = 1; // Error this.b = 1; // Error this.c = 1; // Error } } foo() { this.a = 1; // Error this.b = 1; // Error this.c = 1; // Error } } var o = { get a() { return 1 }, get b() { return 1 }, set b(value) { } }; o.a = 1; // Error o.b = 1; var p: { readonly a: number, b: number } = { a: 1, b: 1 }; p.a = 1; // Error p.b = 1; var q: { a: number, b: number } = p; q.a = 1; q.b = 1; enum E { A, B, C } E.A = 1; // Error namespace N { export const a = 1; export let b = 1; export var c = 1; } N.a = 1; // Error N.b = 1; N.c = 1; let xx: { readonly [x: string]: string }; let s = xx["foo"]; xx["foo"] = "abc"; // Error let yy: { readonly [x: number]: string, [x: string]: string }; yy[1] = "abc"; // Error yy["foo"] = "abc";
{ "end_byte": 1200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyMembers.ts" }
TypeScript/tests/cases/compiler/staticsInConstructorBodies.ts_0_83
class C { constructor() { static p1 = 0; // ERROR static m1() {} // ERROR } }
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticsInConstructorBodies.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts_0_331
// @declaration: true var [] = [1, "hello"]; // Dont emit anything var [x] = [1, "hello"]; // emit x: number var [x1, y1] = [1, "hello"]; // emit x1: number, y1: string var [, , z1] = [0, 1, 2]; // emit z1: number var a = [1, "hello"]; var [x2] = a; // emit x2: number | string var [x3, y3, z3] = a; // emit x3, y3, z3
{ "end_byte": 331, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts" }
TypeScript/tests/cases/compiler/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.ts_0_208
//@module: commonjs export module a { export function foo(x: number) { return x; } } export module c { import b = a.foo; var bVal = b(10); export var bVal2 = b; } var d = c.b(11);
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.ts" }
TypeScript/tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts_0_182
class A { private a: number; } class B { private a: string; } type X<T extends A> = [T["a"], (T | B)["a"]]; type Y<T extends A | B> = T["a"]; type Z<T extends A & B> = T["a"];
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts" }
TypeScript/tests/cases/compiler/unusedVariablesinNamespaces3.ts_0_344
//@noUnusedLocals:true //@noUnusedParameters:true namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { isAcceptable(s2: string) { return lettersRegexp.test(s2); } } }
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesinNamespaces3.ts" }
TypeScript/tests/cases/compiler/reExportGlobalDeclaration3.ts_0_279
// @module: commonjs // @filename: file1.d.ts declare namespace NS1 { export var foo: number; } declare namespace NS2 { export var foo: number; } // @filename: file2.ts export {NS1, NS1 as NNS1}; export {NS2, NS2 as NNS2}; export {NS1 as NNNS1}; export {NS2 as NNNS2};
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reExportGlobalDeclaration3.ts" }
TypeScript/tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts_0_122
// regression test for #43123 type Hmm = [0] extends [infer T, any?] ? [T, [0] extends [T] ? true : false] : never
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts" }
TypeScript/tests/cases/compiler/es6ImportNameSpaceImportDts.ts_0_264
// @module: commonjs // @declaration: true // @filename: server.ts export class c { }; // @filename: client.ts import * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.c(); import * as nameSpaceBinding2 from "./server"; // unreferenced
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNameSpaceImportDts.ts" }
TypeScript/tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts_0_266
// @strict: true function update(b: Readonly<Float32Array>) { const c = copy(b); add(c, c); } function add(a: Float32Array, b: Float32Array, c: Float32Array = a) { c[0] = a[0] + b[0]; } function copy(a: Float32Array) { return new Float32Array(a); }
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts" }
TypeScript/tests/cases/compiler/partiallyAmbientClodule.ts_0_102
declare module foo { export function x(): any; } class foo { } // Legal, because module is ambient
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/partiallyAmbientClodule.ts" }
TypeScript/tests/cases/compiler/superAccess.ts_0_561
class MyBase { static S1: number = 5; private S2: string = "test"; f = () => 5; } class MyDerived extends MyBase { foo() { var l3 = super.S1; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword } }
{ "end_byte": 561, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superAccess.ts" }
TypeScript/tests/cases/compiler/deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts_0_718
// @strictNullChecks: true // @exactOptionalPropertyTypes: true, false interface Foo { a: number b: number | undefined c: number | null d?: number e: number | undefined | null f?: number | undefined | null g: unknown h: any i: never } interface AA { [s: string]: number } type BB = { [P in keyof any]: number } declare const f: Foo declare const g: Partial<Foo> declare const a: AA declare const b: BB delete f.a delete f.b delete f.c delete f.d delete f.e delete f.f delete f.g delete f.h delete f.i delete f.j delete g.a delete g.b delete g.c delete g.d delete g.e delete g.f delete g.g delete g.h delete g.i delete g.j delete a.a delete a.b delete b.a delete b.b
{ "end_byte": 718, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deleteExpressionMustBeOptional_exactOptionalPropertyTypes.ts" }
TypeScript/tests/cases/compiler/simpleRecursionWithBaseCase3.ts_0_158
// @strict: true // @noImplicitAny: true // @lib: esnext // @noEmit: true const fn1 = () => { if (Math.random() > 0.5) { return fn1() } return 0 }
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/simpleRecursionWithBaseCase3.ts" }
TypeScript/tests/cases/compiler/intersectionTypeNormalization.ts_0_2147
interface A { a: string } interface B { b: string } interface C { c: string } interface D { d: string } // Identical ways of writing the same type type X1 = (A | B) & (C | D); type X2 = A & (C | D) | B & (C | D) type X3 = A & C | A & D | B & C | B & D; var x: X1; var x: X2; var x: X3; interface X { x: string } interface Y { y: string } // Identical ways of writing the same type type Y1 = (A | X & Y) & (C | D); type Y2 = A & (C | D) | X & Y & (C | D) type Y3 = A & C | A & D | X & Y & C | X & Y & D; var y: Y1; var y: Y2; var y: Y3; interface M { m: string } interface N { n: string } // Identical ways of writing the same type type Z1 = (A | X & (M | N)) & (C | D); type Z2 = A & (C | D) | X & (M | N) & (C | D) type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; var z: Z1; var z: Z2; var z: Z3; var z: Z4; // Repro from #9919 type ToString = { toString(): string; } type BoxedValue = { kind: 'int', num: number } | { kind: 'string', str: string } type IntersectionFail = BoxedValue & ToString type IntersectionInline = { kind: 'int', num: number } & ToString | { kind: 'string', str: string } & ToString function getValueAsString(value: IntersectionFail): string { if (value.kind === 'int') { return '' + value.num; } return value.str; } // Repro from #12535 namespace enums { export const enum A { a1, a2, a3, // ... elements omitted for the sake of clarity a75, a76, a77, } export const enum B { b1, b2, // ... elements omitted for the sake of clarity b86, b87, } export const enum C { c1, c2, // ... elements omitted for the sake of clarity c210, c211, } export type Genre = A | B | C; } type Foo = { genreId: enums.Genre; }; type Bar = { genreId: enums.Genre; }; type FooBar = Foo & Bar; function foo(so: any) { const val = so as FooBar; const isGenre = val.genreId; return isGenre; }
{ "end_byte": 2147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionTypeNormalization.ts" }
TypeScript/tests/cases/compiler/inferTypeConstraintInstantiationCircularity.ts_1_1703
type AMappedType<T> = { [KeyType in keyof T]: number }; type HasM = { m: number; }; // Simplified repro from #48059 interface X1< T extends HasM, Output = AMappedType<{ s: number; } & { [k in keyof T]: number; }> > { tee: T; output: Output; } type F1<T> = T extends X1<infer U> ? U : never; // With default inlined interface X2< T extends HasM, Output > { tee: T; output: Output; } type F2<T> = T extends X2<infer U, AMappedType<{ s: number; } & { [k in keyof (infer U)]: number; }>> ? U : never; // Original repro type Simplify<T> = {[KeyType in keyof T]: T[KeyType]}; type optionalKeys<T extends object> = { [k in keyof T]: undefined extends T[k] ? k : never; }[keyof T]; type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>; export type addQuestionMarks<T extends object> = { [k in optionalKeys<T>]?: T[k]; } & { [k in requiredKeys<T>]: T[k]; }; type ZodRawShape = { [k: string]: ZodType<any>; }; interface ZodType<Output> { _type: Output; } interface ZodObject< T extends ZodRawShape, Output = Simplify< { [k in optionalKeys<T>]?: T[k]; } & { [k in requiredKeys<T>]: T[k]; } > > extends ZodType<Output> { readonly _shape: T; } type MyObject<T> = T extends ZodObject<infer U> ? U extends ZodRawShape ? U : never : never; // Repro from #50479 type Cell<Value extends BaseValue = any, BaseValue = unknown> = { id: string } type Items<Type extends Cell = Cell> = { type: Type name: string } type InferIOItemToJSType<T extends Items> = T extends { type: infer U } ? U extends Cell<infer V/**, infer _ or unknown, or any valid type **/> ? V : never : never
{ "end_byte": 1703, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferTypeConstraintInstantiationCircularity.ts" }
TypeScript/tests/cases/compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts_0_410
// @noEmit: true // https://github.com/microsoft/TypeScript/issues/2185 function test1() { for (let v; ; ) { var v; } } function test2() { for (let v in []) { var v; } } function test3() { for (let v of []) { var v; } } function test4() { { let x; { var x; } } } function test5() { { { var x; } let x; } }
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts" }
TypeScript/tests/cases/compiler/letDeclarations-invalidContexts.ts_0_424
// @allowUnreachableCode: true // @target: ES6 // Errors, let must be defined inside a block if (true) let l1 = 0; else let l2 = 0; while (true) let l3 = 0; do let l4 = 0; while (true); var obj; with (obj) let l5 = 0; for (var i = 0; i < 10; i++) let l6 = 0; for (var i2 in {}) let l7 = 0; if (true) label: let l8 = 0; while (false) label2: label3: label4: let l9 = 0;
{ "end_byte": 424, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-invalidContexts.ts" }
TypeScript/tests/cases/compiler/ClassDeclaration15.ts_0_42
class C { foo(); constructor() { } }
{ "end_byte": 42, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ClassDeclaration15.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability30.ts_0_338
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 aa:{one:number[];};; export var __val__aa = aa; } __test2__.__val__aa = __test1__.__val__obj4
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability30.ts" }
TypeScript/tests/cases/compiler/stringLiteralObjectLiteralDeclaration1.ts_0_71
// @declaration: true module m1 { export var n = { 'foo bar': 4 }; }
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringLiteralObjectLiteralDeclaration1.ts" }
TypeScript/tests/cases/compiler/classExtensionNameOutput.ts_0_93
class A {} if (true) { class B extends A {} const foo = function () { new B(); } }
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtensionNameOutput.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInMethod2.ts_0_153
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1<X, Y, Z>() { var a: X; var b: Z; a; b; } }
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInMethod2.ts" }
TypeScript/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.ts_0_318
// @allowJs: true // @checkJs: true // @outDir: ./out // @filename: checkJsdocTypeTagOnExportAssignment3.js // @Filename: a.js /** * @typedef {Object} Foo * @property {boolean} a * @property {boolean} b */ const bar = { c: 1 }; /** @type {Foo} */ export default bar; // @Filename: b.js import a from "./a"; a;
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.ts" }
TypeScript/tests/cases/compiler/restParamModifier.ts_0_56
class C { constructor(...public rest: string[]) {} }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParamModifier.ts" }
TypeScript/tests/cases/compiler/substitutionTypeForNonGenericIndexedAccessType.ts_0_125
// @strict: true // @noEmit: true interface A {} type B = A extends Record<'foo', string> ? A['foo'] : string; // no error
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/substitutionTypeForNonGenericIndexedAccessType.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInConstructor2_Js.ts_0_247
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js class A { /** * Constructor * * @param {object} [foo={}] */ constructor(foo = {}) { /** * @type object */ this["arguments"] = foo; } }
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInConstructor2_Js.ts" }
TypeScript/tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts_3_166
@target: es6 class TemplateStringsArray { } function f(x: TemplateStringsArray, y: number, z: number) { } f({}, 10, 10); f `abcdef${ 1234 }${ 5678 }ghijkl`;
{ "end_byte": 166, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts_0_300
// @declaration: true var { } = { x: 5, y: "hello" }; var { x4 } = { x4: 5, y4: "hello" }; var { y5 } = { x5: 5, y5: "hello" }; var { x6, y6 } = { x6: 5, y6: "hello" }; var { x7: a1 } = { x7: 5, y7: "hello" }; var { y8: b1 } = { x8: 5, y8: "hello" }; var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
{ "end_byte": 300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationInAmbientModule2.ts_0_465
// @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; } } } // @filename: main.ts /// <reference path="O.d.ts" /> import {Observable} from "Observable"; import "Map"; let x: Observable; x.foo().x;
{ "end_byte": 465, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationInAmbientModule2.ts" }
TypeScript/tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.ts_0_476
interface A { x: number } declare function isA(a: unknown): a is A; type FunctionsObj<T> = { [K in keyof T]: () => unknown } function g< T extends FunctionsObj<T>, M extends keyof T >(a2: ReturnType<T[M]>, x: A) { x = a2; } // Original CFA report of the above issue function g2< T extends FunctionsObj<T>, M extends keyof T >(a2: ReturnType<T[M]>) { if (isA(a2)) { // a2 is not narrowed a2.x // error, but should be ok } }
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.ts" }
TypeScript/tests/cases/compiler/implicitConstParameters.ts_0_969
// @strictNullChecks: true function doSomething(cb: () => void) { cb(); } function fn(x: number | string) { if (typeof x === 'number') { doSomething(() => x.toFixed()); } } function f1(x: string | undefined) { if (!x) { return; } doSomething(() => x.length); } function f2(x: string | undefined) { if (x) { doSomething(() => { doSomething(() => x.length); }); } } function f3(x: string | undefined) { inner(); function inner() { if (x) { doSomething(() => x.length); } } } function f4(x: string | undefined) { x = "abc"; if (x) { doSomething(() => x.length); } } function f5(x: string | undefined) { if (x) { doSomething(() => x.length); } x = "abc"; // causes x to be considered non-const } function f6(x: string | undefined) { const y = x || ""; if (x) { doSomething(() => y.length); } }
{ "end_byte": 969, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitConstParameters.ts" }
TypeScript/tests/cases/compiler/silentNeverPropagation.ts_0_568
// @strict: true // @declaration: true // Repro from #45041 type ModuleWithState<TState> = { state: TState; }; type State = { a: number; }; type MoreState = { z: string; }; declare function createModule<TState, TActions>(state: TState, actions: TActions): ModuleWithState<TState> & TActions; declare function convert<TState, TActions>(m: ModuleWithState<TState> & TActions): ModuleWithState<TState & MoreState> & TActions; const breaks = convert( createModule({ a: 12 }, { foo() { return true } }) ); breaks.state.a breaks.state.z breaks.foo()
{ "end_byte": 568, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/silentNeverPropagation.ts" }
TypeScript/tests/cases/compiler/conflictingDeclarationsImportFromNamespace2.ts_0_694
// @strict: true // @filename: node_modules/@types/lodash/object.d.ts import _ = require("./index"); declare module "./index" { interface LoDashStatic { pick: <T extends object, U extends keyof T>( object: T, ...props: Array<U> ) => Pick<T, U>; } } // @filename: node_modules/@types/lodash/pick.d.ts import { pick } from "./index"; export = pick; // @filename: node_modules/@types/lodash/index.d.ts /// <reference path="./object.d.ts" /> export = _; export as namespace _; declare const _: _.LoDashStatic; declare namespace _ { interface LoDashStatic {} } // @filename: index.ts import * as pick from 'lodash/pick'; export const pick = () => pick();
{ "end_byte": 694, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictingDeclarationsImportFromNamespace2.ts" }
TypeScript/tests/cases/compiler/moduleAssignmentCompat1.ts_0_137
module A { export class C { } } module B { export class C { } class D { } } var a: A; var b: B; // no error a = b; b = a;
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAssignmentCompat1.ts" }
TypeScript/tests/cases/compiler/moduleKeywordRepeatError.ts_0_69
// "module.module { }" should raise a syntax error module.module { }
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleKeywordRepeatError.ts" }
TypeScript/tests/cases/compiler/numericIndexerConstraint.ts_0_51
class C { 0: number; [x: number]: RegExp; }
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericIndexerConstraint.ts" }
TypeScript/tests/cases/compiler/largeTupleTypes.ts_0_1166
// @strict: true // @noEmit: true // Repro from #54491 type UnshiftTuple<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? Tail : never; type ExpandSmallerTuples<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? T | ExpandSmallerTuples<Tail> : []; type Shift<A extends Array<any>> = ((...args: A) => void) extends (...args: [A[0], ...infer R]) => void ? R : never; type GrowExpRev<A extends Array<any>, N extends number, P extends Array<Array<any>>> = A['length'] extends N ? A : GrowExpRev<[...A, ...P[0]][N] extends undefined ? [...A, ...P[0]] : A, N, Shift<P>>; type GrowExp<A extends Array<any>, N extends number, P extends Array<Array<any>>> = [...A, ...A][N] extends undefined ? GrowExp<[...A, ...A], N, [A, ...P]> : GrowExpRev<A, N, P>; type Tuple<T, N extends number> = number extends N ? Array<T> : N extends 0 ? [] : N extends 1 ? [T] : GrowExp<[T], N, [[]]>; declare class ArrayValidator<T extends unknown[], I = T[number]> { lengthRange<S extends number, E extends number>(start: S, endBefore: E): ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>]>>>>; }
{ "end_byte": 1166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/largeTupleTypes.ts" }
TypeScript/tests/cases/compiler/funduleUsedAcrossFileBoundary.ts_0_381
// @Filename: funduleUsedAcrossFileBoundary_file1.ts declare function Q<T>(value: T): string; declare module Q { interface Promise<T> { foo: string; } export function defer<T>(): string; } // @Filename: funduleUsedAcrossFileBoundary_file2.ts function promiseWithCancellation<T>(promise: Q.Promise<T>) { var deferred = Q.defer<T>(); // used to be an error }
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/funduleUsedAcrossFileBoundary.ts" }
TypeScript/tests/cases/compiler/commonSourceDir2.ts_0_102
// @outDir: A:/ // @Filename: A:/foo/bar.ts var x: number; // @Filename: B:/foo/baz.ts var y: number;
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonSourceDir2.ts" }
TypeScript/tests/cases/compiler/destructuringControlFlowNoCrash.ts_1_306
// legal JS, if nonsensical, which also triggers the issue const { date, } = (inspectedElement: any) => 0; date.toISOString(); // Working flow code const { date2, } = (inspectedElement: any).props; date2.toISOString(); // It could also be an async function const { constructor } = async () => {};
{ "end_byte": 306, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringControlFlowNoCrash.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndAmbientClassInGlobal.ts_0_109
declare class _this { // no error - as no code generation } var f = () => this; var a = new _this(); // Error
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndAmbientClassInGlobal.ts" }