_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/codeFixSpellingJs3.ts_0_422
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @filename: a.js //// class Classe { //// non = 'oui' //// methode() { //// // no error on 'this' references //// return this.none //// } //// } //// class Derivee extends Classe { //// methode() { //// // no error on 'super' references //// return super.none //// } //// } verify.noErrors()
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs3.ts" }
TypeScript/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts_0_416
/// <reference path="fourslash.ts" /> //// function f<x, x>() { } //// function f2<X, X>(b: X): X { return null; } //// class C<X> { //// public f<x, x>() {} //// f2<X>(b): X { return null; } //// } //// //// interface I<X, X> { //// f<X/*addTypeParam*/>(); //// f2<X>(/*addParam*/a: X): X; //// } //// goTo.marker('addParam'); edit.insert(", X"); goTo.marker('addTypeParam'); edit.insert(", X");
{ "end_byte": 416, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts" }
TypeScript/tests/cases/fourslash/indexerReturnTypes1.ts_0_1834
/// <reference path='fourslash.ts'/> ////interface Numeric { //// [x: number]: Date; ////} ////} ////interface Stringy { //// [x: string]: RegExp; ////} ////} ////interface NumericPlus { //// [x: number]: Date; //// foo(): Date; ////} ////} ////interface StringyPlus { //// [x: string]: RegExp; //// foo(): RegExp; ////} ////} ////interface NumericG<T> { //// [x: number]: T; ////} ////} ////interface StringyG<T> { //// [x: string]: T; ////} ////} ////interface Ty<T> { //// [x: number]: Ty<T>; ////} ////interface Ty2<T> { //// [x: number]: { [x: number]: T }; ////} //// //// ////} ////var numeric: Numeric; ////var stringy: Stringy; ////var numericPlus: NumericPlus; ////var stringPlus: StringyPlus; ////var numericG: NumericG<Date>; ////var stringyG: StringyG<Date>; ////var ty: Ty<Date>; ////var ty2: Ty2<Date>; //// ////var /*1*/r1 = numeric[1]; ////var /*2*/r2 = numeric['1']; ////var /*3*/r3 = stringy[1]; ////var /*4*/r4 = stringy['1']; ////var /*5*/r5 = numericPlus[1]; ////var /*6*/r6 = numericPlus['1']; ////var /*7*/r7 = stringPlus[1]; ////var /*8*/r8 = stringPlus['1']; ////var /*9*/r9 = numericG[1]; ////var /*10*/r10 = numericG['1']; ////var /*11*/r11 = stringyG[1]; ////var /*12*/r12 = stringyG['1']; ////var /*13*/r13 = ty[1]; ////var /*14*/r14 = ty['1']; ////var /*15*/r15 = ty2[1]; ////var /*16*/r16 = ty2['1']; verify.quickInfos({ 1: "var r1: Date", 2: "var r2: Date", 3: "var r3: RegExp", 4: "var r4: RegExp", 5: "var r5: Date", 6: "var r6: Date", 7: "var r7: RegExp", 8: "var r8: RegExp", 9: "var r9: Date", 10: "var r10: Date", 11: "var r11: Date", 12: "var r12: Date", 13: "var r13: Ty<Date>", 14: "var r14: Ty<Date>", 15: "var r15: {\n [x: number]: Date;\n}", 16: "var r16: {\n [x: number]: Date;\n}" });
{ "end_byte": 1834, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indexerReturnTypes1.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_typeOnly2.ts_0_387
/// <reference path="fourslash.ts" /> // @importsNotUsedAsValues: error // @Filename: types.ts ////export class A {} // @Filename: index.ts ////const a: A = new A(); goTo.file("index.ts"); verify.codeFixAll({ fixAllDescription: ts.Diagnostics.Add_all_missing_imports.message, fixId: "fixMissingImport", newFileContent: `import { A } from "./types"; const a: A = new A();` });
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_typeOnly2.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesReadonly3.ts_0_313
/// <reference path="fourslash.ts" /> ////class C { //// [|readonly|] prop: /**/readonly string[] = []; //// constructor([|readonly|] prop2: string) { //// class D { //// readonly prop: string = ""; //// } //// } ////} verify.baselineDocumentHighlights(); verify.baselineDocumentHighlights("");
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReadonly3.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts_0_381
/// <reference path="fourslash.ts" /> // @Filename: a/f1.ts //// [|foo/*0*/();|] // @Filename: b/c/f2.ts //// export function foo() {}; // @Filename: tsconfig.json //// { //// "compilerOptions": { //// "rootDirs": [ //// "a", //// "b/c" //// ] //// } //// } verify.importFixAtPosition([ `import { foo } from "./f2"; foo();` ]);
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts" }
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts_0_290
/// <reference path='fourslash.ts'/> ////class Foo { //// public _bar; //// /*1*/public /*2*/__bar; //// public ___bar; //// public ____bar; ////} //// ////var x: Foo; ////x._bar; ////x./*3*/__bar; ////x.___bar; ////x.____bar; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts" }
TypeScript/tests/cases/fourslash/jsdocOverloadTagCompletion.ts_0_192
///<reference path="fourslash.ts" /> // @allowJS: true // @checkJs: true // @filename: /a.js /////** //// * @/**/ //// */ verify.completions( { marker: "", includes: ["overload"] }, );
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocOverloadTagCompletion.ts" }
TypeScript/tests/cases/fourslash/completionListAfterStringLiteral1.ts_0_484
/// <reference path="fourslash.ts" /> ////"a"./**/ verify.completions({ marker: "", unsorted: [ "toString", "charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "localeCompare", "match", "replace", "search", "slice", "split", "substring", "toLowerCase", "toLocaleLowerCase", "toUpperCase", "toLocaleUpperCase", "trim", "length", { name: "substr", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) }, "valueOf", ], });
{ "end_byte": 484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterStringLiteral1.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_nodeModuleDirectoryCase.ts_0_273
/// <reference path='fourslash.ts' /> // @Filename: /a/b/file1.ts ////import { foo } from "foo"; // @Filename: /a/node_modules/foo/index.d.ts ////export const foo = 0; verify.getEditsForFileRename({ oldPath: "/a/b", newPath: "/a/B", newFileContents: {}, });
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_nodeModuleDirectoryCase.ts" }
TypeScript/tests/cases/fourslash/importTypeCompletions1.ts_0_631
/// <reference path="fourslash.ts" /> // @target: esnext // @filename: /foo.ts ////export interface Foo {} // @filename: /bar.ts ////[|import type F/**/|] goTo.file("/bar.ts") verify.completions({ marker: "", exact: [{ name: "Foo", sourceDisplay: "./foo", source: "./foo", insertText: "import type { Foo } from \"./foo\";", replacementSpan: test.ranges()[0] }], isNewIdentifierLocation: true, preferences: { includeCompletionsForModuleExports: true, includeCompletionsForImportStatements: true, includeCompletionsWithInsertText: true } });
{ "end_byte": 631, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions1.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionShorthandProperty06.ts_0_195
/// <reference path="./fourslash.ts"/> ////interface Foo { //// /*2*/foo(): void ////} ////const foo = 1; ////let x: Foo = { //// [|f/*1*/oo|]() ////} verify.baselineGoToDefinition("1");
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionShorthandProperty06.ts" }
TypeScript/tests/cases/fourslash/codeFixExpectedComma02.ts_0_286
/// <reference path='fourslash.ts' /> ////class C { //// const example = [|["one"; "two"]|] ////} verify.codeFixAvailable([ { description: `Change ';' to ','` } ]); verify.codeFix({ description: "Change ';' to ','", index: 0, newRangeContent: `["one", "two"]`, });
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixExpectedComma02.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember1.ts_0_477
/// <reference path="fourslash.ts" /> // @module: esnext // @filename: /a.ts ////declare function foo(): any ////declare function bar(): any; ////export { foo }; // @filename: /b.ts ////import { bar } from "./a"; goTo.file("/b.ts"); verify.codeFix({ description: [ts.Diagnostics.Export_0_from_module_1.message, "bar", "./a"], index: 0, newFileContent: { "/a.ts": `declare function foo(): any declare function bar(): any; export { foo, bar };`, } });
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember1.ts" }
TypeScript/tests/cases/fourslash/completionsStringCommitCharacter.ts_0_170
/// <reference path="fourslash.ts" /> // @Filename: file1.ts //// const a: "aa" | "bb" = "/**/" verify.baselineCompletions({ includeInsertTextCompletions: true, });
{ "end_byte": 170, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsStringCommitCharacter.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags9.ts_0_332
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags9.js /////** //// * @typedef {{ [x: string]: any, y: number }} Foo //// */ //// /////** //// * @type {(t: T) => number} //// * @template {Foo} T Comment Text //// */ ////const /**/foo = t => t.y; verify.baselineQuickInfo();
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags9.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageGetter.ts_0_208
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////declare class C { //// [|get x();|] ////} ////} ////(new C).x = 1; verify.rangeAfterCodeFix("get x(): number;", undefined, undefined, 0);
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageGetter.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputOutFile.ts_0_433
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputOutFile.baseline // @declaration: true // @outFile: outFile.js // @Filename: inputFile1.ts // @emitThisFile: true //// var x: number = 5; //// class Bar { //// x : string; //// y : number //// } // @Filename: inputFile2.ts //// var x1: string = "hello world"; //// class Foo{ //// x : string; //// y : number; //// } verify.baselineGetEmitOutput();
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputOutFile.ts" }
TypeScript/tests/cases/fourslash/formattingEqualsBeforeBracketInTypeAlias.ts_0_158
/// <reference path='fourslash.ts'/> ////type X = [number]/*1*/ goTo.marker("1"); edit.insert(";"); verify.currentLineContentIs("type X = [number];");
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingEqualsBeforeBracketInTypeAlias.ts" }
TypeScript/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts_0_291
/// <reference path='fourslash.ts' /> ////function Foo(arg1: string, arg2: string) { ////} //// ////Foo(/**/; verify.signatureHelp({ marker: "", text: "Foo(arg1: string, arg2: string): void", parameterCount: 2, parameterName: "arg1", parameterSpan: "arg1: string", });
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts_0_196
/// <reference path='fourslash.ts' /> //// function foo(strs, ...rest) { //// } //// //// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}`/*4*/ /*5*/ verify.noSignatureHelp(...test.markerNames());
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts" }
TypeScript/tests/cases/fourslash/autoImportTypeImport4.ts_0_3692
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @target: esnext // @Filename: /exports1.ts //// export const a = 0; //// export const A = 1; //// export const b = 2; //// export const B = 3; //// export const c = 4; //// export const C = 5; //// export type x = 6; //// export const X = 7; //// export const Y = 8; //// export const Z = 9; // @Filename: /exports2.ts //// export const d = 0; //// export const D = 1; //// export const e = 2; //// export const E = 3; // @Filename: /index0.ts //// import { A, B, C } from "./exports1"; //// a/*0*//*0a*/; //// b; // @Filename: /index1.ts //// import { A, B, C, type Y, type Z } from "./exports1"; //// a/*1*//*1a*//*1b*//*1c*/; //// b; // @Filename: /index2.ts //// import { A, a, B, b, type Y, type Z } from "./exports1"; //// import { E } from "./exports2"; //// d/*2*//*2a*//*2b*//*2c*/ // addition of correctly sorted type imports should not affect behavior as shown in autoImportSortCaseSensitivity1.ts goTo.marker("0"); verify.importFixAtPosition([ `import { a, A, B, C } from "./exports1";\na;\nb;`, `import { A, b, B, C } from "./exports1";\na;\nb;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); goTo.marker("0a"); verify.importFixAtPosition([ `import { a, A, B, C } from "./exports1";\na;\nb;`, `import { A, b, B, C } from "./exports1";\na;\nb;` ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); goTo.marker("1"); verify.importFixAtPosition([ `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); goTo.marker("1a"); verify.importFixAtPosition([ `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;` ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); goTo.marker("1b"); // if we sort inline and sensitive, then all upper case imports should be sorted before any lower case imports verify.importFixAtPosition([ `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "inline" }); goTo.marker("1c"); verify.importFixAtPosition([ `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;` ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" }); goTo.marker("2"); verify.importFixAtPosition([ `import { A, a, B, b, type Y, type Z } from "./exports1"; import { d, E } from "./exports2"; d`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); goTo.marker("2a"); verify.importFixAtPosition([ `import { A, a, B, b, type Y, type Z } from "./exports1"; import { E, d } from "./exports2"; d` ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: false, organizeImportsTypeOrder : "last" }); goTo.marker("2b"); verify.importFixAtPosition([ `import { A, a, B, b, type Y, type Z } from "./exports1"; import { d, E } from "./exports2"; d`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); goTo.marker("2c"); verify.importFixAtPosition([ `import { A, a, B, b, type Y, type Z } from "./exports1"; import { E, d } from "./exports2"; d` ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: false, organizeImportsTypeOrder : "last" });
{ "end_byte": 3692, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeImport4.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectPropertyShorthandParameter.ts_0_470
/// <reference path='fourslash.ts' /> // @noImplicitThis: true ////function returnThisMember([| |]suffix: string) { //// return this.member + suffix; //// } //// //// interface Container { //// member: string; //// returnThisMember(suffix: string): string; //// } //// //// const container: Container = { //// member: "sample", //// returnThisMember, //// }; //// //// container.returnThisMember(""); verify.rangeAfterCodeFix("this: Container, ");
{ "end_byte": 470, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectPropertyShorthandParameter.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports2.ts_0_430
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true ////const a = 42; ////const b = 43; ////export function foo() { return a + b; } verify.codeFixAvailable([ { description: "Add return type 'number'" } ]); verify.codeFix({ description: "Add return type 'number'", index: 0, newFileContent: `const a = 42; const b = 43; export function foo(): number { return a + b; }`, });
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports2.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties1.ts_0_646
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true //// interface I { //// a?: number //// } //// interface J { //// a?: number | undefined //// } //// declare var i: I //// declare var j: J //// i/**/ = j verify.codeFixAvailable([ { description: ts.Diagnostics.Add_undefined_to_optional_property_type.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message, index: 0, newFileContent: `interface I { a?: number | undefined } interface J { a?: number | undefined } declare var i: I declare var j: J i = j`, });
{ "end_byte": 646, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties1.ts" }
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter7.ts_0_330
/// <reference path="fourslash.ts" /> ////interface Foo { //// one: string; //// two: { //// three: number; //// } ////} //// ////interface Bar<T extends Foo> { //// foo: T; ////} //// ////var foobar: Bar<{ //// two: {/**/ verify.completions({ marker: "", exact: "three", isNewIdentifierLocation: true });
{ "end_byte": 330, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter7.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionClassStaticBlocks.ts_0_367
/// <reference path='fourslash.ts' /> ////class ClassStaticBocks { //// static x; //// [|/*classStaticBocks1*/static|] {} //// static y; //// [|/*classStaticBocks2*/static|] {} //// static y; //// [|/*classStaticBocks3*/static|] {} ////} verify.baselineGoToDefinition( "classStaticBocks1", "classStaticBocks2", "classStaticBocks3", );
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionClassStaticBlocks.ts" }
TypeScript/tests/cases/fourslash/exportInObjectLiteral.ts_0_213
/// <reference path="fourslash.ts" /> // @Filename: a.ts //// const k = { //// [|export|] f() { } //// } verify.baselineDocumentHighlights(test.ranges()[0], { filesToSearch: [test.ranges()[0].fileName] });
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportInObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral_details.ts_0_955
/// <reference path="fourslash.ts" /> // @Filename: /other.ts ////export const x = 0; // @Filename: /a.ts ////import {} from ".//*path*/"; //// ////const x: "a" = "[|/*type*/|]"; //// ////interface I { //// /** Prop doc */ //// x: number; //// /** Method doc */ //// m(): void; ////} ////declare const o: I; ////o["[|/*prop*/|]"]; verify.completions( { marker: "path", includes: { name: "other", text: "other", kind: "script", kindModifiers: ".ts" }, isNewIdentifierLocation: true }, { marker: "type", exact: { name: "a", text: "a", kind: "string", replacementSpan: test.ranges()[0] } }, { marker: "prop", exact: [ { name: "m", text: "(method) I.m(): void", documentation: "Method doc", kind: "method", replacementSpan: test.ranges()[1] }, { name: "x", text: "(property) I.x: number", documentation: "Prop doc", kind: "property", replacementSpan: test.ranges()[1] }, ], }, );
{ "end_byte": 955, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_details.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalInitialIdentifier.ts_0_380
/// <reference path='fourslash.ts' /> ////let a = { b: 0 }; /////*a*/a ? a.b : "whenFalse";/*b*/ goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert to optional chain expression", actionName: "Convert to optional chain expression", actionDescription: "Convert to optional chain expression", newContent: `let a = { b: 0 }; a?.b ?? "whenFalse";` });
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalInitialIdentifier.ts" }
TypeScript/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts_0_328
/// <reference path="./fourslash.ts" /> ////interface IFoo { //// /*1*/a: string; ////} ////class C<T extends IFoo> { //// method() { //// var x: T = { //// a: "" //// }; //// x.a; //// } ////} //// //// ////var x: IFoo = { //// a: "ss" ////}; verify.baselineFindAllReferences('1')
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember3.ts_0_240
/// <reference path="./fourslash.ts"/> // @noImplicitOverride: true ////abstract class Foo { //// abstract /*2*/m() {} ////} //// ////export class Bar extends Foo { //// [|/*1*/override|] m() {} ////} verify.baselineGoToDefinition("1");
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember3.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc1.ts_0_130
/// <reference path='fourslash.ts' /> /////** */ /////*/**/ ////function foo() {} verify.docCommentTemplateAt("", 3, "/** */");
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc1.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports18.ts_0_460
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true //// function foo() { return 42; } //// export class A { //// readonly a = () => foo(); //// } verify.codeFixAvailable([ { description: "Add return type 'number'" }, ]); verify.codeFix({ description: "Add return type 'number'", index: 0, newFileContent: `function foo() { return 42; } export class A { readonly a = (): number => foo(); }` });
{ "end_byte": 460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports18.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_shadowing.ts_0_297
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const mod = require("mod"); ////const x = 0; ////mod.x(x); verify.codeFix({ description: "Convert to ES module", newFileContent: `import { x as _x } from "mod"; const x = 0; _x(x);`, });
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_shadowing.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion3.ts_0_360
/// <reference path='fourslash.ts'/> //// declare const fn: //// | ((a: { x: number }, b: { x: number }) => number) //// | ((...a: { y: number }[]) => number); //// //// /**/fn(); verify.quickInfoAt( "", `const fn: (a: { x: number; } & { y: number; }, b: { x: number; } & { y: number; }, ...args: { y: number; }[]) => number`, );
{ "end_byte": 360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion3.ts" }
TypeScript/tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts_0_2645
/// <reference path='fourslash.ts' /> ////function foo(...args: [string, string] | [number, string, string] ////) { //// ////} //// ////foo(123/*1*/,) ////foo(""/*2*/, ""/*3*/) ////foo(123/*4*/, ""/*5*/, ) ////foo(123/*6*/, ""/*7*/, ""/*8*/) verify.signatureHelp( { marker: "1", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_0", parameterSpan: "args_0: number", isVariadic: false, overrideSelectedItemIndex: 1 }, { marker: "2", text: "foo(args_0: string, args_1: string): void", overloadsCount: 2, parameterCount: 2, parameterName: "args_0", parameterSpan: "args_0: string", isVariadic: false, overrideSelectedItemIndex: 0 }, { marker: "3", text: "foo(args_0: string, args_1: string): void", overloadsCount: 2, parameterCount: 2, parameterName: "args_1", parameterSpan: "args_1: string", isVariadic: false, overrideSelectedItemIndex: 0 }, { marker: "4", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_0", parameterSpan: "args_0: number", isVariadic: false, overrideSelectedItemIndex: 1 }, { marker: "5", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_1", parameterSpan: "args_1: string", isVariadic: false, overrideSelectedItemIndex: 1 }, { marker: "6", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_0", parameterSpan: "args_0: number", isVariadic: false, overrideSelectedItemIndex: 1 }, { marker: "7", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_1", parameterSpan: "args_1: string", isVariadic: false, overrideSelectedItemIndex: 1 }, { marker: "8", text: "foo(args_0: number, args_1: string, args_2: string): void", overloadsCount: 2, parameterCount: 3, parameterName: "args_2", parameterSpan: "args_2: string", isVariadic: false, overrideSelectedItemIndex: 1 }, );
{ "end_byte": 2645, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts" }
TypeScript/tests/cases/fourslash/renameTemplateLiteralsDefinePropertyJs.ts_0_371
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js ////let obj = {}; //// ////Object.defineProperty(obj, `[|prop|]`, { value: 0 }); //// ////obj = { //// [|[`[|{| "contextRangeIndex": 1 |}prop|]`]: 1|] ////}; //// ////obj.[|prop|]; ////obj['[|prop|]']; ////obj["[|prop|]"]; ////obj[`[|prop|]`]; verify.baselineRenameAtRangesWithText('prop');
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameTemplateLiteralsDefinePropertyJs.ts" }
TypeScript/tests/cases/fourslash/importMetaCompletionDetails.ts_0_327
/// <reference path="fourslash.ts" /> // @filename: index.mts // @module: Node16 // @strict: true //// let x = import.meta/**/; verify.completions({ marker: "", includes: [ { name: "meta", text: "(property) ImportMetaExpression.meta: ImportMeta", }, ] }) verify.noErrors();
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importMetaCompletionDetails.ts" }
TypeScript/tests/cases/fourslash/unusedVariableInClass2.ts_0_296
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////class greeter { //// [|public greeting1; //// private greeting: string;|] ////} verify.codeFix({ description: "Remove unused declaration for: 'greeting'", index: 0, newRangeContent: "public greeting1;\n", });
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInClass2.ts" }
TypeScript/tests/cases/fourslash/findAllRefsTypedef_importType.ts_0_296
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js ////module.exports = 0; /////** /*1*/@typedef {number} /*2*/Foo */ ////const dummy = 0; // @Filename: /b.js /////** @type {import('./a')./*3*/Foo} */ ////const x = 0; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsTypedef_importType.ts" }
TypeScript/tests/cases/fourslash/completionsImport_46332.ts_0_2208
/// <reference path="fourslash.ts" /> // @module: esnext // @moduleResolution: node // @Filename: /node_modules/vue/package.json //// { //// "name": "vue", //// "types": "dist/vue.d.ts" //// } // @Filename: /node_modules/vue/dist/vue.d.ts //// export * from "@vue/runtime-dom" // @Filename: /node_modules/@vue/runtime-dom/package.json //// { //// "name": "@vue/runtime-dom", //// "types": "dist/runtime-dom.d.ts" //// } // @Filename: /node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts //// export * from "@vue/runtime-core"; //// export {} //// declare module '@vue/reactivity' { //// export interface RefUnwrapBailTypes { //// runtimeDOMBailTypes: any //// } //// } // @Filename: /node_modules/@vue/runtime-core/package.json //// { //// "name": "@vue/runtime-core", //// "types": "dist/runtime-core.d.ts" //// } // @Filename: /node_modules/@vue/runtime-core/dist/runtime-core.d.ts //// import { ref } from '@vue/reactivity'; //// export { ref }; //// declare module '@vue/reactivity' { //// export interface RefUnwrapBailTypes { //// runtimeCoreBailTypes: any //// } //// } // @Filename: /node_modules/@vue/reactivity/package.json //// { //// "name": "@vue/reactivity", //// "types": "dist/reactivity.d.ts" //// } // @Filename: /node_modules/@vue/reactivity/dist/reactivity.d.ts //// export declare function ref<T = any>(): T; // @Filename: /package.json //// { //// "dependencies": { //// "vue": "*" //// } //// } // @Filename: /index.ts //// import {} from "vue"; //// ref/**/ verify.completions({ marker: "", includes: [{ name: "ref", source: "vue", sourceDisplay: "vue", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }], preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, }); verify.applyCodeActionFromCompletion("", { name: "ref", source: "vue", description: `Update import from "vue"`, data: { exportName: "ref", fileName: "/node_modules/vue/dist/vue.d.ts", }, preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, newFileContent: `import { ref } from "vue";\nref` });
{ "end_byte": 2208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_46332.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesJsRequireDestructuring.ts_0_274
/// <reference path="fourslash.ts" /> // @allowJs: true // @noEmit: true // @checkJs: true // @Filename: foo.js //// module.exports = { //// foo: '1' //// }; // @Filename: bar.js //// const { /*1*/foo: bar } = require('./foo'); verify.baselineFindAllReferences("1");
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesJsRequireDestructuring.ts" }
TypeScript/tests/cases/fourslash/editLambdaArgToTypeParameter1.ts_0_276
/// <reference path='fourslash.ts'/> ////class C<T> { //// foo(x: T) { //// return (a: number/*1*/) => x; //// } ////} /////*2*/ goTo.marker('1'); edit.backspace(6); edit.insert('T'); verify.noErrors(); goTo.marker('2'); edit.insertLine(''); verify.noErrors();
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/editLambdaArgToTypeParameter1.ts" }
TypeScript/tests/cases/fourslash/renameFunctionParameter2.ts_0_174
/// <reference path="fourslash.ts" /> /////** //// * @param {number} p //// */ ////const foo = function foo(p/**/) { //// return p; ////} verify.baselineRename("", {});
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameFunctionParameter2.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts_0_349
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// abstract class A { //// abstract x: number; //// abstract y: number; //// abstract z: number; //// } //// //// class C extends A {[| //// |]constructor(public x: number) { super(); } //// y: number; //// } verify.rangeAfterCodeFix(` override z: number; `);
{ "end_byte": 349, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization9.ts_0_236
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// a: 1 | 2; //// } verify.codeFix({ description: `Add initializer to property 'a'`, newFileContent: `class T { a: 1 | 2 = 1; }`, index: 2 })
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization9.ts" }
TypeScript/tests/cases/fourslash/navigateToQuoted.ts_0_753
/// <reference path="fourslash.ts" /> // @noLib: true ////class C { //// [|["foo-bar"]() {}|] //// [|["foo bar"]() {}|] ////} const [r0, r1] = test.ranges(); const dash: FourSlashInterface.ExpectedNavigateToItem = { name: "foo-bar", kind: "method", range: r0, containerName: "C", containerKind: "class" }; const space: FourSlashInterface.ExpectedNavigateToItem = { name: "foo bar", kind: "method", range: r1, containerName: "C", containerKind: "class" }; verify.navigateTo( { pattern: "foo-bar", expected: [dash, { ...space, matchKind: "prefix" }], }, { pattern: "foo bar", // TODO: GH#23035 expected: [{ ...space, matchKind: "prefix" }, { ...dash, matchKind: "prefix" }], }, );
{ "end_byte": 753, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigateToQuoted.ts" }
TypeScript/tests/cases/fourslash/completionListOnMethodParameterName.ts_0_220
/// <reference path="fourslash.ts" /> ////class A { //// foo(nu/**/: number) { //// } ////} // Completion list shouldn't be present in argument name position verify.completions({ marker: "", exact: undefined });
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnMethodParameterName.ts" }
TypeScript/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts_0_341
/// <reference path='fourslash.ts'/> ////module SwitchTest { //// var a = 3; //// //// if (a == 5) { //// switch (a) { //// case 1: //// if (a == 5) { //// /**/ //// } //// break; //// } //// } ////} goTo.marker(); verify.indentationIs(20);
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts" }
TypeScript/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts_0_190
///<reference path="fourslash.ts"/> ////class Foo { } ////new/*1*/ Foo ////new /*2*/Foo(/*3*/) verify.noSignatureHelp("1", "2"); verify.signatureHelp({ marker: "3", text: "Foo(): Foo" });
{ "end_byte": 190, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts" }
TypeScript/tests/cases/fourslash/jsDocServices.ts_0_783
///<reference path="fourslash.ts" /> // Note: We include the word "foo" in the documentation to test for a bug where // the `.getChildren()` of the JSDocParameterTag included an identifier at that position with no '.text'. ////interface /*I*/I {} //// /////** //// * @param /*use*/[|foo|] I pity the foo //// */ ////function f([|[|/*def*/{| "contextRangeIndex": 1 |}foo|]: I|]) { //// return /*use2*/[|foo|]; ////} const [r0, r1Def, r1, r2] = test.ranges(); const ranges = [r0, r1, r2]; goTo.marker("use"); verify.quickInfoIs("(parameter) foo: I", "I pity the foo"); verify.baselineFindAllReferences("use", "def", "use2"); verify.baselineRename(ranges); verify.baselineDocumentHighlights(ranges); verify.baselineGoToType("use"); verify.baselineGetDefinitionAtPosition("use");
{ "end_byte": 783, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocServices.ts" }
TypeScript/tests/cases/fourslash/findAllRefsJsThisPropertyAssignment2.ts_0_669
/// <reference path="fourslash.ts" /> // @allowJs: true // @noImplicitThis: true // @Filename: infer.d.ts //// export declare function infer(o: { m: Record<string, Function> } & ThisType<{ x: number }>): void; // @Filename: a.js //// import { infer } from "./infer"; //// infer({ //// m: { //// initData() { //// this.x = 1; //// this./*1*/x; //// }, //// } //// }); // @Filename: b.ts //// import { infer } from "./infer"; //// infer({ //// m: { //// initData() { //// this.x = 1; //// this./*2*/x; //// }, //// } //// }); verify.baselineFindAllReferences("1", "2");
{ "end_byte": 669, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsThisPropertyAssignment2.ts" }
TypeScript/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts_3_555
/ <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// function /*pt1*/SFC1(prop: { x: number }) { //// return <div>hello </div>; //// }; //// function SFC2(prop: { x: boolean }) { //// return <h1>World </h1>; //// } //// var /*def*/SFCComp = SFC1 || SFC2; //// <[|SFC/*one*/Comp|] x /> verify.baselineGoToDefinition("one");
{ "end_byte": 555, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts_0_249
// @strict: true /// <reference path='fourslash.ts' /> //// var x = 12 as [|number?|]; verify.codeFix({ description: "Change 'number?' to 'number | undefined'", errorCode: 17019, index: 0, newRangeContent: "number | undefined", });
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts" }
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType13.ts_0_227
/// <reference path='fourslash.ts' /> ////function /*a*/f/*b*/(x: string): number; ////function f(x: string | number) { //// return 1; ////} goTo.select("a", "b"); verify.not.refactorAvailable("Infer function return type");
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType13.ts" }
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration05.ts_0_241
/// <reference path='fourslash.ts' /> ////function f<A,B,C>(a: A, b:B, c, d: C): { ////{| "indent": 4 |} //// test.markers().forEach(marker => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); });
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration05.ts" }
TypeScript/tests/cases/fourslash/organizeImports12.ts_0_298
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /test.js ////declare export default class A {} ////declare export { a, b }; ////declare export * from "foo"; verify.organizeImports( `declare export default class A {} declare export * from "foo"; declare export { a, b }; `);
{ "end_byte": 298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports12.ts" }
TypeScript/tests/cases/fourslash/refactorExtractTypeForTriggerReason1.ts_0_297
/// <reference path='fourslash.ts' /> //// var x: str/*a*//*b*/ing; // Only offer refactor for empty span if explicity requested goTo.select("a", "b"); verify.not.refactorAvailableForTriggerReason("implicit", "Extract type"); verify.refactorAvailableForTriggerReason("invoked", "Extract type");
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractTypeForTriggerReason1.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_module_existingCompilerOptionsInTsConfig.ts_0_517
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: number[]; ////for await (const _ of p); ////export {}; // @filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// "module": "es2015" //// } ////} verify.codeFix({ description: [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0.message, "esnext"], index: 0, newFileContent: { "/dir/tsconfig.json": `{ "compilerOptions": { "module": "esnext" } }` } });
{ "end_byte": 517, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_module_existingCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/completionListAtEOF2.ts_0_241
/// <reference path="fourslash.ts"/> ////module Shapes { //// export class Point { //// constructor(public x: number, public y: number) { } //// } ////} ////var p = <Shapes. goTo.eof(); verify.completions({ exact: "Point" });
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtEOF2.ts" }
TypeScript/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts_0_199
/// <reference path="fourslash.ts"/> ////var x = /*1*/"asd /////*2*/var y = 2; verify.errorExistsAfterMarker("1"); verify.not.errorExistsAfterMarker("2"); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts" }
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import11.ts_0_440
/// <reference path='fourslash.ts' /> // @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} ////export = foo; // @Filename: index.ts ////// Comment ////import * as foo from "./foo"; ////[|foo()|]; goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo from "./foo";'.`, newFileContent: `// Comment import foo from "./foo"; foo();`, index: 0, });
{ "end_byte": 440, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import11.ts" }
TypeScript/tests/cases/fourslash/moveToFile_reExports4.ts_0_464
/// <reference path='fourslash.ts' /> // @module: esnext //@Filename: /a.ts ////[|export function foo() { } ////export function bar() {}|] // @Filename: /b.ts ////export function baz() { } ////export { foo, bar } from "./a"; verify.moveToFile({ newFileContents: { "/a.ts": "", "/b.ts": `export function baz() { } export function foo() { } export function bar() { } `, }, interactiveRefactorArguments: { targetFile: "/b.ts" }, });
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_reExports4.ts" }
TypeScript/tests/cases/fourslash/findAllRefsImportMeta.ts_0_535
// @noLib: true /// <reference path='fourslash.ts'/> // @module: esnext // @Filename: foo.ts /////// <reference no-default-lib="true"/> /////// <reference path='./bar.d.ts' /> ////import./**/meta; ////import.[|meta|]; //@Filename: bar.d.ts ////interface ImportMeta { ////} // @Filename: baz.ts /////// <reference no-default-lib="true"/> /////// <reference path='./bar.d.ts' /> ////let x = import //// . // hai :) //// meta; verify.baselineFindAllReferences(""); goTo.rangeStart(test.ranges()[0]); verify.renameInfoFailed();
{ "end_byte": 535, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsImportMeta.ts" }
TypeScript/tests/cases/fourslash/renameCommentsAndStrings4.ts_0_529
/// <reference path="fourslash.ts" /> ///////<reference path="./Bar.ts" /> ////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to [|Bar|] in a comment. //// "this is a reference to [|Bar|] in a string"; //// `Foo [|Bar|] Baz.`; //// { //// const Bar = 0; //// `[|Bar|] ba ${Bar} bara [|Bar|] berbobo ${Bar} araura [|Bar|] ara!`; //// } ////}|] const [rDef, ...ranges] = test.ranges(); verify.baselineRename(ranges[0], { findInStrings: true, findInComments: true });
{ "end_byte": 529, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameCommentsAndStrings4.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection2.ts_0_229
/// <reference path='fourslash.ts' /> //// interface I1 { //// x: number; //// } //// interface I2 { //// x: string; //// } //// //// class C implements I1,I2 { //// x: string; //// } verify.not.codeFixAvailable();
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection2.ts" }
TypeScript/tests/cases/fourslash/completionListKeywords.ts_0_162
/// <reference path="fourslash.ts"/> // @noLib: true /////**/ verify.completions({ marker: "", exact: completion.globalsPlus([], { noLib: true }), });
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListKeywords.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash1.ts_0_418
/// <reference path="fourslash.ts"/> //// /// <reference path="./module.ts" /> const c = classification("original"); verify.syntacticClassificationsAre( c.comment("/// "), c.punctuation("<"), c.jsxSelfClosingTagName("reference"), c.comment(" "), c.jsxAttribute("path"), c.operator("="), c.jsxAttributeStringLiteralValue("\"./module.ts\""), c.comment(" "), c.punctuation("/>"));
{ "end_byte": 418, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash1.ts" }
TypeScript/tests/cases/fourslash/unusedTypeParametersInClass1.ts_0_206
/// <reference path='fourslash.ts' /> // @noUnusedParameters: true ////[|class greeter<T> |] { ////} verify.codeFix({ description: "Remove type parameters", newRangeContent: "class greeter ", });
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInClass1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember28.ts_0_352
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////interface IFoo { //// b(): void; ////} ////const foo: IFoo = {} ////foo.a() verify.codeFix({ description: [ts.Diagnostics.Declare_method_0.message, "a"], index: 1, newFileContent: `interface IFoo { a(): unknown; b(): void; } const foo: IFoo = {} foo.a()`, });
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember28.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc2.ts_0_151
/// <reference path='fourslash.ts' /> // @Filename: test123.ts /////** @type {number} */ ////var [|x|]: string; verify.getSuggestionDiagnostics([]);
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc2.ts" }
TypeScript/tests/cases/fourslash/quickInfoTypeOfThisInStatics.ts_0_302
/// <reference path='fourslash.ts'/> ////class C { //// static foo() { //// var /*1*/r = this; //// } //// static get x() { //// var /*2*/r = this; //// return 1; //// } ////} verify.quickInfos({ 1: "(local var) r: typeof C", 2: "(local var) r: typeof C" });
{ "end_byte": 302, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypeOfThisInStatics.ts" }
TypeScript/tests/cases/fourslash/organizeImportsNoFormatOptions.ts_0_435
/// <reference path="fourslash.ts" /> // #38548 ////import { //// stat, //// statSync, ////} from "fs"; ////export function fakeFn() { //// stat; //// statSync; ////} format.setFormatOptions({}); // Default newline is carriage return. // See `getNewLineOrDefaultFromHost()` in services/utilities.ts. verify.organizeImports( `import {\r\nstat,\r\nstatSync,\r\n} from "fs";\r\nexport function fakeFn() { stat; statSync; }`);
{ "end_byte": 435, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsNoFormatOptions.ts" }
TypeScript/tests/cases/fourslash/inlineVariableSingleReference.ts_0_329
/// <reference path="fourslash.ts" /> ////const /*a*/x/*b*/ = 0; ////const y = x + 1; goTo.select("a", "b"); verify.refactorAvailable("Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: "const y = 0 + 1;" });
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableSingleReference.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesAbstract01.ts_0_416
/// <reference path='fourslash.ts' /> ////[|abstract|] class Animal { //// [|abstract|] prop1; // Does not compile //// [|abstract|] abstract(); //// [|abstract|] walk(): void; //// [|abstract|] makeSound(): void; ////} ////// Abstract class below should not get highlighted ////abstract class Foo { //// abstract foo(): void; //// abstract bar(): void; ////} verify.baselineDocumentHighlights();
{ "end_byte": 416, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesAbstract01.ts" }
TypeScript/tests/cases/fourslash/formatSatisfiesExpression.ts_0_381
/// <reference path="fourslash.ts" /> ////type Foo = "a" | "b" | "c"; ////const foo1 = ["a"] satisfies Foo[]; ////const foo2 = ["a"]satisfies Foo[]; ////const foo3 = ["a"] satisfies Foo[]; format.document(); verify.currentFileContentIs( `type Foo = "a" | "b" | "c"; const foo1 = ["a"] satisfies Foo[]; const foo2 = ["a"] satisfies Foo[]; const foo3 = ["a"] satisfies Foo[];` );
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSatisfiesExpression.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_target_missingCompilerOptionsInTsConfig.ts_0_477
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: number[]; ////for await (const _ of p); ////export {}; // @filename: /dir/tsconfig.json ////{ ////} verify.codeFix({ description: [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0.message, "es2017"], index: 0, newFileContent: { "/dir/tsconfig.json": `{ "compilerOptions": { "target": "es2017", "module": "commonjs" } }` } });
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_target_missingCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingNew2.ts_0_240
/// <reference path='fourslash.ts' /> ////class C { ////} ////let x = (() => C)()(); verify.codeFix({ description: "Add missing 'new' operator to call", index: 0, newFileContent: `class C { } let x = new ((() => C)())();` });
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingNew2.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts_0_259
/// <reference path='fourslash.ts' /> ////interface I<T> { x: T; } ////class C<U> implements I<U> {} verify.codeFix({ description: "Implement interface 'I<U>'", newFileContent: `interface I<T> { x: T; } class C<U> implements I<U> { x: U; }` });
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts" }
TypeScript/tests/cases/fourslash/codeFixUnreachableCode_if.ts_0_898
/// <reference path='fourslash.ts' /> ////if (false) a; ////if (false) { //// a; ////} //// ////// No good way to delete just the 'if' part ////if (false) a; else b; ////if (false) { //// a; ////} else { //// b; ////} //// ////while (false) a; ////while (false) { //// a; ////} //// ////for (let x = 0; false; ++x) a; ////for (let x = 0; false; ++x) { //// a; ////} //// ////while (true) { //// 1; //// break; //// 2; ////} //// ////function f() { //// if (true) { //// 1; //// return; //// 2; //// } ////} verify.codeFixAll({ fixId: "fixUnreachableCode", fixAllDescription: "Remove all unreachable code", newFileContent: ` // No good way to delete just the 'if' part if (false) { } else b; if (false) { } else { b; } while (true) { 1; break; } function f() { if (true) { 1; return; } }`, });
{ "end_byte": 898, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnreachableCode_if.ts" }
TypeScript/tests/cases/fourslash/externalModuleIntellisense.ts_0_760
/// <reference path='fourslash.ts'/> // @Filename: externalModuleIntellisense_file0.ts ////export = express; ////function express(): express.ExpressServer; ////module express { //// export interface ExpressServer { //// enable(name: string): ExpressServer; //// post(path: RegExp, handler: (req: Function) => void): void; //// } //// export class ExpressServerRequest { //// } ////} // @Filename: externalModuleIntellisense_file1.ts ///////<reference path='externalModuleIntellisense_file0.ts'/> ////import express = require('./externalModuleIntellisense_file0'); ////var x = express();/*1*/ goTo.marker('1'); verify.numberOfErrorsInCurrentFile(0); goTo.eof(); edit.insert("x."); verify.completions({ exact: ["enable", "post"] });
{ "end_byte": 760, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/externalModuleIntellisense.ts" }
TypeScript/tests/cases/fourslash/completionListClassMembers.ts_0_2079
/// <reference path="fourslash.ts" /> ////class Class { //// private privateInstanceMethod() { } //// public publicInstanceMethod() { } //// //// private privateProperty = 1; //// public publicProperty = 1; //// //// private static privateStaticProperty = 1; //// public static publicStaticProperty = 1; //// //// private static privateStaticMethod() { } //// public static publicStaticMethod() { //// Class./*staticsInsideClassScope*/publicStaticMethod(); //// var c = new Class(); //// c./*instanceMembersInsideClassScope*/privateProperty; //// } ////} //// ////Class./*staticsOutsideClassScope*/publicStaticMethod(); ////var c = new Class(); ////c./*instanceMembersOutsideClassScope*/privateProperty; verify.completions( { marker: "staticsInsideClassScope", exact: completion.functionMembersPlus([ { name: "privateStaticMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "privateStaticProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicStaticMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicStaticProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]), }, { marker: "instanceMembersInsideClassScope", unsorted: ["privateInstanceMethod", "publicInstanceMethod", "privateProperty", "publicProperty"], }, { marker: "staticsOutsideClassScope", exact: completion.functionMembersPlus([ { name: "publicStaticMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicStaticProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]), }, { marker: "instanceMembersOutsideClassScope", exact: ["publicInstanceMethod", "publicProperty"], }, );
{ "end_byte": 2079, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListClassMembers.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration3.ts_0_372
/// <reference path='fourslash.ts' /> ////foo(1, "", { x: 1, y: 1 }); verify.codeFix({ index: 0, description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"], newFileContent: `foo(1, "", { x: 1, y: 1 }); function foo(arg0: number, arg1: string, arg2: { x: number; y: number; }) { throw new Error("Function not implemented."); } ` });
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration3.ts" }
TypeScript/tests/cases/fourslash/quickInfoThrowsTag.ts_0_360
///<reference path="fourslash.ts" /> ////class E extends Error {} //// /////** //// * @throws {E} //// */ ////function f1() {} //// /////** //// * @throws {E} description //// */ ////function f2() {} //// /////** //// * @throws description //// */ ////function f3() {} ////f1/*1*/() ////f2/*2*/() ////f3/*3*/() verify.noErrors() verify.baselineQuickInfo();
{ "end_byte": 360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoThrowsTag.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction11.ts_3_295
/ <reference path="fourslash.ts" /> ////interface MyType { ////} //// ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string = "hello", c: typeof x = "hello") { //// var v = (p: /*1*/ verify.completions({ marker: "1", includes: "MyType" });
{ "end_byte": 295, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction11.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsExternalModules.ts_0_521
/// <reference path='fourslash.ts'/> ////export namespace /*1*/m { //// var /*2*/namespaceElemWithoutExport = 10; //// export var /*3*/namespaceElemWithExport = 10; ////} ////export var /*4*/a = /*5*/m; ////export var /*6*/b: typeof /*7*/m; ////export namespace /*8*/m1./*9*/m2 { //// var /*10*/namespaceElemWithoutExport = 10; //// export var /*11*/namespaceElemWithExport = 10; ////} ////export var /*12*/x = /*13*/m1./*14*/m2; ////export var /*15*/y: typeof /*16*/m1./*17*/m2; verify.baselineQuickInfo();
{ "end_byte": 521, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsExternalModules.ts" }
TypeScript/tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts_0_451
/// <reference path='fourslash.ts'/> ////const a = { //// x: 1, //// y = 1, //// z: 1 ////} ////const b = { //// x = 1, //// y: 1 ////} ////const c = { //// x: 1, //// y = 1 ////} verify.codeFixAll({ fixAllDescription: "Switch each misused '=' to ':'", fixId: "fixPropertyAssignment", newFileContent: `const a = { x: 1, y: 1, z: 1 } const b = { x: 1, y: 1 } const c = { x: 1, y: 1 }` });
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts" }
TypeScript/tests/cases/fourslash/jsdocParam_suggestion1.ts_0_364
/// <reference path="fourslash.ts" /> // @Filename: a.ts //// /** //// * @param options - whatever //// * @param options.zone - equally bad //// */ //// declare function bad(options: any): void //// //// /** //// * @param {number} obtuse //// */ //// function worse(): void { //// arguments //// } goTo.file('a.ts') verify.getSuggestionDiagnostics([]);
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocParam_suggestion1.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction16.ts_0_303
/// <reference path='fourslash.ts' /> // @target: es2015 ////class A { //// async foo(): number {} ////} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "number", "number"], newFileContent: `class A { async foo(): Promise<number> {} }` });
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction16.ts" }
TypeScript/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts_0_583
/// <reference path='fourslash.ts' /> /////*2*/do{ /////*3*/do/*1*/{ /////*4*/do{ /////*5*/}while(a!==b) /////*6*/}while(a!==b) /////*7*/}while(a!==b) goTo.marker("1"); edit.insert("\n"); verify.currentLineContentIs(" {"); goTo.marker("2"); verify.currentLineContentIs("do{"); goTo.marker("3"); verify.currentLineContentIs(" do"); goTo.marker("4"); verify.currentLineContentIs("do{"); goTo.marker("5"); verify.currentLineContentIs("}while(a!==b)"); goTo.marker("6"); verify.currentLineContentIs("}while(a!==b)"); goTo.marker("7"); verify.currentLineContentIs("}while(a!==b)");
{ "end_byte": 583, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties14.ts_0_682
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true //// interface ID { //// a?: number //// } //// interface J { //// a?: number | undefined //// } //// declare var j: J //// declare var id: ID //// ({ id/**/ } = { id: j }) verify.codeFixAvailable([ { description: ts.Diagnostics.Add_undefined_to_optional_property_type.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message, index: 0, newFileContent: `interface ID { a?: number | undefined } interface J { a?: number | undefined } declare var j: J declare var id: ID ({ id } = { id: j })`, });
{ "end_byte": 682, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties14.ts" }
TypeScript/tests/cases/fourslash/stringPropertyNames1.ts_0_187
/// <reference path='fourslash.ts'/> ////export interface Album { //// "artist": number; ////} ////var a: Album; ////var /**/x = a['artist']; verify.quickInfoAt("", "var x: number");
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringPropertyNames1.ts" }
TypeScript/tests/cases/fourslash/tsxSignatureHelp1.ts_0_1076
/// <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true // @libFiles: react.d.ts,lib.d.ts //// import React = require('react'); //// export interface ClickableProps { //// children?: string; //// className?: string; //// } //// export interface ButtonProps extends ClickableProps { //// onClick(event?: React.MouseEvent<HTMLButtonElement>): void; //// } //// function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element { //// return(<button className={className} onClick={onClick}>{ children || 'MAIN BUTTON'}</button>); //// } //// export function MainButton(props: ButtonProps): JSX.Element { //// return this._buildMainButton(props); //// } //// let e1 = <MainButton/*1*/ /*2*/ verify.signatureHelp( { marker: "1", text: "MainButton(props: ButtonProps): JSX.Element", parameterSpan: "props: ButtonProps", }, { marker: "2", text: "MainButton(props: ButtonProps): JSX.Element", parameterSpan: "props: ButtonProps", }, );
{ "end_byte": 1076, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxSignatureHelp1.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMemberJS.ts_0_997
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: true // @strictNullChecks: true // @Filename: important.js ////class C { //// constructor() { //// /** this is fine */ //// this.p = undefined; //// this.q = undefined //// } //// method() { //// this.p.push(1) //// this.q.push(1); //// } ////} // Note: Should be number[] | undefined, but inference currently privileges assignments // over usage (even when the only result is undefined) and infers only undefined. verify.codeFixAll({ fixId: "inferFromUsage", fixAllDescription: "Infer all types from usage", newFileContent: `class C { constructor() { /** * this is fine * @type {number[] | undefined} */ this.p = undefined; /** * @type {number[] | undefined} */ this.q = undefined } method() { this.p.push(1) this.q.push(1); } }`});
{ "end_byte": 997, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMemberJS.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType69.ts_0_715
/// <reference path='fourslash.ts' /> ////type Foo<T> = { //// fn: //// keyof T extends string //// ? /*a*/(x: `${keyof T}Foo`, callback: (y: keyof T) => void) => void/*b*/ //// : never; ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: [ "type /*RENAME*/NewType<T> = (x: `${keyof T}Foo`, callback: (y: keyof T) => void) => void;", "", "type Foo<T> = {", " fn:", " keyof T extends string", " ? NewType<T>", " : never;", "}" ].join("\n"), });
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType69.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnGenericClass.ts_0_134
/// <reference path='fourslash.ts'/> ////class Contai/**/ner<T> { //// x: T; ////} verify.quickInfoAt("", "class Container<T>");
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnGenericClass.ts" }
TypeScript/tests/cases/fourslash/autoImportPathsNodeModules.ts_0_678
/// <reference path="fourslash.ts" /> // @Filename: tsconfig.json //// { //// "compilerOptions": { //// "module": "amd", //// "moduleResolution": "node", //// "rootDir": "ts", //// "baseUrl": ".", //// "paths": { //// "*": ["node_modules/@woltlab/wcf/ts/*"] //// } //// }, //// "include": [ //// "ts", //// "node_modules/@woltlab/wcf/ts", //// ] //// } // @Filename: node_modules/@woltlab/wcf/ts/WoltLabSuite/Core/Component/Dialog.ts //// export class Dialog {} // @Filename: ts/main.ts //// Dialog/**/ verify.importFixModuleSpecifiers("", ["WoltLabSuite/Core/Component/Dialog"]);
{ "end_byte": 678, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPathsNodeModules.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts_0_179
/// <reference path='fourslash.ts' /> //// var index = { get p(): [|*|] { return 12 } }; verify.codeFix({ description: "Change '*' to 'any'", newRangeContent: "any", });
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts" }
TypeScript/tests/cases/fourslash/navbarNestedCommonJsExports.ts_0_958
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /a.js ////exports.a = exports.b = exports.c = 0; verify.navigationTree({ text: "<global>", kind: "script", childItems: [ { text: "a", kind: "const", childItems: [ { text: "b", kind: "const", childItems: [{ text: "c", kind: "const" }], }, ], }, ], }); verify.navigationBar([ { text: "<global>", kind: "script", childItems: [ { text: "a", kind: "const" }, ] }, { text: "a", kind: "const", childItems: [ { text: "b", kind: "const"}, ], indent: 1, }, { text: "b", kind: "const", childItems: [ { text: "c", kind: "const" }, ], indent: 2, } ]);
{ "end_byte": 958, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navbarNestedCommonJsExports.ts" }