_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/inlineVariableMultipleScopes.ts_0_417 | /// <reference path="fourslash.ts" />
////let /*a*/x/*b*/ = 1;
////function foo() {
//// console.log(x);
////}
////const y = x + 2;
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `function foo() {
console.log(1);
}
const y = 1 + 2;`
}); | {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableMultipleScopes.ts"
} |
TypeScript/tests/cases/fourslash/duplicatePackageServices_fileChanges.ts_0_1519 | /// <reference path='fourslash.ts'/>
// @noImplicitReferences: true
// @Filename: /node_modules/a/index.d.ts
////import X from "x";
////export function a(x: X): void;
// @Filename: /node_modules/a/node_modules/x/index.d.ts
////export default class /*defAX*/X {
//// private x: number;
////}
// @Filename: /node_modules/a/node_modules/x/package.json
////{ "name": "x", "version": "1.2./*aVersionPatch*/3" }
// @Filename: /node_modules/b/index.d.ts
////import X from "x";
////export const b: X;
// @Filename: /node_modules/b/node_modules/x/index.d.ts
////export default class /*defBX*/X {
//// private x: number;
////}
// @Filename: /node_modules/b/node_modules/x/package.json
////{ "name": "x", "version": "1.2./*bVersionPatch*/3" }
// @Filename: /src/a.ts
////import { a } from "a";
////import { b } from "b";
////a(/*error*/b);
goTo.file("/src/a.ts");
verify.numberOfErrorsInCurrentFile(0);
testChangeAndChangeBack("aVersionPatch", "defAX");
testChangeAndChangeBack("bVersionPatch", "defBX");
function testChangeAndChangeBack(versionPatch: string, def: string) {
goTo.marker(versionPatch);
edit.insert("4");
goTo.marker(def);
edit.insert(" ");
// No longer have identical packageId, so we get errors.
verify.errorExistsAfterMarker("error");
// Undo the change.
goTo.marker(versionPatch);
edit.deleteAtCaret();
goTo.marker(def);
edit.deleteAtCaret();
// Back to being identical.
goTo.file("/src/a.ts");
verify.numberOfErrorsInCurrentFile(0);
}
| {
"end_byte": 1519,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/duplicatePackageServices_fileChanges.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesTryCatchFinally2.ts_0_283 | /// <reference path='fourslash.ts' />
////try {
//// [|t/*1*/r/*2*/y|] {
//// }
//// [|c/*3*/atch|] (x) {
//// }
////
//// try {
//// }
//// finally {
//// }
////}
////catch (e) {
////}
////finally {
////}
verify.baselineDocumentHighlights(test.markers()); | {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesTryCatchFinally2.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionInstanceof2.ts_0_288 | /// <reference path="fourslash.ts" />
// @lib: esnext
// @filename: /main.ts
//// class C {
//// static /*end*/[Symbol.hasInstance](value: unknown): boolean { return true; }
//// }
//// declare var obj: any;
//// obj [|/*start*/instanceof|] C;
verify.baselineGoToDefinition("start");
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionInstanceof2.ts"
} |
TypeScript/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts_0_135 | /// <reference path="fourslash.ts" />
////1 ? fun/*1*/
////function func () {}
verify.completions({ marker: "1", includes: "func" });
| {
"end_byte": 135,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes7.ts_0_203 | /// <reference path='fourslash.ts' />
////<string>["words"]
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `<string><unknown>["words"]`
});
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes7.ts"
} |
TypeScript/tests/cases/fourslash/jsxGenericQuickInfo.tsx_0_1314 | /// <reference path="fourslash.ts" />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props }
//// }
//// interface PropsA<T> {
//// /** comments for A */
//// name: 'A',
//// items: T[];
//// renderItem: (item: T) => string;
//// }
//// interface PropsB<T> {
//// /** comments for B */
//// name: 'B',
//// items: T[];
//// renderItem: (item: T) => string;
//// }
//// class Component<T> {
//// constructor(props: PropsA<T> | PropsB<T>) {}
//// props: PropsA<T> | PropsB<T>;
//// }
//// var b = new Component({items: [0, 1, 2], render/*0*/Item: it/*1*/em => item.toFixed(), name/*2*/: 'A',});
//// var c = <Component items={[0, 1, 2]} render/*3*/Item={it/*4*/em => item.toFixed()} name/*5*/="A" />
verify.quickInfoAt("0", "(property) PropsA<number>.renderItem: (item: number) => string");
verify.quickInfoAt("1", "(parameter) item: number");
verify.quickInfoAt("2", `(property) PropsA<T>.name: "A"`, 'comments for A');
verify.quickInfoAt("3", "(property) PropsA<number>.renderItem: (item: number) => string");
verify.quickInfoAt("4", "(parameter) item: number");
verify.quickInfoAt("5", `(property) PropsA<T>.name: "A"`, 'comments for A');
| {
"end_byte": 1314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxGenericQuickInfo.tsx"
} |
TypeScript/tests/cases/fourslash/extract-method9.ts_0_203 | /// <reference path='fourslash.ts' />
//// function f() {
//// /*a*/function q() { }
//// q();/*b*/
//// q();
//// }
goTo.select('a', 'b');
verify.not.refactorAvailable("Extract Symbol");
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method9.ts"
} |
TypeScript/tests/cases/fourslash/completionsLiterals.ts_0_699 | /// <reference path="fourslash.ts" />
////const x: 0 | "one" = /**/;
////const y: 0 | "one" | 1n = /*1*/;
////const y2: 0 | "one" | 1n = 'one'/*2*/;
verify.completions({
marker: "",
includes: [
{ name: "0", kind: "string", text: "0" },
{ name: '"one"', kind: "string", text: '"one"' },
],
isNewIdentifierLocation: true,
});
verify.completions({
marker: "1",
includes: [
{ name: "0", kind: "string", text: "0" },
{ name: '"one"', kind: "string", text: '"one"' },
{ name: "1n", kind: "string", text: "1n" },
],
isNewIdentifierLocation: true,
});
verify.completions({
marker: "2",
excludes: [
'"one"'
],
});
| {
"end_byte": 699,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiterals.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsJsx1.ts_0_1269 | /// <reference path="fourslash.ts"/>
// @Filename: file1.tsx
////let x = <div a = "some-value" b = {1}>
//// some jsx text
////</div>;
////
////let y = <element attr="123"/>
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("let"), c.identifier("x"), c.operator("="),
c.punctuation("<"),
c.jsxOpenTagName("div"),
c.jsxAttribute("a"), c.operator("="), c.jsxAttributeStringLiteralValue(`"some-value"`),
c.jsxAttribute("b"), c.operator("="), c.punctuation("{"), c.numericLiteral("1"), c.punctuation("}"),
c.punctuation(">"),
c.jsxText(`
some jsx text
`),
c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"),
c.keyword("let"), c.identifier("y"), c.operator("="),
c.punctuation("<"),
c.jsxSelfClosingTagName("element"),
c.jsxAttribute("attr"), c.operator("="), c.jsxAttributeStringLiteralValue(`"123"`),
c.punctuation("/"), c.punctuation(">")
)
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
);
| {
"end_byte": 1269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsJsx1.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts_0_235 | /// <reference path="fourslash.ts" />
////let v = 100;
////let x = /absidey//**/
// Should get nothing at the marker since it's
// going to be considered part of the regex flags.
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts"
} |
TypeScript/tests/cases/fourslash/renameImportRequire.ts_0_477 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////[|import [|{| "contextRangeIndex": 0 |}e|] = require("mod4");|]
////[|e|];
////a = { [|e|] };
////[|export { [|{| "contextRangeIndex": 4 |}e|] };|]
// @Filename: /b.ts
////[|import { [|{| "contextRangeIndex": 6 |}e|] } from "./a";|]
////[|export { [|{| "contextRangeIndex": 8 |}e|] };|]
const [r0Def, r0, r1, r2, r3Def, r3, r4Def, r4, r5Def, r5] = test.ranges();
verify.baselineRename([r0, r1, r2, r3, r4, r5]);
| {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportRequire.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType59.ts_0_218 | /// <reference path='fourslash.ts' />
//// class C {
//// m<T>(): /*a*/T | this | number/*b*/ {
//// return {} as any
//// }
//// }
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type")
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType59.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString13.ts_0_431 | /// <reference path='fourslash.ts' />
////fetch(/*start*/process.env.API_URL + `/foo/bar?id=${id}&token=${token}`/*end*/);
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: "fetch(`${process.env.API_URL}/foo/bar?id=${id}&token=${token}`);",
});
| {
"end_byte": 431,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString13.ts"
} |
TypeScript/tests/cases/fourslash/superCallError0.ts_0_238 | /// <reference path="fourslash.ts" />
////class T5<T>{
//// constructor(public bar: T) { }
////}
////class T6 extends T5<number>{
//// constructor() {
//// super();
//// }
////}/*1*/
goTo.marker("1");
edit.insert('/n'); | {
"end_byte": 238,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/superCallError0.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_global1.ts_0_290 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const x = y;
////[|const y = x;|]
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`import { y } from "./y";
export const x = y;
`,
"/y.ts":
`import { x } from "./a";
export const y = x;
`,
},
});
| {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_global1.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports16.ts_0_923 | /// <reference path="fourslash.ts" />
//// import { a, A, b } from "foo";
//// interface Use extends A {}
//// console.log(a, b);
verify.organizeImports(
`import { a, A, b } from "foo";
interface Use extends A {}
console.log(a, b);`);
edit.replaceLine(0, 'import { a, A, b } from "foo1";');
verify.organizeImports(
`import { a, A, b } from "foo1";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto" });
edit.replaceLine(0, 'import { a, A, b } from "foo2";');
verify.organizeImports(
`import { a, A, b } from "foo2";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true });
edit.replaceLine(0, 'import { a, A, b } from "foo3";');
verify.organizeImports(
`import { A, a, b } from "foo3";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false }); | {
"end_byte": 923,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports16.ts"
} |
TypeScript/tests/cases/fourslash/jsxExpressionWithCommaExpression.ts_0_339 | /// <reference path="fourslash.ts" />
//@Filename: jsxExpressionWithCommaExpression.tsx
//@jsx: react
////declare var React: any;
////declare var x: string;
////const a = <div x={[|x, x|]} />
////const b = <div>{[|x, x|]}</div>
verify.getSyntacticDiagnostics([]);
test.ranges().forEach(range => verify.errorExistsAtRange(range, 18006));
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxExpressionWithCommaExpression.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnreachableCode_noSuggestionIfDisabled.ts_0_127 | /// <reference path='fourslash.ts' />
// @allowUnreachableCode: true
////if (false) 0;
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 127,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnreachableCode_noSuggestionIfDisabled.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionYield3.ts_0_272 | /// <reference path="fourslash.ts" />
//// class C {
//// notAGenerator() {
//// [|/*start1*/yield|] 0;
//// }
////
//// foo*/*end2*/() {
//// [|/*start2*/yield|] 0;
//// }
//// }
verify.baselineGoToDefinition(
"start1",
"start2",
);
| {
"end_byte": 272,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionYield3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocThisTag.ts_0_172 | /// <reference path="fourslash.ts" />
// @strict: true
// @filename: /a.ts
/////** @this {number} */
////function f/**/() {
//// this
////}
verify.baselineQuickInfo();
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocThisTag.ts"
} |
TypeScript/tests/cases/fourslash/commentsBlocks.ts_0_1145 | /// <reference path='fourslash.ts' />
/////*1*/// 1
////var x,
//// /*2*/// 2
//// y,
/////*3*/ /* %3 */
//// z;
////
/////*4*/ // 4
////switch (x) {
/////*5*/ // 5
//// case 1:
/////*6*/ // 6
//// break;
/////*7*/ // 7
//// case 2:
/////*8*/ // 8
////}
////
/////*9*/ // 9
////if (true)
/////*10*/ // 10
//// ;
/////*11*/ // 11
////else {
/////*12*/ // 12
////}
format.document();
goTo.marker('1');
verify.currentLineContentIs("// 1");
goTo.marker('2');
verify.currentLineContentIs(" // 2");
goTo.marker('3');
verify.currentLineContentIs(" /* %3 */");
goTo.marker('4');
verify.currentLineContentIs("// 4");
goTo.marker('5');
verify.currentLineContentIs(" // 5");
goTo.marker('6');
verify.currentLineContentIs(" // 6");
goTo.marker('7');
verify.currentLineContentIs(" // 7");
goTo.marker('8');
verify.currentLineContentIs(" // 8");
goTo.marker('9');
verify.currentLineContentIs("// 9");
goTo.marker('10');
verify.currentLineContentIs(" // 10");
goTo.marker('11');
verify.currentLineContentIs("// 11");
goTo.marker('12');
verify.currentLineContentIs(" // 12"); | {
"end_byte": 1145,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsBlocks.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeUnion.ts_0_430 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function existing<T, U>(value: T | U & string) {
//// added/*1*/(value);
////}
goTo.marker("1");
verify.codeFix({
description: "Add missing function declaration 'added'",
index: 0,
newFileContent: `function existing<T, U>(value: T | U & string) {
added(value);
}
function added<T>(value: T) {
throw new Error("Function not implemented.");
}
`,
});
| {
"end_byte": 430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeUnion.ts"
} |
TypeScript/tests/cases/fourslash/indentationNone.ts_0_3464 | /// <reference path="fourslash.ts"/>
////
////module classes {
////{| "indent": 0 |}
//// class Bar {
////{| "indent": 0 |}
////
//// constructor() {
////{| "indent": 0 |}
//// }
////
//// private foo: string = "";
////{| "indent": 0 |}
////
//// private f() {
//// var a: any[] = [[1, 2], [3, 4], 5];
////{| "indent": 0 |}
//// return ((1 + 1));
//// }
////
////{| "indent": 0 |}
//// private f2() {
//// if (true) { } { };
//// }
//// }
////}
////
////
////module interfaces {
////{| "indent": 0 |}
//// interface Foo {
////{| "indent": 0 |}
////
//// x: number;
////{| "indent": 0 |}
////
//// foo(): number;
////{| "indent": 0 |}
//// }
////}
////
////
////module nestedModules {
//// module Foo2 {
////{| "indent": 0 |}
//// function f() {
//// }
////{| "indent": 0 |}
//// var x: number;
////{| "indent": 0 |}
//// }
////}
////
////
////module Enums {
//// enum Foo3 {
////{| "indent": 0 |}
//// val1,
////{| "indent": 0 |}
//// val2,
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
////}
////
////
////function controlStatements() {
//// for (var i = 0; i < 10; i++) {
////{| "indent": 0 |}
//// }
////
//// for (var e in foo.bar) {
////{| "indent": 0 |}
//// }
////
//// with (foo.bar) {
////{| "indent": 0 |}
//// }
////
//// while (false) {
////{| "indent": 0 |}
//// }
////
//// do {
////{| "indent": 0 |}
//// } while (false);
////
//// switch (foo.bar) {
////{| "indent": 0 |}
//// }
////
//// switch (foo.bar) {
////{| "indent": 0 |}
//// case 1:
////{| "indent": 0 |}
//// break;
//// default:
////{| "indent": 0 |}
//// break;
//// }
////}
////
////
////function tryCatch() {
////{| "indent": 0 |}
//// try {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
//// catch (err) {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
////}
////
////
////function tryFinally() {
////{| "indent": 0 |}
//// try {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
//// finally {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
////}
////
////
////function tryCatchFinally() {
////{| "indent": 0 |}
//// try {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
//// catch (err) {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
//// finally {
////{| "indent": 0 |}
//// }
////{| "indent": 0 |}
////}
////
////
////class indentBeforeCurly
////{| "indent": 0 |}
////{| "indent": 0 |}{
////{| "indent": 0 |}
////}
////
////
////function argumentsListIndentation(bar,
//// blah,
//// {| "indent": 0 |}
////);
////
////
////function blockIndentAfterIndentedParameter1(bar,
//// blah) {
////{| "indent": 0 |}
////}
////
////
////function blockIndentAfterIndentedParameter2(bar,
//// blah) {
//// if (foo) {
////{| "indent": 0 |}
//// }
////}
////
////
////// Note: Do not add more tests at the end of this file, as
////// the purpose of this test is to verity smart indent
////// works for unterminated function arguments at the end of a file.
////function unterminatedListIndentation(a,
////{| "indent": 0 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, ts.IndentStyle.None);
});
| {
"end_byte": 3464,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationNone.ts"
} |
TypeScript/tests/cases/fourslash/fixNaNEquality3.ts_0_223 | /// <reference path="fourslash.ts" />
////declare const x: number;
////[|if (x !== NaN) {}|]
verify.codeFix({
index: 0,
description: "Use `!Number.isNaN(x)`.",
newRangeContent: "if (!Number.isNaN(x)) {}",
});
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixNaNEquality3.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefix3.ts_0_185 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function ...q) {}} f(10);
verify.codeFixAvailable([
{ description: "Add missing function declaration 'f'" }
]);
| {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefix3.ts"
} |
TypeScript/tests/cases/fourslash/commentsEnumsFourslash.ts_0_1210 | /// <reference path='fourslash.ts' />
/////** Enum of colors*/
////enum /*1*/Colors {
//// /** Fancy name for 'blue'*/
//// /*2*/Cornflower,
//// /** Fancy name for 'pink'*/
//// /*3*/FancyPink
////}
////var /*4*/x = /*5*/Colors./*6*/Cornflower;
////x = Colors./*7*/FancyPink;
verify.quickInfos({
1: ["enum Colors", "Enum of colors"],
2: ["(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'"],
3: ["(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'"],
4: "var x: Colors",
5: ["enum Colors", "Enum of colors"],
6: ["(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'"],
7: ["(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'"],
});
verify.completions(
{
marker: "5",
includes: { name: "Colors", text: "enum Colors", documentation: "Enum of colors" },
isNewIdentifierLocation: true,
},
{
marker: ["6", "7"],
exact: [
{ name: "Cornflower", text: "(enum member) Colors.Cornflower = 0", documentation: "Fancy name for 'blue'" },
{ name: "FancyPink", text: "(enum member) Colors.FancyPink = 1", documentation: "Fancy name for 'pink'" },
]
},
);
| {
"end_byte": 1210,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsEnumsFourslash.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts_0_317 | /// <reference path='fourslash.ts' />
////function /*1*/f/*2*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4); | {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_this.ts_0_496 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*w*/unction() {
//// this.bar = "F-Express";
//// return this.bar;
//// };
goTo.select("x", "w");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
| {
"end_byte": 496,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_this.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts_0_258 | // @strict: true
/// <reference path='fourslash.ts' />
//// function f(x: [|number?|]) {
//// }
verify.codeFix({
description: "Change 'number?' to 'number | undefined'",
errorCode: 17019,
index: 0,
newRangeContent: "number | undefined",
});
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction_all.ts_0_484 | /// <reference path='fourslash.ts' />
////function f() {
//// await Promise.resolve();
//// await Promise.resolve();
////}
////
////const g = () => {
//// await f();
//// await f();
////}
verify.codeFixAll({
fixId: "fixAwaitInSyncFunction",
fixAllDescription: "Add all missing 'async' modifiers",
newFileContent:
`async function f() {
await Promise.resolve();
await Promise.resolve();
}
const g = async () => {
await f();
await f();
}`,
});
| {
"end_byte": 484,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction_all.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType17.ts_0_921 | /// <reference path='fourslash.ts' />
////class F1 {
//// /*a*//*b*/method() {
//// return { x: 1, y: 1 };
//// }
////}
////class F2 {
//// met/*c*//*d*/hod(){
//// return { x: 1, y: 1 };
//// }
////}
////class F3 {
//// method(/*e*//*f*/) {
//// return { x: 1, y: 1 };
//// }
////}
////class F4 {
//// method() {
//// return { x: 1, y: 1 /*g*//*h*/};
//// }
////}
////class F5 {
//// method() {
//// return { x: 1, y: 1 /*i*//*j*/};
//// }
////}
goTo.select("a", "b");
verify.refactorAvailable("Infer function return type");
goTo.select("c", "d");
verify.refactorAvailable("Infer function return type");
goTo.select("e", "f");
verify.refactorAvailable("Infer function return type");
goTo.select("g", "h");
verify.not.refactorAvailable("Infer function return type");
goTo.select("i", "j");
verify.not.refactorAvailable("Infer function return type");
| {
"end_byte": 921,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType17.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnModuleIndentation.ts_0_347 | /// <reference path='fourslash.ts' />
//// module Foo {
//// export module A . B . C { }/**/
//// }
format.document();
goTo.bof();
verify.currentLineContentIs("module Foo {");
goTo.marker();
verify.currentLineContentIs(" export module A.B.C { }");
goTo.eof();
verify.currentLineContentIs("}"); | {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnModuleIndentation.ts"
} |
TypeScript/tests/cases/fourslash/formattingInDestructuring4.ts_0_460 | /// <reference path='fourslash.ts'/>
/////*1*/const {
/////*2*/ a,
/////*3*/ b,
/////*4*/} = { a: 1, b: 2 };
format.setOption('InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces', false);
format.document();
goTo.marker("1");
verify.currentLineContentIs("const {");
goTo.marker("2");
verify.currentLineContentIs(" a,");
goTo.marker("3");
verify.currentLineContentIs(" b,");
goTo.marker("4");
verify.currentLineContentIs("} = {a: 1, b: 2};"); | {
"end_byte": 460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingInDestructuring4.ts"
} |
TypeScript/tests/cases/fourslash/formattingInExpressionsInTsx.ts_0_289 | /// <reference path="fourslash.ts"/>
// @Filename: test.tsx
////import * as React from "react";
////<div
//// autoComplete={(function () {
////return true/*1*/
//// })() }
//// >
////</div>
goTo.marker("1");
edit.insert(";");
verify.currentLineContentIs(" return true;"); | {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingInExpressionsInTsx.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration7.ts_0_515 | /// <reference path='fourslash.ts' />
////namespace Foo {
//// export const x = 0;
////}
////
////Foo.test();
////Foo.test();
////Foo.test();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "test"],
applyChanges: true,
newFileContent:
`namespace Foo {
export const x = 0;
export function test() {
throw new Error("Function not implemented.");
}
}
Foo.test();
Foo.test();
Foo.test();`
});
verify.not.codeFixAvailable();
| {
"end_byte": 515,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration7.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines8.ts_0_471 | // #37813
/// <reference path="fourslash.ts" />
////function foo() {
//// /*1*/var x: number
////
//// x = 10;
//// return x;/*2*/
////}
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function foo() {
return /*RENAME*/newFunction();
}
function newFunction() {
var x: number;
x = 10;
return x;
}
`
});
| {
"end_byte": 471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines8.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConstToLet_all2.ts_0_327 | /// <reference path="fourslash.ts" />
////const a = 1;
////a = 2;
////a = 3;
////
////const b = 1;
////b = 2;
////b = 3;
verify.codeFixAll({
fixId: "fixConvertConstToLet",
fixAllDescription: ts.Diagnostics.Convert_all_const_to_let.message,
newFileContent:
`let a = 1;
a = 2;
a = 3;
let b = 1;
b = 2;
b = 3;`
});
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConstToLet_all2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction15.ts_3_358 | / <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: MyType) => /*1*/
////}
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });
| {
"end_byte": 358,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction15.ts"
} |
TypeScript/tests/cases/fourslash/completionsRedeclareModuleAsGlobal.ts_0_793 | /// <reference path="fourslash.ts" />
// 32675 - if this fails there are two copies of assert in completions
// @esModuleInterop: true,
// @target: esnext
// @Filename: /myAssert.d.ts
////declare function assert(value:any, message?:string):void;
////export = assert;
////export as namespace assert;
// @Filename: /ambient.d.ts
////import assert from './myAssert';
////
////type Assert = typeof assert;
////
////declare global {
//// const assert: Assert;
////}
// @Filename: /index.ts
/////// <reference path="./ambient.d.ts" />
////asser/**/;
verify.completions({
marker: "",
includes: [
{
name: "assert",
sortText: completion.SortText.GlobalsOrKeywords
}
],
preferences: { includeCompletionsForModuleExports: true, includeInsertTextCompletions: true }
});
| {
"end_byte": 793,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRedeclareModuleAsGlobal.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_Typed.ts_0_392 | /// <reference path='fourslash.ts' />
//// let isFoo = /*x*/(/*y*/n: number): boolean => n === 42;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `function isFoo(n: number): boolean {
return n === 42;
}`,
});
| {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_Typed.ts"
} |
TypeScript/tests/cases/fourslash/esModuleInteropFindAllReferences.ts_0_270 | /// <reference path="fourslash.ts"/>
// @esModuleInterop: true
// @Filename: /abc.d.ts
////declare module "a" {
//// /*1*/export const /*2*/x: number;
////}
// @Filename: /b.ts
////import a from "a";
////a./*3*/x;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/esModuleInteropFindAllReferences.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsEnumMember.ts_0_147 | /// <reference path="fourslash.ts"/>
////enum E { /*1*/A, B }
////const e: E./*2*/A = E./*3*/A;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsEnumMember.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namespaceToNamed1.ts_0_399 | /// <reference path='fourslash.ts' />
/////*a*/import * as m from "m";/*b*/
////const a = 0;
////m.a;
////m.b;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert namespace import to named imports",
actionDescription: "Convert namespace import to named imports",
newContent:
`import { a as a_1, b } from "m";
const a = 0;
a_1;
b;`,
});
| {
"end_byte": 399,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namespaceToNamed1.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash5.ts_0_225 | /// <reference path="fourslash.ts"/>
//// /// <reference
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"));
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash5.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_badRestParam.ts_0_528 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////function /*a*/gen<T extends any[]>/*b*/(a: boolean, ...b: T): T {
//// return b;
////}
////gen(false);
////gen(false, 1);
////gen(true, 1, "two");
// @Filename: b.ts
////function /*c*/un/*d*/(a: boolean, ...b: number[] | [string, string]) {
//// return b;
////}
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object");
goTo.select("c", "d");
verify.not.refactorAvailable("Convert parameters to destructured object"); | {
"end_byte": 528,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_badRestParam.ts"
} |
TypeScript/tests/cases/fourslash/codeFixExtendsInterfaceBecomesImplements.ts_0_256 | /// <reference path='fourslash.ts' />
//// interface I {}
//// [|/* */ class /* */ C /* */ extends /* */ I|]{}
verify.codeFix({
description: "Change 'extends' to 'implements'",
newRangeContent: "/* */ class /* */ C /* */ implements /* */ I",
});
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixExtendsInterfaceBecomesImplements.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedIndexSignature01.ts_0_295 | /// <reference path='fourslash.ts' />
////class C {
////[x: string
////{| "indent": 4 |}
////
// Note that we currently do NOT indent further in an index signature.
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
}); | {
"end_byte": 295,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedIndexSignature01.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts_0_102 | /// <reference path='fourslash.ts'/>
////if (true)
/////**/
goTo.marker();
verify.indentationIs(4);
| {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts"
} |
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts_0_777 | /// <reference path='fourslash.ts' />
// Exercises completions for absolute paths.
// @Filename: tests/test0.ts
//// /// <reference path="/tests/cases/f/*0*/
// @Filename: tests/test1.ts
//// /// <reference path="/tests/cases/fourslash/*1*/
// @Filename: tests/test2.ts
//// /// <reference path="/tests/cases/fourslash//*2*/
// @Filename: f1.ts
//// /*f1*/
// @Filename: f2.tsx
//// /*f2*/
// @Filename: folder/f1.ts
//// /*subf1*/
// @Filename: f3.js
//// /*f3*/
// @Filename: f4.jsx
//// /*f4*/
// @Filename: e1.ts
//// /*e1*/
// @Filename: e2.js
//// /*e2*/
verify.completions(
{ marker: ["0", "1"], exact: "fourslash", isNewIdentifierLocation: true },
{ marker: "2", exact: ["e1.ts", "f1.ts", "f2.tsx", "folder", "tests"], isNewIdentifierLocation: true },
);
| {
"end_byte": 777,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts"
} |
TypeScript/tests/cases/fourslash/renameObjectSpreadAssignment.ts_0_343 | /// <reference path='fourslash.ts'/>
////interface A1 { a: number };
////interface A2 { a?: number };
////[|let [|{| "contextRangeIndex": 0 |}a1|]: A1;|]
////[|let [|{| "contextRangeIndex": 2 |}a2|]: A2;|]
////let a12 = { ...[|a1|], ...[|a2|] };
const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges();
verify.baselineRename([r0, r2, r1, r3]);
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameObjectSpreadAssignment.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts_0_329 | /// <reference path='fourslash.ts' />
////interface I<X> {
//// [Ƚ: string]: X;
////}
////
////class C implements I<number> {}
verify.codeFix({
description: "Implement interface 'I<number>'",
newFileContent:
`interface I<X> {
[Ƚ: string]: X;
}
class C implements I<number> {
[Ƚ: string]: number;
}`,
});
| {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_refactorAvailable1.ts_0_366 | /// <reference path='fourslash.ts' />
////namespace ns {
//// /*a*/export function fn() {
//// }
//// fn();
//// /*b*/
////}
goTo.select("a", "b");
verify.not.refactorAvailable("Move to file",
/*actionName*/ undefined,
/*actionDescription*/ undefined,
/*kind*/ undefined,
{
allowTextChangesInNewFiles : true
},
/*includeInteractiveActions*/ true);
| {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_refactorAvailable1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsTypedef.ts_0_256 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////**
//// * @typedef I {Object}
//// * /*1*/@prop /*2*/p {number}
//// */
////
/////** @type {I} */
////let x;
////x./*3*/p;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsTypedef.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_pathsWithoutBaseUrl1.ts_0_407 | /// <reference path="fourslash.ts" />
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "paths": {
//// "@app/*": ["./lib/*"]
//// }
//// }
//// }
// @Filename: index.ts
//// utils/**/
// @Filename: lib/utils.ts
//// export const utils = {};
goTo.marker("");
verify.importFixAtPosition([`import { utils } from "@app/utils";\n\nutils`]);
| {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_pathsWithoutBaseUrl1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageJsDocNewDocsClass.ts_0_680 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitThis: true
// @Filename: /consumesType.js
////function [|returnThisMember|]() {
//// return this.member;
////}
////
////class Container {
//// member = "sample";
//// returnThisMember = returnThisMember;
////};
////
////container.returnThisMember();
verify.codeFix({
description: "Infer 'this' type of 'returnThisMember' from usage",
index: 0,
newFileContent: `/**
* @this {Container}
*/
function returnThisMember() {
return this.member;
}
class Container {
member = "sample";
returnThisMember = returnThisMember;
};
container.returnThisMember();`
});
| {
"end_byte": 680,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageJsDocNewDocsClass.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_templateLiteral.ts_0_611 | /// <reference path='fourslash.ts' />
////function /*a*/insert/*b*/(template: string, overwriteBefore = 0) {}
////insert(`this is \${not} a substitution`);
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: [
'function insert({ template, overwriteBefore = 0 }: { template: string; overwriteBefore?: number; }) {}',
'insert({ template: `this is \\${not} a substitution` });'
].join('\n')
});
| {
"end_byte": 611,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_templateLiteral.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts_0_347 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithEmitterErrors.baseline
// @declaration: true
// @Filename: inputFile.ts
// @emitThisFile: true
////module M {
//// class C { }
//// export var foo = new C();
////}
// Only generate javscript file. The semantic error should not affect it
verify.baselineGetEmitOutput(); | {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc6.ts_0_299 | /// <reference path='fourslash.ts' />
////declare class C {
//// /** @type {number | null} */
//// p;
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 0,
newFileContent:
`declare class C {
/** @type {number | null} */
p: number | null;
}`,
});
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc6.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_loneVariableDeclaration.ts_0_93 | /// <reference path="fourslash.ts" />
////const /**/x = 3;
verify.baselineSmartSelection(); | {
"end_byte": 93,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_loneVariableDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics22.ts_0_139 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
//// function foo(...a) {}
verify.getSemanticDiagnostics([]);
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics22.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts_0_1249 | /// <reference path='fourslash.ts' />
////declare function foo1<T>(obj: T, settings: (row: T) => { value: string, func?: Function }): void;
////
////foo1(new Error(),
//// o/*1*/ => ({
//// value: o.name,
//// func: x => 'foo'
//// })
////);
////
////declare function foo2<T>(settings: (row: T) => { value: string, func?: Function }, obj: T): void;
////
////foo2(o/*2*/ => ({
//// value: o.name,
//// func: x => 'foo'
//// }),
//// new Error(),
////);
////
////declare function foof<T extends { name: string }, U extends keyof T>(settings: (row: T) => { value: T[U], func?: Function }, obj: T, key: U): U;
////
////function q<T extends { name: string }>(x: T): T["name"] {
//// return foof/*3*/(o => ({ value: o.name, func: x => 'foo' }), x, "name");
////}
////
////foof/*4*/(o => ({ value: o.name, func: x => 'foo' }), new Error(), "name");
verify.quickInfos({
1: "(parameter) o: Error",
2: "(parameter) o: Error",
3: `function foof<T, "name">(settings: (row: T) => {
value: T["name"];
func?: Function;
}, obj: T, key: "name"): "name"`,
4: `function foof<Error, "name">(settings: (row: Error) => {
value: string;
func?: Function;
}, obj: Error, key: "name"): "name"`
});
| {
"end_byte": 1249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import1.ts_0_522 | /// <reference path='fourslash.ts' />
// @esModuleInterop: true
// @Filename: foo.d.ts
////declare function foo(): void;
////declare namespace foo {}
////export = foo;
// @Filename: index.ts
////import * as foo from "./foo";
////function invoke(f: () => void) { f(); }
////invoke([|foo|]);
goTo.file(1);
verify.codeFix({
description: `Replace import with 'import foo = require("./foo");'.`,
newFileContent: `import foo = require("./foo");
function invoke(f: () => void) { f(); }
invoke(foo);`,
index: 1,
});
| {
"end_byte": 522,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import1.ts"
} |
TypeScript/tests/cases/fourslash/completionListInImportClause02.ts_0_288 | /// <reference path='fourslash.ts'/>
////declare module "M1" {
//// export var V;
////}
////
////declare module "M2" {
//// import { /**/ } from "M1"
////}
verify.completions({ marker: "", exact: [
"V",
{ name: "type", sortText: completion.SortText.GlobalsOrKeywords },
] });
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInImportClause02.ts"
} |
TypeScript/tests/cases/fourslash/extractFunctionWithSyntheticNodes.ts_0_1739 | /// <reference path="fourslash.ts" />
// @filename: /project/tsconfig.json
//// {}
// @filename: /project/index.esm.d.ts
//// export declare class Chart {
//// constructor(config: ChartConfiguration);
//// }
////
//// export interface ChartConfiguration {
//// options?: Partial<TickOptions>;
//// }
////
//// export interface TickOptions {
//// callback: (this: Scale, tickValue: number | string) => string | string[] | number | number[] | null | undefined;
//// }
////
//// export interface CoreScaleOptions {
//// opt: boolean;
//// }
////
//// export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> {
//// opts: O;
//// getLabelForValue(value: number): string;
//// }
// @filename: /project/options.ts
//// import { Chart } from './index.esm';
////
//// const chart = new Chart({
//// options: {
//// callback(tickValue) {
//// /*a*/const value = this.getLabelForValue(tickValue as number);/*b*/
//// return '$' + value;
//// }
//// }
//// });
goTo.file("/project/options.ts");
verify.noErrors();
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in method 'callback'",
newContent:
`import { Chart } from './index.esm';
const chart = new Chart({
options: {
callback(tickValue) {
const value = /*RENAME*/newFunction.call(this);
return '$' + value;
function newFunction(this: import("/project/index.esm").Scale<import("/project/index.esm").CoreScaleOptions>) {
return this.getLabelForValue(tickValue as number);
}
}
}
});`
});
| {
"end_byte": 1739,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractFunctionWithSyntheticNodes.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpFunctionParameter.ts_0_580 | /// <reference path='fourslash.ts' />
////function parameterFunction(callback: (a: number, b: string) => void) {
//// callback(/*parameterFunction1*/5, /*parameterFunction2*/"");
////}
verify.signatureHelp(
{
marker: "parameterFunction1",
text: "callback(a: number, b: string): void",
parameterCount: 2,
parameterName: "a",
parameterSpan: "a: number",
},
{
marker: "parameterFunction2",
text: "callback(a: number, b: string): void",
parameterName: "b",
parameterSpan: "b: string",
},
);
| {
"end_byte": 580,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpFunctionParameter.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_jsxOpeningTagImportDefault.ts_0_396 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @jsx: react-jsx
// @Filename: /component.tsx
//// export default function (props: any) {}
// @Filename: /index.tsx
//// export function Index() {
//// return <Component/**/ />;
//// }
goTo.marker("");
verify.importFixAtPosition([`import Component from "./component";
export function Index() {
return <Component />;
}`]);
| {
"end_byte": 396,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_jsxOpeningTagImportDefault.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionPrimitives.ts_0_116 | /// <reference path='fourslash.ts' />
////var x: st/*primitive*/ring;
verify.baselineGoToDefinition("primitive");
| {
"end_byte": 116,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionPrimitives.ts"
} |
TypeScript/tests/cases/fourslash/extract-method21.ts_0_617 | /// <reference path='fourslash.ts' />
// Extracting from a static method should create a static method
//// class Foo {
//// static method() {
//// /*start*/return 1;/*end*/
//// }
//// }
goTo.select('start', 'end')
verify.refactorAvailable('Extract Symbol', 'function_scope_1');
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to method in class 'Foo'",
newContent:
`class Foo {
static method() {
return Foo./*RENAME*/newMethod();
}
private static newMethod() {
return 1;
}
}`
});
| {
"end_byte": 617,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method21.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingParam4.ts_0_239 | /// <reference path="fourslash.ts" />
////[|function f() {}|]
////
////f("");
verify.codeFix({
description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"],
index: 0,
newRangeContent: "function f(p0: string) {}"
});
| {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam4.ts"
} |
TypeScript/tests/cases/fourslash/noCompletionsForCurrentOrLaterParametersInDefaults.ts_0_851 | /// <reference path='fourslash.ts' />
//// function f1(a = /*1*/, b) { }
//// function f2(a = a/*2*/, b) { }
//// function f3(a = a + /*3*/, b = a/*4*/, c = /*5*/) { }
//// function f3(a) {
//// function f4(b = /*6*/, c) { }
//// }
//// const f5 = (a, b = (c = /*7*/, e) => { }, d = b) => { }
////
//// type A1<K = /*T1*/, L> = K
verify.completions({
marker: ["1", "2"],
excludes: ["a", "b"],
})
verify.completions({
marker: ["3"],
excludes: ["a", "b"],
})
verify.completions({
marker: ["4"],
includes: ["a"],
})
verify.completions({
marker: ["5"],
includes: ["a", "b"],
})
verify.completions({
marker: ["6"],
excludes: ["b", "c"],
includes: ["a"],
})
verify.completions({
marker: ["7"],
includes: ["a", "b", "d"],
})
verify.completions({
marker: ["T1"],
excludes: ["K", "L"],
})
| {
"end_byte": 851,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noCompletionsForCurrentOrLaterParametersInDefaults.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts_3_670 | / <reference path='fourslash.ts'/>
// @Filename: file1.ts
//// class Foo {
//// // This is not valid syntax: parameter property can't be binding pattern
//// constructor(private [[|privateParam|]]: number,
//// public [[|publicParam|]]: string,
//// protected [[|protectedParam|]]: boolean) {
////
//// let localPrivate = [|privateParam|];
//// this.privateParam += 10;
////
//// let localPublic = [|publicParam|];
//// this.publicParam += " Hello!";
////
//// let localProtected = [|protectedParam|];
//// this.protectedParam = false;
//// }
//// }
verify.baselineDocumentHighlights();
| {
"end_byte": 670,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageImplicitAny.ts_0_591 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
////function returnThisMember([| |]) {
//// return this.member;
//// }
////
//// interface Container {
//// member: string;
//// returnThisMember(): string;
//// }
////
//// let container;
//// container = {
//// member: "sample",
//// returnThisMember: returnThisMember,
//// };
////
//// container.returnThisMember();
verify.codeFix({
description: "Infer 'this' type of 'returnThisMember' from usage",
index: 0,
newRangeContent: "this: { member: string; returnThisMember: () => any; } ",
});
| {
"end_byte": 591,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageImplicitAny.ts"
} |
TypeScript/tests/cases/fourslash/classInterfaceInsert.ts_0_422 | /// <reference path="fourslash.ts" />
//// interface Intersection {
//// dist: number;
//// }
//// /*interfaceGoesHere*/
//// class /*className*/Sphere {
//// constructor(private center) {
//// }
//// }
verify.quickInfoAt("className", "class Sphere");
goTo.marker('interfaceGoesHere');
edit.insert("\ninterface Surface {\n reflect: () => number;\n}\n");
verify.quickInfoAt("className", "class Sphere");
| {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/classInterfaceInsert.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnCommaOperator.ts_0_335 | /// <reference path='fourslash.ts' />
////var v1 = ((1, 2, 3), 4, 5, (6, 7));/*1*/
////function f1() {
//// var a = 1;
//// return a, v1, a;/*2*/
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs("var v1 = ((1, 2, 3), 4, 5, (6, 7));");
goTo.marker("2");
verify.currentLineContentIs(" return a, v1, a;"); | {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnCommaOperator.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts_0_1436 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export type A = number;
////export const A = 42;
////export type B = number;
////export const B = 42;
////
////type C = number;
////const C = 42;
////export type { C };
////type D = number;
////const D = 42;
////export { type D ];
// @Filename: /b.ts
////import type { A/*1*/ } from './a';
////import { type B/*2*/ } from './a';
////import { C/*3*/, D/*4*/ } from './a';
////export type { A/*5*/ } from './a';
////export { type B/*6*/ } from './a';
////export { C/*7*/, D/*8*/ } from './a';
verify.quickInfoAt("1", [
"(alias) type A = number",
"(alias) const A: 42",
"import A",
].join("\n"));
verify.quickInfoAt("2", [
"(alias) type B = number",
"(alias) const B: 42",
"import B",
].join("\n"));
verify.quickInfoAt("3", [
"(alias) type C = number",
"(alias) const C: 42",
"import C",
].join("\n"));
verify.quickInfoAt("4", [
"(alias) type D = number",
"(alias) const D: 42",
"import D",
].join("\n"));
verify.quickInfoAt("5", [
"(alias) type A = number",
"(alias) const A: 42",
"export A",
].join("\n"));
verify.quickInfoAt("6", [
"(alias) type B = number",
"(alias) const B: 42",
"export B",
].join("\n"));
verify.quickInfoAt("7", [
"(alias) type C = number",
"(alias) const C: 42",
"export C",
].join("\n"));
verify.quickInfoAt("8", [
"(alias) type D = number",
"(alias) const D: 42",
"export D",
].join("\n"));
| {
"end_byte": 1436,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypeOnlyImportExport.ts"
} |
TypeScript/tests/cases/fourslash/completionListObjectMembers.ts_0_370 | /// <reference path="fourslash.ts" />
//// var object: {
//// (bar: any): any;
//// new (bar: any): any;
//// [bar: any]: any;
//// bar: any;
//// foo(bar: any): any;
//// };
////object./**/
verify.completions({
marker: "",
includes: [{ name: "bar", text: "(property) bar: any" }, { name: "foo", text: "(method) foo(bar: any): any" }],
});
| {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListObjectMembers.ts"
} |
TypeScript/tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts_0_186 | /// <reference path="./fourslash.ts" />
////interface Foo {}
////type Bar = {};
////
////let x: Foo<"/*1*/">;
////let y: Bar<"/*2*/">;
verify.completions({ marker: test.markers() });
| {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts"
} |
TypeScript/tests/cases/fourslash/quickfixAddMissingConstraint_all.ts_0_1493 | /// <reference path="fourslash.ts" />
// @strict: true
// @filename: /bar.ts
////export type Bar = Record<string, string>
////export function bar<T extends Bar>(obj: { prop: T }) {}
// @filename: /foo.ts
////import { bar } from "./bar";
////
////export function f1<T>(x: T) {
//// bar({ prop: x })
////}
////
////function f2<T>(x: T) {
//// const y: `${number}` = x;
////}
////
////interface Fn<T extends string> {}
////function f3<T>(x: Fn<T>) {
////}
////
////function f4<T = `${number}`>(x: T) {
//// const y: `${number}` = x;
////}
////
////interface TypeRef<T extends {}> {
//// x: T
////}
////function f5<T>(): TypeRef</**/T> {
//// throw undefined as any as TypeRef<T>;
////}
goTo.file("/foo.ts");
verify.codeFixAll({
fixId: "addMissingConstraint",
fixAllDescription: ts.Diagnostics.Add_extends_constraint_to_all_type_parameters.message,
newFileContent:
"import { bar } from \"./bar\";\n\n" +
"export function f1<T extends Bar>(x: T) {\n" +
" bar({ prop: x })\n" +
"}\n\n" +
"function f2<T extends \`${number}\`>(x: T) {\n" +
" const y: `${number}` = x;\n" +
"}\n\n" +
"interface Fn<T extends string> {}\n" +
"function f3<T extends string>(x: Fn<T>) {\n" +
"}\n\n" +
"function f4<T extends `${number}` = `${number}`>(x: T) {\n" +
" const y: `${number}` = x;\n" +
"}\n\n" +
"interface TypeRef<T extends {}> {\n" +
" x: T\n" +
"}\n" +
"function f5<T extends {}>(): TypeRef<T> {\n" +
" throw undefined as any as TypeRef<T>;\n" +
"}"
});
| {
"end_byte": 1493,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixAddMissingConstraint_all.ts"
} |
TypeScript/tests/cases/fourslash/codeFixPropertyAssignment3.ts_0_275 | /// <reference path='fourslash.ts'/>
////const a = {
//// x: 1,
//// y /**/= 1,
//// z: 1
////}
verify.codeFix({
description: [ts.Diagnostics.Change_0_to_1.message, "=", ":"],
index: 0,
newFileContent:
`const a = {
x: 1,
y: 1,
z: 1
}`,
});
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixPropertyAssignment3.ts"
} |
TypeScript/tests/cases/fourslash/getRenameInfoTests2.ts_0_124 | /// <reference path="fourslash.ts"/>
////class C /**/extends null {
////
////}
goTo.marker("");
verify.renameInfoFailed(); | {
"end_byte": 124,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getRenameInfoTests2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes_all.ts_0_1073 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////interface P {
//// a: number;
//// b: string;
//// c: number[];
//// d: any;
////}
////const A = ({ a, b, c, d }: P) =>
//// <div>{a}{b}{c}{d}</div>;
////const props = { a: 1, b: "" };
////
////const C1 = () =>
//// <A a={1} b={""}></A>
////const C2 = () =>
//// <A {...props}></A>
////const C3 = () =>
//// <A c={[]} {...props}></A>
////const C4 = () =>
//// <A></A>
goTo.file("foo.tsx");
verify.codeFixAll({
fixId: "fixMissingAttributes",
fixAllDescription: ts.Diagnostics.Add_all_missing_attributes.message,
newFileContent:
`interface P {
a: number;
b: string;
c: number[];
d: any;
}
const A = ({ a, b, c, d }: P) =>
<div>{a}{b}{c}{d}</div>;
const props = { a: 1, b: "" };
const C1 = () =>
<A a={1} b={""} c={[]} d={undefined}></A>
const C2 = () =>
<A c={[]} d={undefined} {...props}></A>
const C3 = () =>
<A d={undefined} c={[]} {...props}></A>
const C4 = () =>
<A a={0} b={""} c={[]} d={undefined}></A>`
});
| {
"end_byte": 1073,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes_all.ts"
} |
TypeScript/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts_0_298 | /// <reference path='fourslash.ts' />
////module M {
//// export class C { public pub = 0; private priv = 1; }
//// export var V = 0;
////}
////
////
////var c = new M.C();
////
////c. // test on c.
////
//////Test for comment
//////c./**/
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts_0_455 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputDeclarationSingleFile.baseline
// @declaration: true
// @outFile: declSingleFile.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": 455,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionDecorator.ts_0_499 | /// <reference path='fourslash.ts' />
// @Filename: b.ts
////@[|/*decoratorUse*/decorator|]
////class C {
//// @[|decora/*decoratorFactoryUse*/torFactory|](a, "22", true)
//// method() {}
////}
// @Filename: a.ts
////function /*decoratorDefinition*/decorator(target) {
//// return target;
////}
////function /*decoratorFactoryDefinition*/decoratorFactory(...args) {
//// return target => target;
////}
verify.baselineGoToDefinition(
"decoratorUse",
"decoratorFactoryUse",
);
| {
"end_byte": 499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDecorator.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString3.ts_0_337 | /// <reference path='fourslash.ts' />
////const foo = /*start*/`` + ""/*end*/;
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: "const foo = ``;"
});
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString3.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags5.ts_0_274 | /// <reference path="fourslash.ts" />
/////**
//// * @callback Foo
//// * @param {string} data
//// * @param {/**/number} [index] - comment
//// * @return {boolean}
//// */
////
/////** @type {Foo} */
////const foo = s => !(s.length % 2);
verify.baselineSmartSelection();
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags5.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationParenCallOrNewExpressions.ts_0_889 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_parenCallOrNewExpressions.baseline
// @Filename: bpSpan_parenCallOrNewExpressions.ts
////function foo(a: number) {
//// return a;
////}
////foo((function bar() {
//// return foo(40);
////})());
////var y = foo((function () {
//// return foo(40);
////})());;
////class greeter {
//// constructor(a: number) {
//// }
////}
////foo(30);
////foo(40 + y);
////y = foo(30);
////y = foo(500 + y);
////new greeter((function bar() {
//// return foo(40);
////})());
////var anotherGreeter = new greeter((function bar() {
//// return foo(40);
////})());
////anotherGreeter = new greeter(30);
////anotherGreeter = new greeter(40 + y);
////new greeter(30);
////new greeter(40 + y);
////function foo2(x: number, y: string) {
////}
////foo2(foo(30), foo(40).toString());
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 889,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationParenCallOrNewExpressions.ts"
} |
TypeScript/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts_0_259 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
/////** /*1*/@typedef {number} /*2*/T */
/////*3*/const /*4*/T = 1;
/////** @type {/*5*/T} */
////const n = /*6*/T;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6');
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyle3.ts_0_314 | /// <reference path="fourslash.ts" />
//// [|export { v2 } from './module2';
////
//// f1/*0*/();|]
// @Filename: module1.ts
//// export function f1() {}
// @Filename: module2.ts
//// export var v2 = 6;
verify.importFixAtPosition([
`import { f1 } from './module1';
export { v2 } from './module2';
f1();`
]);
| {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyle3.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType28.ts_0_386 | /// <reference path='fourslash.ts' />
//// type Item<T> = /*a*/T/*b*/ extends (infer P)[] ? P : 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> = T;
type Item<T> = NewType<T> extends (infer P)[] ? P : never;`,
});
| {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType28.ts"
} |
TypeScript/tests/cases/fourslash/completionsGenericIndexedAccess5.ts_0_650 | /// <reference path="fourslash.ts" />
////interface CustomElements {
//// 'component-one': {
//// foo?: string;
//// },
//// 'component-two': {
//// bar?: string;
//// }
////}
////
////interface Options<T extends keyof CustomElements> {
//// props?: {} & { x: CustomElements[(T extends string ? T : never) & string][] }['x'];
////}
////
////declare function f<T extends keyof CustomElements>(k: T, options: Options<T>): void;
////
////f("component-one", {
//// props: [{
//// /**/
//// }]
////})
verify.completions({
marker: "",
exact: [{
name: "foo",
sortText: completion.SortText.OptionalMember
}]
});
| {
"end_byte": 650,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericIndexedAccess5.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatement1.ts_0_1132 | /// <reference path='fourslash.ts' />
////interface Robot {
//// name: string;
//// skill: string;
////}
////declare var console: {
//// log(msg: string): void;
////}
////var hello = "hello";
////var robotA: Robot = { name: "mower", skill: "mowing" };
////var robotB: Robot = { name: "trimmer", skill: "trimming" };
////var a: string, { name: nameA } = robotA;
////var b: string, { name: nameB, skill: skillB } = robotB;
////var c: string, { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
////
////var { name: nameA } = robotA, a = hello;
////var { name: nameB, skill: skillB } = robotB, b = " hello";
////var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }, c = hello;
////
////var a = hello, { name: nameA } = robotA, a1= "hello";
////var b = hello, { name: nameB, skill: skillB } = robotB, b1 = "hello";
////var c = hello, { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }, c1 = hello;
////if (nameA == nameB) {
//// console.log(skillB);
////}
////else {
//// console.log(nameC);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 1132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatement1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageString.ts_0_326 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function foo([|p, a, b |]) {
//// var x
//// p.charAt(x)
//// a.charAt(0)
//// b.concat('hi')
//// }
verify.rangeAfterCodeFix("p: string, a: string, b: string | any[]", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
| {
"end_byte": 326,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageString.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterNumericLiteral1.ts_0_196 | /// <reference path="fourslash.ts" />
////5../**/
verify.completions({ marker: "", exact: [
"toExponential",
"toFixed",
"toLocaleString",
"toPrecision",
"toString",
"valueOf",
] });
| {
"end_byte": 196,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterNumericLiteral1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam5.ts_0_259 | /// <reference path="fourslash.ts" />
////[|const f = function () {}|]
////
////f("");
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"],
index: 1,
newRangeContent: "const f = function (p0?: string) {}"
});
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs_allowSyntheticDefaultImports_all.ts_0_469 | /// <reference path='fourslash.ts' />
// @allowSyntheticDefaultImports: true
// @Filename: /a.ts
////const a = [|require("a")|];
////const b = [|require("b")|];
////const { c } = [|require("c")|];
////const { d } = [|require("d")|];
verify.codeFixAll({
fixId: "requireInTs",
fixAllDescription: ts.Diagnostics.Convert_all_require_to_import.message,
newFileContent:
`import a from "a";
import b from "b";
import { c } from "c";
import { d } from "d";`,
});
| {
"end_byte": 469,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs_allowSyntheticDefaultImports_all.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts_0_934 | /// <reference path='fourslash.ts' />
// @module: esnext
// @verbatimModuleSyntax: true
// @Filename: types1.ts
////type A = {};
////export default A;
// @Filename: types2.ts
////export type B = {};
////export type C = {};
////export type D<T> = {};
// @Filename: interface.ts
////import type A from './types1';
////import type { B, C, D } from './types2';
////
////export interface Base {
//// a: A;
//// b<T extends B = B>(p1: C): D<C>;
////}
// @Filename: index.ts
////import type { Base } from './interface';
////
////export class C implements Base {[| |]}
goTo.file('index.ts');
verify.codeFix({
description: "Implement interface 'Base'",
newFileContent:
`import type { Base } from './interface';
import type A from './types1';
import type { B, C, D } from './types2';
export class C implements Base {
a: A;
b<T extends B = B>(p1: C): D<C> {
throw new Error('Method not implemented.');
}
}`,
});
| {
"end_byte": 934,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarNestedObjectLiterals.ts_0_2506 | /// <reference path="fourslash.ts"/>
////var a = {
//// b: 0,
//// c: {},
//// d: {
//// e: 1,
//// },
//// f: {
//// g: 2,
//// h: {
//// i: 3,
//// },
//// },
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var",
"childItems": [
{
"text": "b",
"kind": "property"
},
{
"text": "c",
"kind": "property"
},
{
"text": "d",
"kind": "property",
"childItems": [
{
"text": "e",
"kind": "property"
}
]
},
{
"text": "f",
"kind": "property",
"childItems": [
{
"text": "g",
"kind": "property"
},
{
"text": "h",
"kind": "property",
"childItems": [
{
"text": "i",
"kind": "property"
}
]
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var"
}
]
},
{
"text": "a",
"kind": "var",
"childItems": [
{
"text": "b",
"kind": "property"
},
{
"text": "c",
"kind": "property"
},
{
"text": "d",
"kind": "property"
},
{
"text": "f",
"kind": "property"
}
],
"indent": 1
},
{
"text": "d",
"kind": "property",
"childItems": [
{
"text": "e",
"kind": "property"
}
],
"indent": 2
},
{
"text": "f",
"kind": "property",
"childItems": [
{
"text": "g",
"kind": "property"
},
{
"text": "h",
"kind": "property"
}
],
"indent": 2
},
{
"text": "h",
"kind": "property",
"childItems": [
{
"text": "i",
"kind": "property"
}
],
"indent": 3
}
]); | {
"end_byte": 2506,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarNestedObjectLiterals.ts"
} |
TypeScript/tests/cases/fourslash/superInDerivedTypeOfGenericWithStatics.ts_0_395 | /// <reference path='fourslash.ts'/>
////module M {
//// export class C<T extends Date> {
//// static foo(): C<Date> {
//// return null;
//// }
//// }
////}
////class D extends M.C<Date> {
//// constructor() {
//// /**/ // was an error appearing on super in editing scenarios
//// }
////}
goTo.marker();
edit.insert('super();');
verify.noErrors(); | {
"end_byte": 395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/superInDerivedTypeOfGenericWithStatics.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.