_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/regionCheckSpan.ts_0_579 | /// <reference path="fourslash.ts" />
// @strict: true
//// [|function foo() {
//// [|return 1 + 3;
//// }
////
//// function bar(a: number, b: string) {
//// const z = a + b;
//// return z + z;
//// }|]|]
////
//// class Foo {}
////
//// class Bar extends Foo {
//// foo!: string;[|
//// bar!: number;
//// zzz!: boolean;|]
//// }
const [outerFunctions, innerFunctions, classMembers] = test.ranges();
verify.getRegionSemanticDiagnostics([innerFunctions], [], [outerFunctions]);
verify.getRegionSemanticDiagnostics([classMembers], [], [classMembers]); | {
"end_byte": 579,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/regionCheckSpan.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpelling9.ts_0_314 | /// <reference path='fourslash.ts' />
// @filename: a.ts
////module Foo {
//// export type nums = number;
////}
// @filename: b.ts
////let x: Foo.[|num|];
goTo.file("b.ts");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Change_spelling_to_0.message, "nums"],
newRangeContent: "nums"
});
| {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling9.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnInvalidCodes.ts_0_7053 | /// <reference path='fourslash.ts' />
/////*1*/var a;var c , b;var $d
/////*2*/var $e
/////*3*/var f
/////*4*/a++;b++;
////
/////*5*/function f ( ) {
/////*6*/ for (i = 0; i < 10; i++) {
/////*7*/ k = abc + 123 ^ d;
/////*8*/ a = XYZ[m (a[b[c][d]])];
/////*9*/ break;
////
/////*10*/ switch ( variable){
/////*11*/ case 1: abc += 425;
/////*12*/break;
/////*13*/case 404 : a [x--/2]%=3 ;
/////*14*/ break ;
/////*15*/ case vari : v[--x ] *=++y*( m + n / k[z]);
/////*16*/ for (a in b){
/////*17*/ for (a = 0; a < 10; ++a) {
/////*18*/ a++;--a;
/////*19*/ if (a == b) {
/////*20*/ a++;b--;
/////*21*/ }
/////*22*/else
/////*23*/if (a == c){
/////*24*/++a;
/////*25*/(--c)+=d;
/////*26*/$c = $a + --$b;
/////*27*/}
/////*28*/if (a == b)
/////*29*/if (a != b) {
/////*30*/ if (a !== b)
/////*31*/ if (a === b)
/////*32*/ --a;
/////*33*/ else
/////*34*/ --a;
/////*35*/ else {
/////*36*/ a--;++b;
/////*37*/a++
/////*38*/ }
/////*39*/ }
/////*40*/ }
/////*41*/ for (x in y) {
/////*42*/m-=m;
/////*43*/k=1+2+3+4;
/////*44*/}
/////*45*/}
/////*46*/ break;
////
/////*47*/ }
/////*48*/ }
/////*49*/ var a ={b:function(){}};
/////*50*/ return {a:1,b:2}
/////*51*/}
////
/////*52*/var z = 1;
/////*53*/ for (i = 0; i < 10; i++)
/////*54*/ for (j = 0; j < 10; j++)
/////*55*/for (k = 0; k < 10; ++k) {
/////*56*/z++;
/////*57*/}
////
/////*58*/for (k = 0; k < 10; k += 2) {
/////*59*/z++;
/////*60*/}
////
/////*61*/ $(document).ready ();
////
////
/////*62*/ function pageLoad() {
/////*63*/ $('#TextBox1' ) . unbind ( ) ;
/////*64*/$('#TextBox1' ) . datepicker ( ) ;
/////*65*/}
////
/////*66*/ function pageLoad ( ) {
/////*67*/ var webclass=[
/////*68*/ { 'student' :/*69*/
/////*70*/ { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }
/////*71*/ } ,
/////*72*/{ 'student':/*73*/
/////*74*/{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'}
/////*75*/} ,
/////*76*/ { 'student':/*77*/
/////*78*/{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'}
/////*79*/}
/////*80*/ ];
////
/////*81*/$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList'));
////
/////*82*/}
////
/////*83*/$( document ).ready(function(){
/////*84*/alert('hello');
/////*85*/ } ) ;
format.document();
goTo.marker("1");
verify.currentLineContentIs("var a; var c, b; var $d");
goTo.marker("2");
verify.currentLineContentIs("var $e");
goTo.marker("3");
verify.currentLineContentIs("var f");
goTo.marker("4");
verify.currentLineContentIs("a++; b++;");
goTo.marker("5");
verify.currentLineContentIs("function f() {");
goTo.marker("6");
verify.currentLineContentIs(" for (i = 0; i < 10; i++) {");
goTo.marker("7");
verify.currentLineContentIs(" k = abc + 123 ^ d;");
goTo.marker("8");
verify.currentLineContentIs(" a = XYZ[m(a[b[c][d]])];");
goTo.marker("9");
verify.currentLineContentIs(" break;");
goTo.marker("10");
verify.currentLineContentIs(" switch (variable) {");
goTo.marker("11");
verify.currentLineContentIs(" case 1: abc += 425;");
goTo.marker("12");
verify.currentLineContentIs(" break;");
goTo.marker("13");
verify.currentLineContentIs(" case 404: a[x-- / 2] %= 3;");
goTo.marker("14");
verify.currentLineContentIs(" break;");
goTo.marker("15");
verify.currentLineContentIs(" case vari: v[--x] *= ++y * (m + n / k[z]);");
goTo.marker("16");
verify.currentLineContentIs(" for (a in b) {");
goTo.marker("17");
verify.currentLineContentIs(" for (a = 0; a < 10; ++a) {");
goTo.marker("18");
verify.currentLineContentIs(" a++; --a;");
goTo.marker("19");
verify.currentLineContentIs(" if (a == b) {");
goTo.marker("20");
verify.currentLineContentIs(" a++; b--;");
goTo.marker("21");
verify.currentLineContentIs(" }");
goTo.marker("22");
verify.currentLineContentIs(" else");
goTo.marker("23");
verify.currentLineContentIs(" if (a == c) {");
goTo.marker("24");
verify.currentLineContentIs(" ++a;");
goTo.marker("25");
verify.currentLineContentIs(" (--c) += d;");
goTo.marker("26");
verify.currentLineContentIs(" $c = $a + --$b;");
goTo.marker("27");
verify.currentLineContentIs(" }");
goTo.marker("28");
verify.currentLineContentIs(" if (a == b)");
goTo.marker("29");
verify.currentLineContentIs(" if (a != b) {");
goTo.marker("30");
verify.currentLineContentIs(" if (a !== b)");
goTo.marker("31");
verify.currentLineContentIs(" if (a === b)");
goTo.marker("32");
verify.currentLineContentIs(" --a;");
goTo.marker("33");
verify.currentLineContentIs(" else");
goTo.marker("34");
verify.currentLineContentIs(" --a;");
goTo.marker("35");
verify.currentLineContentIs(" else {");
goTo.marker("36");
verify.currentLineContentIs(" a--; ++b;");
goTo.marker("37");
verify.currentLineContentIs(" a++");
goTo.marker("38");
//bug 697788 expect result : " }", actual result : " }"
//verify.currentLineContentIs(" }");
verify.currentLineContentIs(" }");
goTo.marker("39");
verify.currentLineContentIs(" }");
goTo.marker("40");
verify.currentLineContentIs(" }");
goTo.marker("41");
verify.currentLineContentIs(" for (x in y) {");
goTo.marker("42");
verify.currentLineContentIs(" m -= m;");
goTo.marker("43");
verify.currentLineContentIs(" k = 1 + 2 + 3 + 4;");
goTo.marker("44");
verify.currentLineContentIs(" }");
goTo.marker("45");
verify.currentLineContentIs(" }");
goTo.marker("46");
verify.currentLineContentIs(" break;");
goTo.marker("47");
verify.currentLineContentIs(" }");
goTo.marker("48");
verify.currentLineContentIs(" }");
goTo.marker("49");
//bug 704204 expect result : " var a = { b: function () { } };", actual result : " var a = { b: function() { } };"
//verify.currentLineContentIs(" var a = { b: function () { } };");
verify.currentLineContentIs(" var a = { b: function() { } };");
goTo.marker("50"); | {
"end_byte": 7053,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnInvalidCodes.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnInvalidCodes.ts_7054_9924 | verify.currentLineContentIs(" return { a: 1, b: 2 }");
goTo.marker("51");
verify.currentLineContentIs("}");
goTo.marker("52");
verify.currentLineContentIs("var z = 1;");
goTo.marker("53");
verify.currentLineContentIs("for (i = 0; i < 10; i++)");
goTo.marker("54");
verify.currentLineContentIs(" for (j = 0; j < 10; j++)");
goTo.marker("55");
verify.currentLineContentIs(" for (k = 0; k < 10; ++k) {");
goTo.marker("56");
verify.currentLineContentIs(" z++;");
goTo.marker("57");
verify.currentLineContentIs(" }");
goTo.marker("58");
verify.currentLineContentIs("for (k = 0; k < 10; k += 2) {");
goTo.marker("59");
verify.currentLineContentIs(" z++;");
goTo.marker("60");
verify.currentLineContentIs("}");
goTo.marker("61");
verify.currentLineContentIs("$(document).ready();");
goTo.marker("62");
verify.currentLineContentIs("function pageLoad() {");
goTo.marker("63");
verify.currentLineContentIs(" $('#TextBox1').unbind();");
goTo.marker("64");
verify.currentLineContentIs(" $('#TextBox1').datepicker();");
goTo.marker("65");
verify.currentLineContentIs("}");
goTo.marker("66");
verify.currentLineContentIs("function pageLoad() {");
goTo.marker("67");
verify.currentLineContentIs(" var webclass = [");
goTo.marker("68");
verify.currentLineContentIs(" {");
goTo.marker("69");
verify.currentLineContentIs(" 'student':");
goTo.marker("70");
verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }");
goTo.marker("71");
verify.currentLineContentIs(" },");
goTo.marker("72");
verify.currentLineContentIs(" {");
goTo.marker("73");
verify.currentLineContentIs(" 'student':");
goTo.marker("74");
verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }");
goTo.marker("75");
verify.currentLineContentIs(" },");
goTo.marker("76");
verify.currentLineContentIs(" {");
goTo.marker("77");
verify.currentLineContentIs(" 'student':");
goTo.marker("78");
verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }");
goTo.marker("79");
verify.currentLineContentIs(" }");
goTo.marker("80");
verify.currentLineContentIs(" ];");
goTo.marker("81");
verify.currentLineContentIs(" $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList'));");
goTo.marker("82");
verify.currentLineContentIs("}");
goTo.marker("83");
//bug 704204 expect result : "$(document).ready(function () {", actual result : "$(document).ready(function() "
//verify.currentLineContentIs("$(document).ready(function () {");
verify.currentLineContentIs("$(document).ready(function() {");
goTo.marker("84");
verify.currentLineContentIs(" alert('hello');");
goTo.marker("85");
verify.currentLineContentIs("});"); | {
"end_byte": 9924,
"start_byte": 7054,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnInvalidCodes.ts"
} |
TypeScript/tests/cases/fourslash/renameImportAndShorthand.ts_0_204 | /// <reference path='fourslash.ts' />
////[|import [|{| "contextRangeIndex": 0 |}foo|] from 'bar';|]
////const bar = { [|foo|] };
const [r0Def, r0, r1] = test.ranges();
verify.baselineRename([r0, r1]);
| {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportAndShorthand.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts_0_1906 | /// <reference path='fourslash.ts' />
// @Filename: /file1.ts
////declare function log(s: string | number): void;
////[|const /*q0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}q|] = 1;|]
////[|export { /*q1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}q|] };|]
////const x = {
//// [|/*z0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}z|]: 'value'|]
////}
////[|const { /*z1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}z|] } = x;|]
////log(/*z2*/[|z|]);
// @Filename: /file2.ts
////declare function log(s: string | number): void;
////[|import { /*q2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}q|] } from "./file1";|]
////log(/*q3*/[|q|] + 1);
verify.noErrors();
const [q0Def, q0, q1Def, q1, z0Def, z0, z1Def, z1, z2, q2Def, q2, q3] = test.ranges();
const qFile1Ranges = [q0, q1];
const qFile2Ranges = [q2, q3];
const qFile1ReferenceGroup: FourSlashInterface.ReferenceGroup = {
definition: "const q: 1",
ranges: qFile1Ranges
};
const qFile2ReferenceGroup: FourSlashInterface.ReferenceGroup = {
definition: "(alias) const q: 1\nimport q",
ranges: qFile2Ranges
};
const zReferenceGroup1: FourSlashInterface.ReferenceGroup = {
definition: "(property) z: string",
ranges: [z0]
};
const zReferenceGroup2: FourSlashInterface.ReferenceGroup = {
definition: "const z: string",
ranges: [z1, z2]
};
verify.baselineFindAllReferences('q0', 'q1', 'q2', 'q3', 'z0', 'z1', 'z2');
verify.baselineRename([q0, q1, q2, q3], { providePrefixAndSuffixTextForRename: true });
verify.baselineRename([q0, q1, q2, q3], { providePrefixAndSuffixTextForRename: false });
verify.baselineRename([z0, z1, z2], { providePrefixAndSuffixTextForRename: true });
verify.baselineRename([z0, z1, z2], { providePrefixAndSuffixTextForRename: false }); | {
"end_byte": 1906,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJSExport.ts_0_382 | /// <reference path="fourslash.ts" />
// GH #35347
// @Filename: a.js
// @allowJs: true
//// /**
//// * @enum {string}
//// */
//// const testString = {
//// one: "1",
//// two: "2"
//// };
////
//// export { test/**/String };
verify.quickInfoAt("",
`(alias) type testString = string
(alias) const testString: {
one: string;
two: string;
}
export testString`);
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJSExport.ts"
} |
TypeScript/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral5.ts_0_420 | // @module: esnext
// @Filename: /a.ts
//// export const exportedConstant = 0;
// @Filename: /b.ts
//// const foo = 'foo'
//// const obj = { exp/**/
verify.completions({
marker: "",
includes: { name: "exportedConstant", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions },
isNewIdentifierLocation: true,
preferences: { includeCompletionsForModuleExports: true },
});
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingImportForReactJsx2.ts_0_765 | /// <reference path='fourslash.ts' />
// @jsx: react-jsxdev
// @Filename: node_modules/react/index.d.ts
////export declare var React: any;
// @Filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "./index.d.ts"
////}
// @Filename: foo.tsx
//// export default function Foo(){
//// return <></>;
//// }
// @Filename: bar.tsx
//// export default function Bar(){
//// return <Foo></Foo>;
//// }
// @Filename: package.json
////{
//// "dependencies": {
//// "react": "*"
//// }
////}
goTo.file('bar.tsx')
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`import Foo from "./foo";
export default function Bar(){
return <Foo></Foo>;
}`,
});
| {
"end_byte": 765,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingImportForReactJsx2.ts"
} |
TypeScript/tests/cases/fourslash/jsDocPropertyDescription3.ts_0_368 | ///<reference path="fourslash.ts" />
//// interface LiteralExample {
//// /** Something generic */
//// [key: `data-${string}`]: string;
//// /** Something else */
//// [key: `prefix${number}`]: number;
//// }
//// function literalExample(e: LiteralExample) {
//// console.log(e./*literal*/anything);
//// }
verify.quickInfoAt("literal", "any"); | {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExprWithElementAccess.ts_0_439 | /// <reference path='fourslash.ts' />
////const a = { prop: 1 };
////const b = /*x*/a["prop"]/*y*/ + "a" + "b";
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: [
"const a = { prop: 1 };",
"const b = `${a[\"prop\"]}ab`;"
].join("\n")
});
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExprWithElementAccess.ts"
} |
TypeScript/tests/cases/fourslash/codeFixPropertyOverrideAccess2.ts_0_452 | /// <reference path='fourslash.ts' />
// @strict: true
//// class A {
//// x = 1
//// }
//// class B extends A {
//// get x() { return 2 }
//// }
verify.codeFix({
description: `Generate 'get' and 'set' accessors`,
newFileContent: `class A {
private _x = 1
public get x() {
return this._x
}
public set x(value) {
this._x = value
}
}
class B extends A {
get x() { return 2 }
}`,
index: 0
})
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixPropertyOverrideAccess2.ts"
} |
TypeScript/tests/cases/fourslash/unknownVariableErrorRecovery.ts_0_182 | /// <reference path="fourslash.ts" />
////var foo = [1, 2, 3];
////for (var bar = 0; foo[bar] < 5; bear/**/++ ) {
//// foo[bar] = 0;
////}
verify.not.errorExistsAfterMarker();
| {
"end_byte": 182,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unknownVariableErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1.ts_0_249 | /// <reference path='fourslash.ts'/>
// @strict: true
//// const optionals: ((a?: number) => unknown) & ((b?: string) => unknown) = (
//// arg,
//// ) =/**/> {};
verify.quickInfoAt(
"",
`function(arg: string | number | undefined): void`,
); | {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixWithCopyright.ts_0_3622 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export class A { }
// @Filename: /b.ts
/////*---------------------------------------------------------------------------------------------
//// * Copyright (c) Microsoft Corporation. All rights reserved.
//// * Licensed under the MIT License. See License.txt in the project root for license information.
//// *--------------------------------------------------------------------------------------------*/
////
////export class B extends A { }
// @Filename: /c.ts
/////*---------------------------------------------------------------------------------------------
//// * Copyright (c) Microsoft Corporation. All rights reserved.
//// * Licensed under the MIT License. See License.txt in the project root for license information.
//// *--------------------------------------------------------------------------------------------*/
////
//// /// <reference types="node" />
//// /// <reference path="./a.ts" />
//// /// <amd-dependency path="./b.ts" />
////export class C extends A { }
// @Filename: /d.ts
/////*---------------------------------------------------------------------------------------------
//// * Copyright (c) Microsoft Corporation. All rights reserved.
//// * Licensed under the MIT License. See License.txt in the project root for license information.
//// *--------------------------------------------------------------------------------------------*/
////
//// /// <reference types="node" />
//// /// <reference path="./a.ts" />
//// /// <amd-dependency path="./b.ts" />
//// /**
//// * This is a comment intended to be attached to this interface
//// */
////export class D extends A { }
goTo.file("/b.ts");
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0),
newFileContent:
`/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { A } from "./a";
export class B extends A { }`,
});
goTo.file("/c.ts");
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0),
newFileContent:
`/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference types="node" />
/// <reference path="./a.ts" />
/// <amd-dependency path="./b.ts" />
import { A } from "./a";
export class C extends A { }`,
});
goTo.file("/d.ts");
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0),
newFileContent:
`/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference types="node" />
/// <reference path="./a.ts" />
/// <amd-dependency path="./b.ts" />
import { A } from "./a";
/**
* This is a comment intended to be attached to this interface
*/
export class D extends A { }`,
}); | {
"end_byte": 3622,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixWithCopyright.ts"
} |
TypeScript/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts_0_740 | /// <reference path="fourslash.ts" />
//@Filename: findAllRefsOnDefinition-import.ts
////export class Test{
////
//// constructor(){
////
//// }
////
//// public /*1*/start(){
//// return this;
//// }
////
//// public stop(){
//// return this;
//// }
////}
//@Filename: findAllRefsOnDefinition.ts
////import Second = require("./findAllRefsOnDefinition-import");
////
////var second = new Second.Test()
////second./*2*/start();
////second.stop();
verify.baselineFindAllReferences("1");
cancellation.setCancelled();
verifyOperationIsCancelled(() => verify.baselineFindAllReferences('1'));
// verify that internal state is still correct
cancellation.resetCancelled();
verify.baselineFindAllReferences("1");
| {
"end_byte": 740,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts"
} |
TypeScript/tests/cases/fourslash/semicolonFormatting.ts_0_172 | /// <reference path='fourslash.ts' />
/////**/function of1 (b:{r:{c:number
goTo.eof();
edit.insert(';');
verify.currentLineContentIs('function of1(b: { r: { c: number;'); | {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormatting.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExportAsDefaultExistingImport.ts_0_309 | /// <reference path="fourslash.ts" />
//// import [|{ v1, v2, v3 }|] from "./module";
//// v4/*0*/();
// @Filename: module.ts
//// const v4 = 5;
//// export { v4 as default };
//// export const v1 = 5;
//// export const v2 = 5;
//// export const v3 = 5;
verify.importFixAtPosition([`v4, { v1, v2, v3 }`]);
| {
"end_byte": 309,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExportAsDefaultExistingImport.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_importType_named.ts_0_299 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////*1*/export type /*2*/T = number;
/////*3*/export type /*4*/U = string;
// @Filename: /b.ts
////const x: import("./a")./*5*/T = 0;
////const x: import("./a")./*6*/U = 0;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6');
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_named.ts"
} |
TypeScript/tests/cases/fourslash/javascriptModules21.ts_0_428 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @module: system
// @Filename: mod.js
//// function foo() { return {a: true}; }
//// module.exports = foo();
// @Filename: app.js
//// import mod from "./mod"
//// mod./**/
verify.completions({
marker: "",
exact: [
{ name: "a", kind: "property" },
{ name: "mod", kind: "warning", sortText: completion.SortText.JavascriptIdentifiers }
]
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules21.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsImportType2.ts_0_437 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
//// module.exports.a = 1
// @Filename: /b.js
//// function foo () { return require('./a'); }
//// function bar () { return require('./a').a; }
//// const c = foo()
//// const d = bar()
goTo.file('/b.js')
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
includeInlayFunctionLikeReturnTypeHints: true
});
| {
"end_byte": 437,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsImportType2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier19.ts_0_363 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////class Foo {
//// protected static readonly p = '';
////}
////
////export class Bar extends Foo {
//// [|protected static readonly p = ''|];
////}
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "protected static override readonly p = ''",
index: 0
})
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier19.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts_0_142 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => delete /*1*/
verify.completions({ marker: "1", includes: ["x", "p"] });
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForTypeParameterInTypeAlias2.ts_3_687 | / <reference path="fourslash.ts" />
//// type Call<AA> = { (): A/*1*/A };
//// type Index<AA> = {[foo: string]: A/*2*/A};
//// type GenericMethod<AA> = { method<BB>(): A/*3*/A & B/*4*/B }
//// type Nesting<TT> = { method<UU>(): new <WW>() => T/*5*/T & U/*6*/U & W/*7*/W };
verify.quickInfos({
1: "(type parameter) AA in type Call<AA>",
2: "(type parameter) AA in type Index<AA>",
3: "(type parameter) AA in type GenericMethod<AA>",
4: "(type parameter) BB in method<BB>(): AA & BB",
5: "(type parameter) TT in type Nesting<TT>",
6: "(type parameter) UU in method<UU>(): new <WW>() => TT & UU & WW",
7: "(type parameter) WW in <WW>(): TT & UU & WW"
});
| {
"end_byte": 687,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForTypeParameterInTypeAlias2.ts"
} |
TypeScript/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath5.ts_0_832 | /// <reference path='fourslash.ts' />
// @Filename: /main.ts
////// leading trivia
////import { a } from "./a";
////import { b } from "./b";
////import { c } from "./c";
// @Filename: /a.ts
////export const a = null;
// @Filename: /b.ts
////export const b = null;
// @Filename: /c.ts
////export const c = null;
verify.codeFix({
index: 0,
description: "Remove import from './a'",
newFileContent:
`// leading trivia
import { b } from "./b";
import { c } from "./c";`,
});
verify.codeFix({
index: 1,
description: "Remove import from './b'",
newFileContent:
`// leading trivia
import { a } from "./a";
import { c } from "./c";`,
});
verify.codeFix({
index: 2,
description: "Remove import from './c'",
newFileContent:
`// leading trivia
import { a } from "./a";
import { b } from "./b";
`,
});
| {
"end_byte": 832,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath5.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers2.ts_1_2359 | //// function f(p1: () => any, p2: string) { }
//// f(() => { }, `line1\
//// line2\
//// line3`);
////
//// class c1 {
//// const a = ' ''line1\
//// line2';
//// }
////
//// f(() => { }, `unterminated backtick 1
//// unterminated backtick 2
//// unterminated backtick 3
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c1",
"kind": "class",
"childItems": [
{
"text": "a",
"kind": "property"
},
{
"text": "'line1 line2'",
"kind": "property"
}
]
},
{
"text": "f",
"kind": "function"
},
{
"text": "f(`line1line2line3`) callback",
"kind": "function"
},
{
"text": "f(`unterminated backtick 1unterminated backtick 2unterminated backtick 3) callback",
"kind": "function"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c1",
"kind": "class"
},
{
"text": "f",
"kind": "function"
},
{
"text": "f(`line1line2line3`) callback",
"kind": "function"
},
{
"text": "f(`unterminated backtick 1unterminated backtick 2unterminated backtick 3) callback",
"kind": "function"
}
]
},
{
"text": "c1",
"kind": "class",
"childItems": [
{
"text": "a",
"kind": "property"
},
{
"text": "'line1 line2'",
"kind": "property"
}
],
"indent": 1
},
{
"text": "f",
"kind": "function",
"indent": 1
},
{
"text": "f(`line1line2line3`) callback",
"kind": "function",
"indent": 1
},
{
"text": "f(`unterminated backtick 1unterminated backtick 2unterminated backtick 3) callback",
"kind": "function",
"indent": 1
}
]);
| {
"end_byte": 2359,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers2.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_existingImports2.ts_0_550 | /// <reference path='fourslash.ts' />
// @filename: /common.ts
////export const x = 1;
// @filename: /a.ts
////import { x } from "./common";
////export const a = x;
////[|export const b = x;|]
// @filename: /b.ts
////import { x } from "./common";
////export const a = x;
verify.moveToFile({
newFileContents: {
"/a.ts":
`import { x } from "./common";
export const a = x;
`,
"/b.ts":
`import { x } from "./common";
export const a = x;
export const b = x;
`,
},
interactiveRefactorArguments: { targetFile: "/b.ts" },
});
| {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_existingImports2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstPreservingIndentation1.ts_0_378 | /// <reference path='fourslash.ts' />
////a = () => {
//// x = 0;
//// [y] = [1];
//// weirdlyIndented = 2;
////};
////b = 3;
verify.codeFixAll({
fixId: "addMissingConst",
fixAllDescription: "Add 'const' to all unresolved variables",
newFileContent: `const a = () => {
const x = 0;
const [y] = [1];
const weirdlyIndented = 2;
};
const b = 3;`
});
| {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstPreservingIndentation1.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsGroup_MultilineCommentInNewline.ts_0_361 | /// <reference path="fourslash.ts" />
////// polyfill
////import c from "C";
/////*
////* demo
////*/
////import d from "D";
////import a from "A";
////import b from "B";
////
////console.log(a, b, c, d)
verify.organizeImports(
`// polyfill
import c from "C";
/*
* demo
*/
import a from "A";
import b from "B";
import d from "D";
console.log(a, b, c, d)`
);
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsGroup_MultilineCommentInNewline.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts_0_200 | /// <reference path='fourslash.ts' />
/////** */
/////**
//// *
//// * @param p
//// */
/////** */
/////*/**/
////function foo(p) {}
verify.docCommentTemplateAt("", 7,
`/**
*
* @param p
*/`);
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard11.ts_0_517 | /// <reference path="fourslash.ts" />
// @module: preserve
// @moduleResolution: bundler
// @jsx: react
// @Filename: /node_modules/repo/package.json
//// {
//// "name": "repo",
//// "exports": {
//// "./*": "./src/*"
//// }
//// }
// @Filename: /node_modules/repo/src/card.tsx
//// export {};
// @Filename: /main.ts
//// import { } from "repo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{ name: "card.js", kind: "script", kindModifiers: ".js" },
],
});
| {
"end_byte": 517,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts_0_174 | /// <reference path='fourslash.ts' />
////declare class C {
//// p: [|*|];
////}
verify.codeFix({
description: "Change '*' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 174,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType22.ts_0_376 | /// <reference path='fourslash.ts' />
////const foo = async /*a*//*b*/a => {
//// return 1;
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`const foo = async (a): Promise<number> => {
return 1;
}`
});
| {
"end_byte": 376,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType22.ts"
} |
TypeScript/tests/cases/fourslash/findReferencesSeeTagInTs.ts_0_264 | /// <reference path='fourslash.ts' />
//// function doStuffWithStuff/*1*/(stuff: { quantity: number }) {}
////
//// declare const stuff: { quantity: number };
//// /** @see {doStuffWithStuff} */
//// if (stuff.quantity) {}
verify.baselineFindAllReferences("1");
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findReferencesSeeTagInTs.ts"
} |
TypeScript/tests/cases/fourslash/todoComments19.ts_0_271 | /// <reference path='fourslash.ts' />
// Tests that todos are not found in node_modules folder.
// @Filename: todoTest0.ts
//// import * as foo1 from "fake-module";
// @Filename: node_modules/fake-module/ts.ts
//// // TODO
verify.todoCommentsInCurrentFile(["TODO"]);
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments19.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableParensNewExpression.ts_0_552 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function foo() {
//// class Foo { function bar() { } }
//// return Foo;
////}
// @Filename: /b.ts
////import * as a from "./a";
////const /*a*/foo/*b*/ = a.foo();
////new foo.bar();
goTo.file("/b.ts");
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `import * as a from "./a";
new (a.foo()).bar();`
});
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableParensNewExpression.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyInterfaceMethod.ts_0_199 | /// <reference path="fourslash.ts" />
//// interface I {
//// /**/foo(): void;
//// }
////
//// const obj: I = { foo() {} };
////
//// obj.foo();
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyInterfaceMethod.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts_0_1153 | /// <reference path="fourslash.ts" />
////function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number;
////function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string;
////function tempTag2(...rest: any[]): any {
//// return undefined;
////}
////
////tempTag2 `${ x => /*0*/x }${ 0 }`;
////tempTag2 `${ /*1*/x => /*2*/x }${ undefined }`;
////tempTag2 `${ x => /*3*/x }${ x => /*4*/x }${ "hello" }`;
////tempTag2 `${ x => /*5*/x }${ undefined }${ "hello" }`;
// The first group of parameters, [0, 2], should all be contextually typed as 'number'.
// The second group, [3, 5], should be typed as 'string'.
var numTypedVariableCount = 3;
var strTypedVariableCount = 3;
if (numTypedVariableCount + strTypedVariableCount !== test.markers().length) {
throw "Unexpected number of markers in file.";
}
for (var i = 0; i < numTypedVariableCount; i++) {
verify.quickInfoAt("" + i, "(parameter) x: number");
}
for (var i = 0; i < strTypedVariableCount; i++) {
verify.quickInfoAt("" + (i + numTypedVariableCount), "(parameter) x: string");
} | {
"end_byte": 1153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralWithPartialConstraint.ts_0_1783 | /// <reference path="fourslash.ts" />
////interface MyOptions {
//// hello?: boolean;
//// world?: boolean;
////}
////declare function bar<T extends MyOptions>(options?: Partial<T>): void;
////bar({ hello: true, /*1*/ });
////
////interface Test {
//// keyPath?: string;
//// autoIncrement?: boolean;
////}
////
////function test<T extends Record<string, Test>>(opt: T) { }
////
////test({
//// a: {
//// keyPath: 'x.y',
//// autoIncrement: true
//// },
//// b: {
//// /*2*/
//// }
////});
////type Colors = {
//// rgb: { r: number, g: number, b: number };
//// hsl: { h: number, s: number, l: number }
////};
////
////function createColor<T extends keyof Colors>(kind: T, values: Colors[T]) { }
////
////createColor('rgb', {
//// /*3*/
////});
////
////declare function f<T extends 'a' | 'b', U extends { a?: string }, V extends { b?: string }>(x: T, y: { a: U, b: V }[T]): void;
////
////f('a', {
//// /*4*/
////});
////
////declare function f2<T extends { x?: string }>(x: T): void;
////f2({
//// /*5*/
////});
////
////type X = { a: { a }, b: { b } }
////
////function f4<T extends 'a' | 'b'>(p: { kind: T } & X[T]) { }
////
////f4({
//// kind: "a",
//// /*6*/
////})
verify.completions(
{ marker: "1", exact: [{ name: "world", sortText: completion.SortText.OptionalMember }] },
{ marker: "2", exact: [{ name: "autoIncrement", sortText: completion.SortText.OptionalMember }, { name: "keyPath", sortText: completion.SortText.OptionalMember }] },
{ marker: "3", exact: ["b", "g", "r"] },
{ marker: "4", exact: [{ name: "a", sortText: completion.SortText.OptionalMember }] },
{ marker: "5", exact: [{ name: "x", sortText: completion.SortText.OptionalMember }] },
{ marker: "6", exact: ["a"] },
); | {
"end_byte": 1783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralWithPartialConstraint.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralMethod5.ts_0_1118 | /// <reference path="fourslash.ts" />
// @newline: LF
// @Filename: a.ts
////interface Foo {
//// method(x?: string): void;
////}
////const foo: Foo = {
//// /*m*/
////}
verify.completions({
marker: "m",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "method",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "method"),
insertText: undefined,
},
{
name: "method",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "method")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
isSnippet: true,
insertText: "method(x) {\n $0\n},",
labelDetails: {
detail: "(x)",
},
},
],
});
| {
"end_byte": 1118,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralMethod5.ts"
} |
TypeScript/tests/cases/fourslash/formatDebuggerStatement.ts_0_270 | /// <reference path='fourslash.ts' />
////if(false){debugger;}
//// if ( false ) { debugger ; }
format.document();
goTo.bof();
verify.currentLineContentIs("if (false) { debugger; }");
goTo.eof();
verify.currentLineContentIs("if (false) { debugger; }"); | {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatDebuggerStatement.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForAliasedGeneric.ts_0_308 | /// <reference path='fourslash.ts'/>
////module M {
//// export module N {
//// export class C<T> { }
//// export class D { }
//// }
////}
////import d = M.N;
////var /*1*/aa: d.C<number>;
////var /*2*/bb: d.D;
verify.quickInfos({
1: "var aa: d.C<number>",
2: "var bb: d.D"
});
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForAliasedGeneric.ts"
} |
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations.ts_0_351 | /// <reference path='fourslash.ts'/>
/////*1*/interface /*2*/Foo {
////}
////
/////*3*/module /*4*/Foo {
//// export interface Bar { }
////}
////
/////*5*/function /*6*/Foo(): void {
////}
////
////var f1: /*7*/Foo.Bar;
////var f2: /*8*/Foo;
/////*9*/Foo.bind(this);
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9');
| {
"end_byte": 351,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingSuperCall1.ts_0_409 | /// <reference path='fourslash.ts' />
////class A {}
////class B extends A {
//// [|public constructor|]() {}
////}
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_missing_super_call.message }
])
verify.codeFix({
description: ts.Diagnostics.Add_missing_super_call.message,
newFileContent:
`class A {}
class B extends A {
public constructor() {
super();
}
}`
});
| {
"end_byte": 409,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingSuperCall1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanVariableStatementConditional.ts_0_624 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////let x = a.b ? /*a*//*b*/a.b.c : "whenFalse";
// verify that the refactor is offered for empty spans in variable statements.
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: 0 } };
let x = a.b?.c ?? "whenFalse";`,
triggerReason: "invoked"
}); | {
"end_byte": 624,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanVariableStatementConditional.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation3.ts_0_213 | /// <reference path='fourslash.ts'/>
// @strict: true
// @exactOptionalPropertyTypes: true
//// declare const xx: { prop?: number };
//// xx.prop/*1*/ ??= 1;
verify.quickInfoAt('1', '(property) prop?: number');
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction13.ts_0_365 | /// <reference path='fourslash.ts' />
// @target: es2015
////declare class Thenable { then(): void; }
////async function fn(): Thenable {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "Thenable", "void"],
newFileContent:
`declare class Thenable { then(): void; }
async function fn(): Promise<void> {}`
});
| {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction13.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties11.ts_0_706 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
//// interface IC {
//// a?: number
//// }
//// interface J {
//// a?: number | undefined
//// }
//// declare var j: J
//// class C {
//// ic: IC
//// m() { this.ic/**/ = 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 IC {
a?: number | undefined
}
interface J {
a?: number | undefined
}
declare var j: J
class C {
ic: IC
m() { this.ic = j }
}`,
});
| {
"end_byte": 706,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties11.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputNoErrors.ts_0_240 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputNoErrors.baseline
// @Filename: inputFile.ts
// @emitThisFile: true
//// var x;
//// class M {
//// x: number;
//// y: string;
//// }
verify.baselineGetEmitOutput(); | {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputNoErrors.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_defaultImport.ts_0_288 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export default function f() { }
////[|const x = f();|]
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export default function f() { }
`,
"/x.ts":
`import f from "./a";
const x = f();
`,
},
});
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_defaultImport.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports23.ts_0_617 | /// <reference path="fourslash.ts" />
//// import {abc, Abc, type bc, type Bc} from 'b';
//// import {
//// I,
//// R,
//// M,
//// } from 'a';
//// type x = bc | Bc;
//// console.log(abc, Abc, I, R, M);
verify.organizeImports(
`import {
I,
M,
R,
} from 'a';
import { abc, Abc, type bc, type Bc } from 'b';
type x = bc | Bc;
console.log(abc, Abc, I, R, M);`);
// organize already-organized imports to make sure output is stable
verify.organizeImports(
`import {
I,
M,
R,
} from 'a';
import { abc, Abc, type bc, type Bc } from 'b';
type x = bc | Bc;
console.log(abc, Abc, I, R, M);`);
| {
"end_byte": 617,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports23.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports_removeOnly.ts_0_372 | /// <reference path="fourslash.ts" />
//// import { c, b, a } from "foo";
//// import d, { e } from "bar";
//// import * as f from "baz";
//// import { g } from "foo";
////
//// export { g, e, b, c };
verify.organizeImports(
`import { c, b } from "foo";
import { e } from "bar";
import { g } from "foo";
export { g, e, b, c };`,
ts.OrganizeImportsMode.RemoveUnused);
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports_removeOnly.ts"
} |
TypeScript/tests/cases/fourslash/extract-export-assignment.ts_0_138 | /// <reference path="fourslash.ts" />
//// /*1*/export = 0;/*2*/
goTo.select("1", "2");
verify.not.refactorAvailable("Extract Symbol");
| {
"end_byte": 138,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-export-assignment.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlights_moduleImport_filesToSearch.ts_0_411 | /// <reference path="fourslash.ts" />
// @Filename: /node_modules/@types/foo/index.d.ts
////export const x: number;
// @Filename: /a.ts
////import * as foo from "foo";
////foo.[|x|];
// @Filename: /b.ts
////import { [|x|] } from "foo";
// @Filename: /c.ts
////import { x } from "foo";
const [r0, r1] = test.ranges();
verify.baselineDocumentHighlights(test.ranges(), { filesToSearch: ["/a.ts", "/b.ts"] });
| {
"end_byte": 411,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlights_moduleImport_filesToSearch.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_uriStyleNodeCoreModules2.ts_0_884 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /node_modules/@types/node/index.d.ts
//// declare module "fs" { function writeFile(): void }
//// declare module "fs/promises" { function writeFile(): Promise<void> }
//// declare module "node:fs" { export * from "fs"; }
//// declare module "node:fs/promises" { export * from "fs/promises"; }
// @Filename: /other.ts
//// import "node:fs/promises";
// @Filename: /index.ts
//// writeFile/**/
verify.importFixModuleSpecifiers("", ["node:fs", "node:fs/promises"]);
goTo.file("/other.ts");
edit.replaceLine(0, "\n");
goTo.file("/index.ts");
verify.importFixModuleSpecifiers("", ["fs", "fs/promises", "node:fs", "node:fs/promises"]);
goTo.file("/other.ts");
edit.replaceLine(0, `import "node:fs/promises";\n`);
goTo.file("/index.ts");
verify.importFixModuleSpecifiers("", ["node:fs", "node:fs/promises"]);
| {
"end_byte": 884,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_uriStyleNodeCoreModules2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnUndefined.ts_0_256 | /// <reference path='fourslash.ts'/>
////function foo(a: string) {
////}
////foo(/*1*/undefined);
////var x = {
//// undefined: 10
////};
////x./*2*/undefined = 30;
verify.quickInfos({
1: "var undefined",
2: "(property) undefined: number"
});
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnUndefined.ts"
} |
TypeScript/tests/cases/fourslash/completionImportModuleSpecifierEndingJsx.ts_0_465 | /// <reference path='fourslash.ts'/>
//@allowJs: true
//@jsx:preserve
//@Filename:test.jsx
//// export class Test { }
//@Filename:module.jsx
////import { Test } from ".//**/"
verify.completions({ marker: "", includes:{name:"test.jsx"}, preferences: {importModuleSpecifierEnding: "js"}, isNewIdentifierLocation: true});
verify.completions({ marker: "", includes:{name:"test"}, preferences: {importModuleSpecifierEnding: "index" }, isNewIdentifierLocation: true});
| {
"end_byte": 465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportModuleSpecifierEndingJsx.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingPropertyNameStartsWithHash.ts_0_462 | /// <reference path='fourslash.ts' />
////class A {
//// "#foo": number = 100;
//// constructor() {
//// [|this.foo = 1;|]
//// }
////}
verify.codeFixAvailable([
{ description: "Change spelling to '#foo'" },
{ description: "Declare property 'foo'" },
{ description: "Add index signature for property 'foo'" }
]);
verify.codeFix({
index: 0,
description: "Change spelling to '#foo'",
newRangeContent: 'this["#foo"] = 1;'
});
| {
"end_byte": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingPropertyNameStartsWithHash.ts"
} |
TypeScript/tests/cases/fourslash/getFileReferences2.ts_0_202 | /// <reference path="fourslash.ts" />
// @Filename: /project/a.ts
//// console.log("I'm a script!");
// @Filename: /project/b.ts
//// import "./a";
verify.baselineGetFileReferences("/project/a.ts");
| {
"end_byte": 202,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getFileReferences2.ts"
} |
TypeScript/tests/cases/fourslash/commentsMultiModuleMultiFileFourslash.ts_0_1002 | /// <reference path='fourslash.ts' />
// @Filename: commentsMultiModuleMultiFile_0.ts
/////** this is multi declare namespace*/
////namespace mult/*3*/iM {
//// /** class b*/
//// export class b {
//// }
////}
/////** thi is multi namespace 2*/
////namespace mu/*2*/ltiM {
//// /** class c comment*/
//// export class c {
//// }
////}
////
////new /*1*/mu/*4*/ltiM.b();
////new mu/*5*/ltiM.c();
// @Filename: commentsMultiModuleMultiFile_1.ts
/////** this is multi namespace 3 comment*/
////namespace mu/*6*/ltiM {
//// /** class d comment*/
//// export class d {
//// }
////}
////new /*7*/mu/*8*/ltiM.d();
const comment = "this is multi declare namespace\nthi is multi namespace 2\nthis is multi namespace 3 comment";
verify.completions({
marker: ["1", "7"],
includes: { name: "multiM", text: "namespace multiM", documentation: comment },
});
for (const marker of ["2", "3", "4", "5", "6", "8"]) {
verify.quickInfoAt(marker, "namespace multiM", comment);
}
| {
"end_byte": 1002,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsMultiModuleMultiFileFourslash.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageFunctionExpression.ts_0_519 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
//// const returnThisMember = function ([| |]) {
//// return this.member;
//// }
////
//// interface Container {
//// member: string;
//// returnThisMember(): string;
//// }
////
//// const container: Container = {
//// member: "sample",
//// returnThisMember: returnThisMember,
//// };
verify.codeFix({
description: "Infer 'this' type of 'returnThisMember' from usage",
index: 0,
newRangeContent: "this: Container ",
});
| {
"end_byte": 519,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionJsDocImportTag3.ts_0_248 | /// <reference path='fourslash.ts'/>
// @allowJS: true
// @checkJs: true
// @Filename: /b.ts
/////*2*/export interface A { }
// @Filename: /a.js
/////**
//// * @import { A } [|from /*1*/|] "./b";
//// */
verify.baselineGoToDefinition("1");
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsDocImportTag3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionPartialImplementation.ts_0_440 | /// <reference path='fourslash.ts' />
// @Filename: goToDefinitionPartialImplementation_1.ts
////module A {
//// export interface /*Part1Definition*/IA {
//// y: string;
//// }
////}
// @Filename: goToDefinitionPartialImplementation_2.ts
////module A {
//// export interface /*Part2Definition*/IA {
//// x: number;
//// }
////
//// var x: [|/*Part2Use*/IA|];
////}
verify.baselineGoToDefinition("Part2Use");
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionPartialImplementation.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedMethod.ts_0_660 | /// <reference path='fourslash.ts' />
////class Foo {
//// /*a*/bar/*b*/(t: string, s: string): string {
//// return s + t;
//// }
////}
////class Bar extends Foo { }
////var bar = new Bar();
////bar.bar("a", "b");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
}
}
class Bar extends Foo { }
var bar = new Bar();
bar.bar({ t: "a", s: "b" });`
}); | {
"end_byte": 660,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedMethod.ts"
} |
TypeScript/tests/cases/fourslash/extract-method34.ts_0_991 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export interface A {
//// x: number;
////}
// @Filename: /b.ts
////export interface B<T> {
//// payload: T;
////}
// @Filename: /c.ts
////import { A } from "./a";
////import { B } from "./b";
////export interface C<T> {
//// payload: T;
////}
////
////export const c: C<B<A>> = {
//// payload: {
//// payload: { x: 1 }
//// }
////}
// @Filename: /d.ts
////import { c } from "./c";
////
////function foo() {
//// const prop = c;
//// /*a*/console.log(prop);/*b*/
////}
goTo.file("/c.ts");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in module scope",
newContent:
`import { A } from "./a";
import { B } from "./b";
import { C, c } from "./c";
function foo() {
const prop = c;
/*RENAME*/newFunction(prop);
}
function newFunction(prop: C<B<A>>) {
console.log(prop);
}
`
});
| {
"end_byte": 991,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method34.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules7.ts_0_538 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/('');|]
// @Filename: package.json
//// { "dependencies": { "package-name": "0.0.1" } }
// @Filename: node_modules/package-name/bin/lib/libfile.d.ts
//// export declare function f1(text: string): string;
// @Filename: node_modules/package-name/bin/lib/libfile.js
//// function f1(text) {}
//// exports.f1 = f1;
// @Filename: node_modules/package-name/package.json
//// { "main": "bin/lib/libfile.js" }
verify.importFixAtPosition([
`import { f1 } from "package-name";
f1('');`
]); | {
"end_byte": 538,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules7.ts"
} |
TypeScript/tests/cases/fourslash/referencesForLabel4.ts_0_254 | /// <reference path='fourslash.ts'/>
// References to a label outside function bounderies
/////*1*/label: function foo(label) {
//// while (true) {
//// /*2*/break /*3*/label;
//// }
////}
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForLabel4.ts"
} |
TypeScript/tests/cases/fourslash/jsDocIndentationPreservation1.ts_0_299 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * Does some stuff.
//// * Second line.
//// * Third line.
//// */
////function foo/**/(){}
goTo.marker();
verify.quickInfoIs("function foo(): void", "Does some stuff.\n Second line.\n\tThird line.");
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocIndentationPreservation1.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputOut.ts_0_487 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputOut.baseline
// @outFile: out.js
// @Filename: my.d.ts
// @emitThisFile: false
////declare module foo.bar {
//// class Baz { }
////}
// @Filename: input0.ts
// @emitThisFile: false
/////// <reference path='my.d.ts' />
////module foo.bar {
//// var baz1 = <any>Baz.prototype; // Should emit as bar.Baz.prototype
////}
// @Filename: input1.ts
// @emitThisFile: true
////var x;
verify.baselineGetEmitOutput();
| {
"end_byte": 487,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputOut.ts"
} |
TypeScript/tests/cases/fourslash/completionListInStringLiterals1.ts_0_149 | /// <reference path="fourslash.ts" />
////"/*1*/ /*2*/\/*3*/
//// /*4*/ \\/*5*/
verify.completions({ marker: test.markers(), exact: [] });
| {
"end_byte": 149,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInStringLiterals1.ts"
} |
TypeScript/tests/cases/fourslash/jsDocTagsWithHyphen.ts_0_548 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: dummy.js
//// /**
//// * @typedef Product
//// * @property {string} title
//// * @property {boolean} h/*1*/igh-top some-comments
//// */
////
//// /**
//// * @type {Pro/*2*/duct}
//// */
//// const product = {
//// /*3*/
//// }
verify.quickInfoAt('1', '(property) high-top: boolean', 'some-comments');
verify.quickInfoAt('2', 'type Product = {\n title: string;\n "high-top": boolean;\n}');
verify.completions({
marker: ['3'],
includes: ['"high-top"']
});
| {
"end_byte": 548,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocTagsWithHyphen.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier3.ts_0_387 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
////[|import {
//// a, b, c, d, /** comment related to e */
//// e, f,
////} from "fs";|]
////
////a;
////b;
////c;
////e;
////f;
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'd'",
newRangeContent:
`import {
a, b, c, /** comment related to e */
e, f,
} from "fs";`
});
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoFunctionCheckType.ts_0_291 | ///<reference path="fourslash.ts" />
////export type /**/Tail<T extends any[]> = ((...t: T) => void) extends (h: any, ...rest: infer R) => void ? R : never;
verify.quickInfoAt("", "type Tail<T extends any[]> = ((...t: T) => void) extends (h: any, ...rest: infer R) => void ? R : never");
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoFunctionCheckType.ts"
} |
TypeScript/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts_0_733 | /// <reference path='fourslash.ts'/>
////class Base {
//// private privateMethod() { }
//// private privateProperty;
////
//// protected protectedMethod() { }
//// protected protectedProperty;
////
//// public publicMethod() { }
//// public publicProperty;
////
//// protected protectedOverriddenMethod() { }
//// protected protectedOverriddenProperty;
////}
////
////class C1 extends Base {
//// protected protectedOverriddenMethod() { }
//// protected protectedOverriddenProperty;
////}
////
//// var b: Base;
//// var c: C1;
//// b./*1*/;
//// c./*2*/;
// Only public properties are visible outside the class
verify.completions({ marker: ["1", "2"], exact: ["publicMethod", "publicProperty"] });
| {
"end_byte": 733,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsJsDocTypeDef.ts_0_317 | /// <reference path='fourslash.ts' />
// Just testing that this doesn't cause an exception due to the @typedef contents not having '.parent' set.
// But it isn't bound to a Symbol so find-all-refs will return nothing.
/////** @typedef {Object} /*0*/T */
////function foo() {}
verify.baselineFindAllReferences('0')
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocTypeDef.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunctionForTriggerReason1.ts_0_425 | /// <reference path='fourslash.ts' />
//// const a = (a: number) => { return/*a*//*b*/ a; };
// Only offer refactor for empty span in body if explicity requested
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Add or remove braces in an arrow function");
verify.refactorAvailableForTriggerReason("invoked", "Add or remove braces in an arrow function", "Remove braces from arrow function");
| {
"end_byte": 425,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunctionForTriggerReason1.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpFilteredTriggers03.ts_0_450 | /// <reference path="fourslash.ts" />
////declare class ViewJayEss {
//// constructor(obj: object);
////}
////new ViewJayEss({
//// methods: {
//// sayHello/**/
//// }
////});
goTo.marker();
edit.insert("(");
verify.noSignatureHelpForTriggerReason({
kind: "characterTyped",
triggerCharacter: "(",
});
edit.insert(") {},");
verify.noSignatureHelpForTriggerReason({
kind: "characterTyped",
triggerCharacter: ",",
});
| {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpFilteredTriggers03.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class2.ts_0_935 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: test123.js
////var foo = function() { };
////foo.prototype.instanceMethod1 = function() { return "this is name"; };
////foo.prototype.instanceMethod2 = () => { return "this is name"; };
////foo.instanceProp1 = "hello";
////foo.instanceProp2 = undefined;
////foo.staticProp = "world";
////foo.staticMethod1 = function() { return "this is static name"; };
////foo.staticMethod2 = () => "this is static name";
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class foo {
constructor() { }
static staticMethod1() { return "this is static name"; }
static staticMethod2() { return "this is static name"; }
instanceMethod1() { return "this is name"; }
instanceMethod2() { return "this is name"; }
}
foo.instanceProp1 = "hello";
foo.instanceProp2 = undefined;
foo.staticProp = "world";
`,
});
| {
"end_byte": 935,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceHeritageClauseAlreadyHaveMember.ts_0_577 | /// <reference path='fourslash.ts' />
//// class Base {
//// foo: number;
//// }
////
//// class D extends Base {
//// bar: number;
//// }
////
//// interface I {
//// foo: number;
//// bar: number;
//// baz: number;
//// }
////
//// class C extends D implements I { }
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`class Base {
foo: number;
}
class D extends Base {
bar: number;
}
interface I {
foo: number;
bar: number;
baz: number;
}
class C extends D implements I {
baz: number;
}`,
});
| {
"end_byte": 577,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceHeritageClauseAlreadyHaveMember.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes6.ts_0_219 | /// <reference path='fourslash.ts' />
////<string>0 * (4 + 3) / 100
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `<string><unknown>0 * (4 + 3) / 100`
});
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes6.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport.ts_0_308 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
////export default function /*def*/f() {}
// @Filename: b.ts
////import /*deg*/g from "./a";
////[|/*ref*/g|]();
// @Filename: c.ts
////import { f } from "./a";
verify.baselineFindAllReferences('def', 'deg');
verify.baselineGoToDefinition("ref");
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport.ts"
} |
TypeScript/tests/cases/fourslash/asConstRefsNoErrors1.ts_0_151 | /// <reference path="fourslash.ts" />
////class Tex {
//// type = 'Text' as /**/const;
////}
verify.baselineGoToDefinition("");
verify.noErrors(); | {
"end_byte": 151,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/asConstRefsNoErrors1.ts"
} |
TypeScript/tests/cases/fourslash/formattingTypeInfer.ts_0_1790 | /// <reference path='fourslash.ts'/>
////
/////*L1*/type C<T> = T extends Array<infer U> ? U : never;
////
/////*L2*/ type C < T > = T extends Array < infer U > ? U : never ;
////
/////*L3*/type C<T> = T extends Array<infer U> ? U : T;
////
/////*L4*/ type C < T > = T extends Array < infer U > ? U : T ;
////
/////*L5*/type Foo<T> = T extends { a: infer U, b: infer U } ? U : never;
////
/////*L6*/ type Foo < T > = T extends { a : infer U , b : infer U } ? U : never ;
////
/////*L7*/type Bar<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;
////
/////*L8*/ type Bar < T > = T extends { a : (x : infer U ) => void , b : (x : infer U ) => void } ? U : never ;
////
format.document();
goTo.marker("L1");
verify.currentLineContentIs("type C<T> = T extends Array<infer U> ? U : never;");
goTo.marker("L2");
verify.currentLineContentIs("type C<T> = T extends Array<infer U> ? U : never;");
goTo.marker("L3");
verify.currentLineContentIs("type C<T> = T extends Array<infer U> ? U : T;");
goTo.marker("L4");
verify.currentLineContentIs("type C<T> = T extends Array<infer U> ? U : T;");
goTo.marker("L5");
verify.currentLineContentIs("type Foo<T> = T extends { a: infer U, b: infer U } ? U : never;");
goTo.marker("L6");
verify.currentLineContentIs("type Foo<T> = T extends { a: infer U, b: infer U } ? U : never;");
goTo.marker("L7");
verify.currentLineContentIs("type Bar<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;");
goTo.marker("L8");
verify.currentLineContentIs("type Bar<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;"); | {
"end_byte": 1790,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingTypeInfer.ts"
} |
TypeScript/tests/cases/fourslash/autoImportCompletionExportListAugmentation4.ts_0_1589 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/@sapphire/pieces/index.d.ts
//// interface Container {
//// stores: unknown;
//// }
////
//// declare class Piece {
//// get container(): Container;
//// }
////
//// export { Piece as Alias, type Container };
// @Filename: /node_modules/@sapphire/framework/index.d.ts
//// import { Alias } from "@sapphire/pieces";
////
//// declare class Command extends Alias {}
////
//// declare module "@sapphire/pieces" {
//// interface Container {
//// client: unknown;
//// }
//// }
////
//// export { Command as CommandAlias };
// @Filename: /index.ts
//// import "@sapphire/pieces";
//// import { CommandAlias } from "@sapphire/framework";
//// class PingCommand extends CommandAlias {
//// /*1*/
//// }
const preferences = {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
};
verify.completions({
marker: "1",
includes: [
{
name: "container",
insertText: "get container(): Container {\n}",
filterText: "container",
hasAction: true,
source: "ClassMemberSnippet/",
},
],
preferences,
isNewIdentifierLocation: true,
});
verify.applyCodeActionFromCompletion("1", {
name: "container",
source: "ClassMemberSnippet/",
description: `Includes imports of types referenced by 'container'`,
newFileContent: `import "@sapphire/pieces";
import { CommandAlias } from "@sapphire/framework";
import { Container } from "@sapphire/pieces";
class PingCommand extends CommandAlias {
}`,
preferences,
}); | {
"end_byte": 1589,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportCompletionExportListAugmentation4.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationIfElse.ts_0_459 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_ifElse.baseline
// @Filename: bpSpan_ifElse.ts
////var i = 10;
////if (i == 10) {
//// i++;
////} else
////{
////}
////if (i == 10)
////{
//// i++;
////}
////else if (i == 20) {
//// i--;
////} else if (i == 30) {
//// i += 70;
////} else {
//// i--;
////}
////if (function foo() {
//// return 30;
////} ()) {
//// i++;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 459,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationIfElse.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesPrivate2.ts_0_1482 | /// <reference path='fourslash.ts' />
////module m {
//// export class C1 {
//// public pub1;
//// public pub2;
//// private priv1;
//// private priv2;
//// protected prot1;
//// protected prot2;
////
//// public public;
//// private private;
//// protected protected;
////
//// public constructor(public a, private b, protected c, public d, private e, protected f) {
//// this.public = 10;
//// this.private = 10;
//// this.protected = 10;
//// }
////
//// public get x() { return 10; }
//// public set x(value) { }
////
//// public static statPub;
//// private static statPriv;
//// protected static statProt;
//// }
////
//// export interface I1 {
//// }
////
//// export declare module ma.m1.m2.m3 {
//// interface I2 {
//// }
//// }
////
//// export module mb.m1.m2.m3 {
//// declare var foo;
////
//// export class C2 {
//// public pub1;
//// [|private|] priv1;
//// protected prot1;
////
//// protected constructor(public public, protected protected, [|private|] private) {
//// public = private = protected;
//// }
//// }
//// }
////
//// declare var ambientThing: number;
//// export var exportedThing = 10;
//// declare function foo(): string;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 1482,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesPrivate2.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesTryCatchFinally3.ts_0_282 | /// <reference path='fourslash.ts' />
////try {
//// try {
//// }
//// catch (x) {
//// }
////
//// [|t/*1*/r/*2*/y|] {
//// }
//// [|finall/*3*/y|] {
//// }
////}
////catch (e) {
////}
////finally {
////}
verify.baselineDocumentHighlights(test.markers()); | {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesTryCatchFinally3.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_infers.ts_0_247 | /// <reference path='fourslash.ts' />
//// type UType = 1;
//// type Bar<T> = T extends { a: (x: infer /*1*/) => void; b: (x: infer U/*2*/) => void }
//// ? U
//// : never;
verify.completions({ marker: test.markers(), exact: undefined });
| {
"end_byte": 247,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_infers.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports17.ts_0_397 | /// <reference path="fourslash.ts" />
//// import { Both } from "module-specifiers-unsorted";
//// import { aa, CaseInsensitively, sorted } from "aardvark";
verify.organizeImports(
`import { aa, CaseInsensitively, sorted } from "aardvark";
import { Both } from "module-specifiers-unsorted";
`,
ts.OrganizeImportsMode.SortAndCombine,
{
organizeImportsIgnoreCase: "auto",
}
);
| {
"end_byte": 397,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports17.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAmbientClassExtendAbstractMethod_all.ts_0_555 | /// <reference path='fourslash.ts' />
////abstract class A {
//// abstract m(): void;
//// abstract n(): void;
////}
////declare class B extends A {}
////declare class C extends A {}
verify.codeFixAll({
fixId: "fixClassDoesntImplementInheritedAbstractMember",
fixAllDescription: "Implement all inherited abstract classes",
newFileContent:
`abstract class A {
abstract m(): void;
abstract n(): void;
}
declare class B extends A {
m(): void;
n(): void;
}
declare class C extends A {
m(): void;
n(): void;
}`,
});
| {
"end_byte": 555,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAmbientClassExtendAbstractMethod_all.ts"
} |
TypeScript/tests/cases/fourslash/jsdocTypedefTagServices.ts_0_594 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
/////**
//// * Doc comment
//// * [|@typedef /*def*/[|{| "contextRangeIndex": 0 |}Product|]
//// * @property {string} title
//// |]*/
/////**
//// * @type {[|/*use*/Product|]}
//// */
////const product = null;
const desc = `type Product = {
title: string;
}`;
const [r0Def, ...ranges] = test.ranges();
verify.quickInfoAt("use", desc, "Doc comment");
verify.baselineFindAllReferences("use", "def");
verify.baselineRename(ranges);
verify.baselineDocumentHighlights(ranges);
verify.baselineGoToDefinition("use");
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocTypedefTagServices.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType58.ts_0_188 | /// <reference path='fourslash.ts' />
//// interface I { f: (this: O, b: number) => /*a*/ true | this | false /*b*/ };
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type") | {
"end_byte": 188,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType58.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_nonExportedImports.ts_0_552 | /// <reference path='fourslash.ts' />
//@Filename: /bar.ts
////import './someFile';
////
////const q = 20;
// @Filename: /a.ts
////import { b } from './other';
////const p = 0;
////[|const y: Date = p + b;|]
// @Filename: /other.ts
////export const b = 2;
verify.moveToFile({
newFileContents: {
"/a.ts":
`export const p = 0;
`,
"/bar.ts":
`import { p } from './a';
import { b } from './other';
import './someFile';
const q = 20;
const y: Date = p + b;
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
});
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_nonExportedImports.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableFunctionResult.ts_0_472 | /// <reference path="fourslash.ts" />
////function inc(x: number) { return x + 1; }
////const /*a*/y/*b*/ = inc(1);
////const z = y + 1;
////const w = inc(y);
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `function inc(x: number) { return x + 1; }
const z = inc(1) + 1;
const w = inc(inc(1));`
}); | {
"end_byte": 472,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableFunctionResult.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString12.ts_0_346 | /// <reference path='fourslash.ts' />
////const a = /*x*/`x` + `y` + text + `z`/*y*/;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: "const a = `xy${text}z`;"
});
| {
"end_byte": 346,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString12.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts_0_229 | /// <reference path="fourslash.ts" />
////let v = 100;
////let x = /absidey/
/////**/
// Should not be blocked since there is a
// newline separating us from the regex flags.
verify.completions({ marker: "", includes: "v" });
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts"
} |
TypeScript/tests/cases/fourslash/extract-method8.ts_0_401 | /// <reference path='fourslash.ts' />
// You cannot extract an exported function declaration
//// namespace ns {
//// /*a*/export function fn() {
////
//// }
//// fn();
//// /*b*/
//// }
goTo.select('a', 'b');
verify.not.refactorAvailable("Extract Symbol");
edit.deleteAtCaret('export'.length);
goTo.select('a', 'b');
verify.refactorAvailable("Extract Symbol", 'function_scope_0');
| {
"end_byte": 401,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method8.ts"
} |
TypeScript/tests/cases/fourslash/completionsDefaultKeywordWhenDefaultExportAvailable.ts_0_336 | /// <reference path="fourslash.ts" />
// https://github.com/microsoft/TypeScript/issues/3229
// @filename: index.ts
//// export default function () {}
//// def/*1*/
verify.completions(
{
marker: "1",
includes: [{ name: "default", kind: "keyword", sortText: completion.SortText.GlobalsOrKeywords }],
},
);
| {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsDefaultKeywordWhenDefaultExportAvailable.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_reExports1.ts_0_516 | /// <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":
`export function foo() { }
`,
"/b.ts":
`export function baz() { }
export function bar() { }
export {
foo,
} from "./a";`,
},
interactiveRefactorArguments: { targetFile: "/b.ts" },
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_reExports1.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionYield2.ts_0_215 | /// <reference path="fourslash.ts" />
//// function* outerGen() {
//// function* /*end*/gen() {
//// [|/*start*/yield|] 0;
//// }
//// return gen
//// }
verify.baselineGoToDefinition("start");
| {
"end_byte": 215,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionYield2.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.