_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/completionListInObjectLiteral8.ts_0_343 | /// <reference path="fourslash.ts" />
////declare function test<
//// Variants extends Partial<Record<'hover' | 'pressed', string>>,
////>(v: Variants): void
////
////test({
//// hover: "",
//// /**/
////});
verify.completions({
marker: '',
exact: [{
name: 'pressed',
sortText: completion.SortText.OptionalMember
}]
});
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral8.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard9.ts_0_525 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @allowJs: true
// @maxNodeModuleJsDepth: 1
// @Filename: /node_modules/foo/package.json
//// {
//// "name": "foo",
//// "exports": {
//// "./*": "./dist/*.js"
//// }
//// }
// @Filename: /node_modules/foo/dist/blah.js
//// export const blah = 0;
// @Filename: /index.mts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{ name: "blah", kind: "script", kindModifiers: "" },
]
});
| {
"end_byte": 525,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard9.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag7.ts_0_470 | /// <reference path="fourslash.ts" />
// @strict: true
////interface I {
//// /** @deprecated a */
//// a: number;
////}
////const foo = {
//// a: 1
////}
////const i: I = {
//// ...foo,
//// /**/
////}
verify.completions({
marker: "",
exact: [{
name: "a",
sortText: completion.SortText.Deprecated(completion.SortText.MemberDeclaredBySpreadAssignment),
kind: 'property',
kindModifiers: "deprecated"
}]
});
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag7.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentMissingBracketsWhileKeyword.ts_0_117 | /// <reference path='fourslash.ts'/>
////while /*1*/
goTo.marker("1");
edit.insert("\n");
verify.indentationIs(4);
| {
"end_byte": 117,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentMissingBracketsWhileKeyword.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_moduleDotExports.ts_0_551 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////module.exports = function() {}
////module.exports = function f() {}
////module.exports = class {}
////module.exports = class C {}
////module.exports = 0;
// See also `refactorConvertToEs6Module_export_moduleDotExportsEqualsRequire.ts`
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`export default function() {}
export default function f() {}
export default class {}
export default class C {}
export default 0;`,
});
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_moduleDotExports.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties18.ts_0_430 | /// <reference path='fourslash.ts' />
////interface Bar {
//// a: number;
////}
////
////interface Foo<T, U> {
//// foo(a: T): U;
////}
////[|const x: Foo<string, Bar> = {};|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent: `const x: Foo<string, Bar> = {
foo: function(a: string): Bar {
throw new Error("Function not implemented.");
}
};`,
});
| {
"end_byte": 430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties18.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_require_importVsRequire_moduleTarget.ts_0_872 | // If the module target is es2015+ and the file has no existing CommonJS
// indicators, use `import` declarations.
// @allowJs: true
// @checkJs: true
// @module: es2015
// @Filename: a.js
////export const x = 0;
// @Filename: index.js
////x
goTo.file("index.js");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Cannot_find_name_0.code,
description: `Add import from "./a"`,
applyChanges: false,
newFileContent:
`import { x } from "./a";
x`
});
// If the module target is es2015+ but the file already uses `require`
// (and not `import`), use `require`.
goTo.position(0);
edit.insertLine("const fs = require('fs');\n");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Cannot_find_name_0.code,
description: `Add import from "./a"`,
applyChanges: false,
newFileContent:
`const fs = require('fs');
const { x } = require('./a');
x`
});
| {
"end_byte": 872,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_require_importVsRequire_moduleTarget.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarClassStaticBlock.ts_0_805 | /// <reference path="fourslash.ts" />
////class C {
//// static {
//// let x;
//// }
////}
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "C",
kind: "class",
childItems: [
{
"text": "x",
"kind": "let"
}
]
}
]
});
verify.navigationBar([
{
text: "<global>",
kind: "script",
childItems: [
{
text: "C",
kind: "class"
}
]
},
{
text: "C",
kind: "class",
childItems: [
{
"text": "x",
"kind": "let"
}
],
indent: 1
}
]);
| {
"end_byte": 805,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarClassStaticBlock.ts"
} |
TypeScript/tests/cases/fourslash/renameJsDocImportTag.ts_0_293 | /// <reference path='fourslash.ts' />
// @allowJS: true
// @checkJs: true
// @Filename: /b.ts
////export interface A { }
// @Filename: /a.js
/////**
//// * @import { A } from "./b";
//// */
////
/////**
//// * @param { [|A/**/|] } a
//// */
////function f(a) {}
verify.baselineRename("");
| {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsDocImportTag.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace10.ts_0_423 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////** [|@import { join } from "path"|] */
goTo.selectRange(test.ranges()[0]);
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent: `/** @import * as path from "path" */`,
});
| {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToNamespace10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties_all.ts_0_1905 | /// <reference path='fourslash.ts' />
////interface I1 {
//// a: number;
//// b: string;
//// c: 1;
//// d: "d";
//// e: "e1" | "e2";
//// f(x: number, y: number): void;
//// g: (x: number, y: number) => void;
////}
////interface I2 {
//// a: unknown;
//// b: any;
////}
////const a: I1 = {};
////const b: I2 = {};
////class C {
//// public c: I1 = {};
////}
////function fn1(foo: I2 = {}) {}
////function fn2(a: I1) {}
////fn2({});
verify.codeFixAll({
fixId: "fixMissingProperties",
fixAllDescription: ts.Diagnostics.Add_all_missing_properties.message,
newFileContent:
`interface I1 {
a: number;
b: string;
c: 1;
d: "d";
e: "e1" | "e2";
f(x: number, y: number): void;
g: (x: number, y: number) => void;
}
interface I2 {
a: unknown;
b: any;
}
const a: I1 = {
a: 0,
b: "",
c: 1,
d: "d",
e: "e1",
f: function(x: number, y: number): void {
throw new Error("Function not implemented.");
},
g: function(x: number, y: number): void {
throw new Error("Function not implemented.");
}
};
const b: I2 = {
a: undefined,
b: undefined
};
class C {
public c: I1 = {
a: 0,
b: "",
c: 1,
d: "d",
e: "e1",
f: function(x: number, y: number): void {
throw new Error("Function not implemented.");
},
g: function(x: number, y: number): void {
throw new Error("Function not implemented.");
}
};
}
function fn1(foo: I2 = {
a: undefined,
b: undefined
}) {}
function fn2(a: I1) {}
fn2({
a: 0,
b: "",
c: 1,
d: "d",
e: "e1",
f: function(x: number, y: number): void {
throw new Error("Function not implemented.");
},
g: function(x: number, y: number): void {
throw new Error("Function not implemented.");
}
});`
});
| {
"end_byte": 1905,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties_all.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics4.ts_0_139 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////public class C { }
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics4.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_templateStrings2.ts_0_92 | /// <reference path="fourslash.ts" />
////`a ${b} /**/c`
verify.baselineSmartSelection();
| {
"end_byte": 92,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_templateStrings2.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationModuleEmpty.ts_0_194 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_moduleEmpty.baseline
// @Filename: bpSpan_moduleEmpty.ts
////module Bar {
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 194,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationModuleEmpty.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_windowsPathsProjectRelative.ts_0_2379 | /// <reference path="fourslash.ts" />
// @Filename: c:/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "paths": {
//// "~/noIndex/*": ["./src/noIndex/*"],
//// "~/withIndex": ["./src/withIndex/index.ts"]
//// }
//// }
//// }
// @Filename: c:/project/package.json
//// {}
// @Filename: c:/project/src/noIndex/a.ts
//// export const myFunctionA = () => {};
// @Filename: c:/project/src/withIndex/b.ts
//// export const myFunctionB = () => {};
// @Filename: c:/project/src/withIndex/index.ts
//// export * from './b';
// @Filename: c:/project/src/reproduction/1.ts
//// myFunction/**/
goTo.marker("");
verify.completions({
includes: [
{
name: "myFunctionA",
source: "~/noIndex/a",
sourceDisplay: "~/noIndex/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
{
name: "myFunctionB",
source: "~/withIndex",
sourceDisplay: "~/withIndex",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
importModuleSpecifierPreference: "non-relative"
},
});
verify.completions({
includes: [
{
name: "myFunctionA",
source: "../noIndex/a",
sourceDisplay: "../noIndex/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
{
name: "myFunctionB",
source: "../withIndex",
sourceDisplay: "../withIndex",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
importModuleSpecifierPreference: "relative"
},
});
verify.completions({
includes: [
{
name: "myFunctionA",
source: "../noIndex/a",
sourceDisplay: "../noIndex/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
{
name: "myFunctionB",
source: "../withIndex",
sourceDisplay: "../withIndex",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
importModuleSpecifierPreference: "project-relative"
},
}); | {
"end_byte": 2379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_windowsPathsProjectRelative.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsDocComment2.ts_0_742 | /// <reference path="fourslash.ts"/>
//// /** @param foo { function(x): string } */
//// var v;
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/** "),
c.punctuation("@"),
c.docCommentTagName("param"),
c.comment(" "),
c.parameterName("foo"),
c.comment(" "),
c.punctuation("{"),
c.keyword("function"),
c.punctuation("("),
c.identifier("x"),
c.punctuation(")"),
c.punctuation(":"),
c.keyword("string"),
c.punctuation("}"),
c.comment(" */"),
c.keyword("var"),
c.identifier("v"),
c.punctuation(";"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "v"),
);
| {
"end_byte": 742,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsDocComment2.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_comment2.ts_0_103 | /// <reference path="fourslash.ts" />
////const a = 1; //a b/**/c d
verify.baselineSmartSelection();
| {
"end_byte": 103,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_comment2.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts_0_604 | /// <reference path='fourslash.ts'/>
// Should handle calls made on super
//// interface Foo {
//// hello (): void;
//// }
////
//// class SubBar extends Bar {
//// hello() {}
//// }
////
//// class Bar extends SuperBar {
//// hello() {}
////
//// whatever() {
//// super.he/*function_call*/llo();
//// super["hel/*element_access*/lo"]();
//// }
//// }
////
//// class SuperBar extends MegaBar {
//// [|hello|]() {}
//// }
////
//// class MegaBar implements Foo {
//// hello() {}
//// }
verify.baselineGoToImplementation("function_call", "element_access");
| {
"end_byte": 604,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember12.ts_0_429 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////type T1 = {};
////type T2 = {};
////export { type T1 };
// @filename: /b.ts
////import { T2 } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "T2", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`type T1 = {};
type T2 = {};
export { type T1, type T2 };`,
}
});
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember12.ts"
} |
TypeScript/tests/cases/fourslash/renameExportSpecifier.ts_0_271 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
////const name = {};
////export { name as name/**/ };
// @Filename: b.ts
////import { name } from './a';
////const x = name.toString();
verify.baselineRename("", { providePrefixAndSuffixTextForRename: false });
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameExportSpecifier.ts"
} |
TypeScript/tests/cases/fourslash/completionsJSDocNoCrash1.ts_0_850 | /// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: index.js
//// /**
//// * @example
//// <file name="glyphicons.css">
//// @import url(//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css);
//// </file>
//// <example module="ngAnimate" deps="angular-animate.js" animations="true">
//// <file name="animations.css">
//// .animate-show.ng-hide-add.ng-hide-add-active,
//// .animate-show.ng-hide-remove.ng-hide-remove-active {
//// transition:all linear 0./**/5s;
//// }
//// </file>
//// </example>
//// */
//// var ngShowDirective = ['$animate', function($animate) {}];
verify.completions({
marker: "",
includes: ["url"],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true
}
});
| {
"end_byte": 850,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocNoCrash1.ts"
} |
TypeScript/tests/cases/fourslash/completionsUniqueSymbol2.ts_0_567 | /// <reference path="fourslash.ts" />
////const a = {
//// KEY_1: 'key_1',
//// KEY_2: 'key_2',
//// KEY_3: 'key_3',
////} as const;
////
////const b = {
//// KEY_1: 'key_1',
//// KEY_2: 'key_2',
//// KEY_3: 'key_3',
////} as const;
////
////interface I {
//// [b.KEY_1]: string,
//// [a.KEY_2]: string,
//// [a.KEY_3]: string
////}
////
////const foo: I = {
//// key_1: 'value_1',
//// key_2: 'value_2',
//// key_3: 'value_3',
////}
////
////foo./**/
verify.baselineCompletions({
includeCompletionsWithInsertText: true,
});
| {
"end_byte": 567,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsUniqueSymbol2.ts"
} |
TypeScript/tests/cases/fourslash/renameImportOfReExport2.ts_0_852 | /// <reference path='fourslash.ts' />
////declare module "a" {
//// [|export class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|]
////}
////declare module "b" {
//// [|export { [|{| "contextRangeIndex": 2 |}C|] as /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}D|] } from "a";|]
////}
////declare module "c" {
//// [|import { /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}D|] } from "b";|]
//// export function f(c: [|D|]): void;
////}
verify.noErrors();
const ranges = test.rangesByText();
const cRanges = ranges.get("C");
const dRanges = ranges.get("D");
const [d0, d1, d2] = dRanges;
verify.baselineFindAllReferences('1', '2', '3');
verify.baselineRename(cRanges);
verify.baselineRename(d0);
verify.baselineRename([d1, d2]); | {
"end_byte": 852,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportOfReExport2.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_require.ts_0_756 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.js
////import * as s from "something";
////fo/*b*/
verify.completions({
marker: "b",
includes: {
name: "foo",
source: "/a",
sourceDisplay: "./a",
text: "const foo: 0",
kind: "const",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("b", {
name: "foo",
source: "/a",
description: `Add import from "./a"`,
newFileContent:
`import * as s from "something";
import { foo } from "./a";
fo`,
});
| {
"end_byte": 756,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_require.ts"
} |
TypeScript/tests/cases/fourslash/javascriptModulesTypeImportAsValue.ts_0_299 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: types.js
//// /**
//// * @typedef {Object} Pet
//// * @prop {string} name
//// */
//// module.exports = { a: 1 };
// @Filename: app.js
//// import { /**/ } from "./types"
verify.completions({ marker: "", excludes: "Pet" });
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModulesTypeImportAsValue.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts_0_569 | /// <reference path='fourslash.ts' />
////function [|/*functionOverload1*/functionOverload|](value: number);
////function /*functionOverload2*/functionOverload(value: string);
////function /*functionOverloadDefinition*/functionOverload() {}
////
////[|/*functionOverloadReference1*/functionOverload|](123);
////[|/*functionOverloadReference2*/functionOverload|]("123");
////[|/*brokenOverload*/functionOverload|]({});
verify.baselineGoToDefinition(
"functionOverloadReference1",
"functionOverloadReference2",
"brokenOverload",
"functionOverload1",
);
| {
"end_byte": 569,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport12.ts_0_258 | /// <reference path="fourslash.ts" />
//// import [|{}|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([`{ f1 }`]);
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport12.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixInferEndingPreference_classic.ts_0_325 | /// <reference path="fourslash.ts" />
// @module: esnext
// @checkJs: true
// @allowJs: true
// @noEmit: true
// @Filename: /a.js
//// export const a = 0;
// @Filename: /b.js
//// export const b = 0;
// @Filename: /c.js
//// import { a } from "./a.js";
////
//// b/**/;
verify.importFixModuleSpecifiers("", ["./b.js"]);
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixInferEndingPreference_classic.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts_0_393 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /x/y.ts
////foo;
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": ".",
//// "paths": {
//// "@root/*": ["*"],
//// }
//// }
////}
goTo.file("/x/y.ts");
verify.importFixAtPosition([
`import { foo } from "@root/a";
foo;`,
]);
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_require_namedAndDefault.ts_0_482 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: blah.ts
////export default class Blah {}
////export const Named1 = 0;
////export const Named2 = 1;
// @Filename: index.js
////Named1 + Named2;
////new Blah;
goTo.file("index.js");
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`const { default: Blah, Named1, Named2 } = require("./blah");
Named1 + Named2;
new Blah;`
});
| {
"end_byte": 482,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_require_namedAndDefault.ts"
} |
TypeScript/tests/cases/fourslash/codeFixEnableJsxFlag_blankCompilerOptionsJsConfig.ts_0_428 | /// <reference path='fourslash.ts' />
// @Filename: /dir/a.tsx
////export const Component = () => <></>
// @Filename: /dir/jsconfig.json
////{
//// "compilerOptions": {
//// }
////}
goTo.file("/dir/a.tsx");
verify.codeFix({
description: "Enable the '--jsx' flag in your configuration file",
newFileContent: {
"/dir/jsconfig.json":
`{
"compilerOptions": {
"jsx": "react"
}
}`,
},
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixEnableJsxFlag_blankCompilerOptionsJsConfig.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles.ts_0_457 | /// <reference path='fourslash.ts' />
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file0.ts
////declare function fn(x: string, y: number);
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file1.ts
////declare function fn(x: string);
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file2.ts
////fn(/*1*/
verify.signatureHelp({ marker: "1", overloadsCount: 2 });
| {
"end_byte": 457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageInaccessibleTypes.ts_0_385 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f1(a) { a; }
////function h1() {
//// class C { p: number };
//// f1({ ofTypeC: new C() });
////}
////
////function f2(a) { a; }
////function h2() {
//// interface I { a: number }
//// var i: I = {a : 1};
//// f2(i);
//// f2(2);
//// f2(false);
////}
////
verify.not.codeFixAvailable();
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageInaccessibleTypes.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_overloads.ts_0_365 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
////function foo(): number;
////function foo(x: number, y: number): number;
////function foo(x?: number, y?: number): number {
//// return 1234;
////}
////
////export {}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'foo'",
newFileContent:
`
export {}`,
});
| {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_overloads.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType8.ts_0_1565 | /// <reference path="fourslash.ts" />
//// import { type A, type a, b, B } from "foo";
//// console.log(a, b, A, B);
verify.organizeImports(
`import { type A, type a, b, B } from "foo";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" }
);
edit.replaceLine(0, 'import { type A, type a, b, B } from "foo1";');
verify.organizeImports(
`import { type A, type a, b, B } from "foo1";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "first" }
);
edit.replaceLine(0, 'import { type A, type a, b, B } from "foo2";');
verify.organizeImports(
`import { b, B, type A, type a } from "foo2";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "last" }
);
edit.replaceLine(0, 'import { type A, type a, b, B } from "foo3";');
verify.organizeImports(
`import { type A, type a, b, B } from "foo3";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto" }
);
edit.replaceLine(0, 'import { type A, type a, b, B } from "foo4";');
verify.organizeImports(
`import { type A, type a, b, B } from "foo4";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true }
);
edit.replaceLine(0, 'import { type A, type a, b, B } from "foo5";');
verify.organizeImports(
`import { type A, B, type a, b } from "foo5";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false }
); | {
"end_byte": 1565,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType8.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixConvertTypeOnly1.ts_0_265 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
//// export class A {}
//// export class B {}
// @Filename: /b.ts
//// import type { A } from './a';
//// new B
goTo.file('/b.ts');
verify.importFixAtPosition([`import { B, type A } from './a';
new B`]);
| {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixConvertTypeOnly1.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxAttribute2.ts_0_588 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// <a href=/*a*/"string"/*b*/></a>;
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`function Foo() {
const /*RENAME*/newLocal = "string";
return (
<div>
<a href={newLocal}></a>;
</div>
);
}`
});
| {
"end_byte": 588,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxAttribute2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePrefixExpr.ts_0_388 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/4/*y*/2 - 6 * 4 + 23 / 12 +" years old"
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 foo = \`\${42 - 6 * 4 + 23 / 12} years old\``,
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePrefixExpr.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingExpr.ts_0_419 | /// <reference path='fourslash.ts' />
//// const foo = /* C0 */ /*x*/"/*y*/foo" /* C1 */ + " is" /* C2 */ + 42/* C3 */
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 foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42 /* C3 */}`",
});
| {
"end_byte": 419,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingExpr.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameterNarrowed.ts_0_488 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function existing<T>(value: T) {
//// if (typeof value === "number") {
//// added/*1*/(value);
//// }
////}
goTo.marker("1");
verify.codeFix({
description: "Add missing function declaration 'added'",
index: 0,
newFileContent: `function existing<T>(value: T) {
if (typeof value === "number") {
added(value);
}
}
function added<T>(value: T) {
throw new Error("Function not implemented.");
}
`,
});
| {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameterNarrowed.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration29.ts_0_522 | /// <reference path='fourslash.ts' />
// @filename: /a.ts
////export namespace A {
//// export function test() {}
////};
// @filename: /b.ts
////import { A } from "./a";
////
////A.fn();
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "fn"],
index: 0,
newFileContent: {
"/a.ts":
`export namespace A {
export function test() {}
export function fn() {
throw new Error("Function not implemented.");
}
};`,
}
});
| {
"end_byte": 522,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration29.ts"
} |
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations5.ts_0_224 | /// <reference path='fourslash.ts'/>
////interface /*1*/Foo { }
////module /*2*/Foo { export interface Bar { } }
////function /*3*/Foo() { }
////
////export = /*4*/Foo;
verify.baselineFindAllReferences('1', '2', '3', '4')
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations5.ts"
} |
TypeScript/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts_0_1048 | /// <reference path='fourslash.ts'/>
////function f() {
//// namespace n {
//// interface I {
//// x: number
//// }
//// /*1*/
//// }
//// /*2*/
////}
/////*3*/
////function f2() {
//// namespace n2 {
//// class I2 {
//// x: number
//// }
//// /*11*/
//// }
//// /*22*/
////}
/////*33*/
verify.completions(
{ marker: ["1", "2", "3"], includes: { name: "f", text: "function f(): void" }, excludes: ["n", "I"] },
{
marker: "11",
includes: [
{ name: "f2", text: "function f2(): void" },
{ name: "n2", text: "namespace n2" },
{ name: "I2", text: "class I2" },
],
},
{
marker: "22",
includes: [
{ name: "f2", text: "function f2(): void" },
{ name: "n2", text: "namespace n2" },
],
excludes: "I2",
},
{
marker: "33",
includes: { name: "f2", text: "function f2(): void" },
excludes: ["n2", "I2"],
},
);
| {
"end_byte": 1048,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixJsEnding.ts_0_476 | /// <reference path="fourslash.ts"/>
// @module: commonjs
// @Filename: /node_modules/lit/package.json
//// { "name": "lit", "version": "1.0.0" }
// @Filename: /node_modules/lit/index.d.ts
//// import "./decorators";
// @Filename: /node_modules/lit/decorators.d.ts
//// export declare function customElement(name: string): any;
// @Filename: /a.ts
//// customElement/**/
verify.importFixModuleSpecifiers("", ["lit/decorators.js"], { importModuleSpecifierEnding: "js" })
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixJsEnding.ts"
} |
TypeScript/tests/cases/fourslash/genericCombinators3.ts_0_784 | /// <reference path='fourslash.ts'/>
////interface Collection<T, U> {
////}
////
////interface Combinators {
//// map<T, U, V>(c: Collection<T,U>, f: (x: T, y: U) => V): Collection<T, V>;
//// map<T, U>(c: Collection<T,U>, f: (x: T, y: U) => any): Collection<any, any>;
////}
////
////var c2: Collection<number, string>;
////
////var _: Combinators;
////
////var /*9*/r1a = _.ma/*1c*/p(c2, (/*1a*/x,/*1b*/y) => { return x + "" }); // check quick info of map here
verify.quickInfos({
"1a": "(parameter) x: number",
"1b": "(parameter) y: string",
"1c": "(method) Combinators.map<number, string, string>(c: Collection<number, string>, f: (x: number, y: string) => string): Collection<number, string> (+1 overload)",
9: "var r1a: Collection<number, string>"
});
| {
"end_byte": 784,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCombinators3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedLabel_noSuggestionIfDisabled.ts_0_131 | /// <reference path='fourslash.ts' />
// @allowUnusedLabels: true
////foo: while (true) {}
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 131,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedLabel_noSuggestionIfDisabled.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember5.ts_0_393 | /// <reference path='fourslash.ts' />
// @checkJs: true
// @allowJs: true
// @Filename: a.js
////class C {
//// static method() {
//// ()=>{ this.foo === 10 };
//// }
////}
verify.codeFix({
description: "Initialize static property 'foo'",
index: 0,
newFileContent: `class C {
static method() {
()=>{ this.foo === 10 };
}
}
C.foo = undefined;
`
});
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember5.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_dollar.ts_0_309 | /// <reference path="fourslash.ts" />
// @module: esnext
// @moduleResolution: bundler
// @Filename: /node_modules/qwik/index.d.ts
//// export declare const $: any;
// @Filename: /index.ts
//// import {} from "qwik";
//// $/**/
goTo.marker("");
verify.importFixAtPosition([`import { $ } from "qwik";
$`]); | {
"end_byte": 309,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_dollar.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction2.ts_0_370 | /// <reference path="fourslash.ts" />
//// function createProps<T>(t: T) {
//// const getProps = function() {}
//// const createVariants = function() {}
////
//// getProps.createVariants = createVariants;
//// return getProps;
//// }
////
//// createProps({})./**/createVariants();
verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
| {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForImportCall.ts_0_537 | /// <reference path="fourslash.ts" />
// @Filename: /app.ts
//// export function he/**/llo() {};
// @Filename: /re-export.ts
//// export const services = { app: setup(() => import('./app')) }
//// function setup<T>(importee: () => Promise<T>): T { return {} as any }
// @Filename: /indirect-use.ts
//// import("./re-export").then(mod => mod.services.app.hello());
// @Filename: /direct-use.ts
//// async function main() {
//// const mod = await import("./app")
//// mod.hello();
//// }
verify.baselineFindAllReferences("");
| {
"end_byte": 537,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForImportCall.ts"
} |
TypeScript/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts_0_386 | /// <reference path="fourslash.ts" />
// @Filename: file.jsx
//// `
//// // /*0*/
//// /* /*1*/ */
//// /**
//// * /*2*/
//// */
//// foo()
//// // /*3*/
//// /* /*4*/ */
//// /**
//// * /*5*/
//// */
//// `
//// `
//// // /*6*/
//// /* /*7*/ */
//// /**
//// * /*8*/
//// */
for (let i = 0; i < 9; ++i) {
goTo.marker(i.toString());
verify.not.isInCommentAtPosition();
} | {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isInMultiLineCommentInTemplateLiteral.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts_0_327 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////namespace greeter {
//// type hw = "Hello" |"world";
//// export type nw = "No" | "Way";
////}
verify.codeFix({
description: "Remove unused declaration for: 'hw'",
newFileContent: `namespace greeter {
export type nw = "No" | "Way";
}`,
});
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts"
} |
TypeScript/tests/cases/fourslash/outlineSpansTrailingBlockCommentsAfterStatements.ts_0_163 | /// <reference path="fourslash.ts"/>
// #22732
////console.log(0);
////[|/*
///// * Some text
//// */|]
verify.outliningHintSpansInCurrentFile(test.ranges());
| {
"end_byte": 163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/outlineSpansTrailingBlockCommentsAfterStatements.ts"
} |
TypeScript/tests/cases/fourslash/unusedClassInNamespace3.ts_0_367 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// class c1 {
////
//// }
////
//// export class c2 {
////
//// }
////
//// class c3 extends c1 {
////
//// }
////} |]
verify.rangeAfterCodeFix(`namespace Validation {
class c1 {
}
export class c2 {
}
}`);
| {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedClassInNamespace3.ts"
} |
TypeScript/tests/cases/fourslash/completionsForLatterTypeParametersInConstraints1.ts_0_381 | /// <reference path='fourslash.ts' />
//// // https://github.com/microsoft/TypeScript/issues/56474
//// function test<First extends S/*1*/, Second>(a: First, b: Second) {}
//// type A1<K extends /*2*/, L> = K
verify.completions({
marker: ["1"],
includes: ["Second"],
excludes: ["First"],
});
verify.completions({
marker: ["2"],
includes: ["L"],
excludes: ["K"],
});
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsForLatterTypeParametersInConstraints1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport9.ts_0_535 | /// <reference path="fourslash.ts" />
// @verbatimModuleSyntax: true
// @module: esnext
// @moduleResolution: bundler
// @target: esnext
// @filename: /a.ts
////export function f() {}
////export interface I {}
// @Filename: /b.ts
////[|import { I, f } from "./a";|]
////export { type I, f };
goTo.file("/b.ts");
verify.codeFixAvailable([
{ description: "Use 'type I'" }
]);
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Use_type_0.message, "I"],
newRangeContent: `import { type I, f } from "./a";`,
});
| {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport9.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameters.ts_0_605 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function existing<T1, T, T2>(t1: T1, t: T, t2a: T2, t2b: T2, t2c: T2) {
//// added/*1*/(t2a, t2b, t2c, t1, t, t2a, t2c, t2b);
////}
goTo.marker("1");
verify.codeFix({
description: "Add missing function declaration 'added'",
index: 0,
newFileContent: `function existing<T1, T, T2>(t1: T1, t: T, t2a: T2, t2b: T2, t2c: T2) {
added(t2a, t2b, t2c, t1, t, t2a, t2c, t2b);
}
function added<T2, T1, T>(t2a: T2, t2b: T2, t2c: T2, t1: T1, t: T, t2a1: T2, t2c1: T2, t2b1: T2) {
throw new Error("Function not implemented.");
}
`,
});
| {
"end_byte": 605,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameters.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts_0_1072 | /// <reference path='fourslash.ts' />
// Should handle nested files in folders discovered via the baseUrl compiler option
// @baseUrl: tests/cases/fourslash/modules
// @Filename: tests/test0.ts
//// import * as foo1 from "subfolder//*import_as0*/
//// import foo2 = require("subfolder//*import_equals0*/
//// var foo3 = require("subfolder//*require0*/
//// import * as foo1 from "module-from-node//*import_as1*/
//// import foo2 = require("module-from-node//*import_equals1*/
//// var foo3 = require("module-from-node//*require1*/
// @Filename: modules/subfolder/module.ts
//// export var x = 5;
// @Filename: package.json
//// { "dependencies": { "module-from-node": "latest" } }
// @Filename: node_modules/module-from-node/index.ts
//// /*module1*/
const kinds = ["import_as", "import_equals", "require"];
verify.completions(
{
marker: kinds.map(k => `${k}0`),
exact: "module",
isNewIdentifierLocation: true,
},
{
marker: kinds.map(k => `${k}1`),
exact: "index",
isNewIdentifierLocation: true,
},
)
| {
"end_byte": 1072,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization15.ts_0_413 | /// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: a.js
////class Foo {
//// /**
//// * comment
//// * @type {string}
//// */
//// a;
////}
verify.codeFix({
description: `Add 'undefined' type to property 'a'`,
newFileContent:
`class Foo {
/**
* comment
* @type {string | undefined}
*/
a;
}`,
index: 2
})
| {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization15.ts"
} |
TypeScript/tests/cases/fourslash/completionListModuleMembers.ts_0_1078 | /// <reference path="fourslash.ts" />
//// module Module {
//// var innerVariable = 1;
//// function innerFunction() { }
//// class innerClass { }
//// module innerModule { }
//// interface innerInterface {}
//// export var exportedVariable = 1;
//// export function exportedFunction() { }
//// export class exportedClass { }
//// export module exportedModule { export var exportedInnerModuleVariable = 1; }
//// export interface exportedInterface {}
//// }
////
////Module./*ValueReference*/;
////
////var x : Module./*TypeReference*/
////
////class TestClass extends Module./*TypeReferenceInExtendsList*/ { }
////
////interface TestInterface implements Module./*TypeReferenceInImplementsList*/ { }
verify.completions(
{
marker: ["ValueReference", "TypeReferenceInExtendsList"],
unsorted: ["exportedFunction", "exportedVariable", "exportedClass", "exportedModule"],
},
{
marker: ["TypeReference", "TypeReferenceInImplementsList"],
unsorted: ["exportedClass", "exportedInterface"],
},
);
| {
"end_byte": 1078,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListModuleMembers.ts"
} |
TypeScript/tests/cases/fourslash/removeInterfaceExtendsClause.ts_0_176 | /// <reference path="fourslash.ts" />
//// interface IFoo<T> { }
//// interface Array<T> /**/extends IFoo<T> { }
goTo.marker();
edit.deleteAtCaret('extends IFoo<T>'.length);
| {
"end_byte": 176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeInterfaceExtendsClause.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionAwait3.ts_0_305 | /// <reference path="fourslash.ts" />
//// class C {
//// notAsync() {
//// [|/*start1*/await|] Promise.resolve(0);
//// }
////
//// async /*end2*/foo() {
//// [|/*start2*/await|] Promise.resolve(0);
//// }
//// }
verify.baselineGoToDefinition(
"start1",
"start2"
);
| {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionAwait3.ts"
} |
TypeScript/tests/cases/fourslash/extract-method-in-anonymous-function-declaration.ts_0_428 | /// <reference path='fourslash.ts' />
////export default function() {
//// /*start*/0/*end*/;
////}
goTo.select('start', 'end')
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in anonymous function",
newContent:
`export default function() {
/*RENAME*/newFunction();
function newFunction() {
0;
}
}`
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-in-anonymous-function-declaration.ts"
} |
TypeScript/tests/cases/fourslash/completionNoParentLocation.ts_0_129 | /// <reference path="fourslash.ts" />
//// /**/
//// type foo = any;
//// declare const foo: any;
verify.baselineCompletions(); | {
"end_byte": 129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionNoParentLocation.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptPrototype4.ts_0_551 | ///<reference path="fourslash.ts" />
// Check for any odd symbol leakage
// @allowNonTsExtensions: true
// @Filename: myMod.js
//// function myCtor(x) {
//// this.qua = 10;
//// }
//// myCtor.prototype.foo = function() { return 32 };
//// myCtor.prototype.bar = function() { return '' };
////
//// myCtor/*1*/
goTo.marker('1');
edit.insert('.');
// Check members of the function
verify.completions({
includes: ["foo", "bar", "qua"].map(
name => ({ name, kind: "warning", sortText: completion.SortText.JavascriptIdentifiers }))
});
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptPrototype4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingVsImport.ts_0_331 | /// <reference path='fourslash.ts' />
// Tests that the import fix is returned first.
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////const foof = 0;
////foo;
goTo.file("/b.ts");
verify.codeFixAvailable([
{ description: `Add import from "./a"` },
{ description: "Change spelling to 'foof'" },
]);
| {
"end_byte": 331,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingVsImport.ts"
} |
TypeScript/tests/cases/fourslash/unusedAmbient2.ts_0_1056 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
// @Filename: /a.ts
////export {};
////declare var [|a|]: string;
// @Filename: /b.d.ts
////declare module 'b' {
//// var [|b|]: string;
//// function [|f|]([|p|]: string): any;
//// export {};
////}
goTo.file("/a.ts");
verify.getSuggestionDiagnostics([{
code: ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code,
message: "'a' is declared but its value is never read.",
reportsUnnecessary: true
}]);
verify.getSemanticDiagnostics([]);
goTo.file("/b.d.ts");
verify.getSuggestionDiagnostics([{
range: test.rangesByText().get("b")[0],
code: ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code,
message: "'b' is declared but its value is never read.",
reportsUnnecessary: true
}, {
range: test.rangesByText().get("f")[0],
code: ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code,
message: "'f' is declared but its value is never read.",
reportsUnnecessary: true
}]);
verify.getSemanticDiagnostics([]);
| {
"end_byte": 1056,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedAmbient2.ts"
} |
TypeScript/tests/cases/fourslash/toggleMultilineComment7.ts_0_980 | // Cases where the cursor is inside JSX like sintax but it's actually js.
//@Filename: file.tsx
//// const a = (
//// [|<div>
//// some text|]
//// </div>
//// );
//// const b = <MyComponent foo={1 [|+ 2 + 3 + 4|]} />;
//// const c = <MyComponent message={[|'hello world'|]} />;
//// const d = <MyTextBox autocomplete={tr[|ue|]} />;
//// const e = <MyCo[|mponent message={'hello world'} />;|]
//// const f = [
//// [|<li key="A">First item</li>,
//// <li key="B">Second item</li>,|]
//// <li key="C">Third item</li>,
//// ];
verify.toggleMultilineComment(
`const a = (
/*<div>
some text*/
</div>
);
const b = <MyComponent foo={1 /*+ 2 + 3 + 4*/} />;
const c = <MyComponent message={/*'hello world'*/} />;
const d = <MyTextBox autocomplete={tr/*ue*/} />;
const e = <MyCo/*mponent message={'hello world'} />;*/
const f = [
/*<li key="A">First item</li>,
<li key="B">Second item</li>,*/
<li key="C">Third item</li>,
];`); | {
"end_byte": 980,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment7.ts"
} |
TypeScript/tests/cases/fourslash/completionListStaticProtectedMembers.ts_0_2424 | /// <reference path='fourslash.ts'/>
////class Base {
//// private static privateMethod() { }
//// private static privateProperty;
////
//// protected static protectedMethod() { }
//// protected static protectedProperty;
////
//// public static publicMethod() { }
//// public static publicProperty;
////
//// protected static protectedOverriddenMethod() { }
//// protected static protectedOverriddenProperty;
////
//// static test() {
//// Base./*1*/;
//// this./*2*/;
//// C1./*3*/;
//// }
////}
////
////class C1 extends Base {
//// protected static protectedOverriddenMethod() { }
//// protected static protectedOverriddenProperty;
////}
verify.completions(
{
marker: ["1", "2"],
// Same class, everything is visible
includes: [
{ name: "privateMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "privateProperty", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "protectedProperty", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "publicProperty", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority},
{ name: "protectedOverriddenProperty", sortText: completion.SortText.LocalDeclarationPriority }
],
},
{
marker: "3",
includes: [
{ name: "privateMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "privateProperty", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "protectedProperty", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "publicProperty", sortText: completion.SortText.LocalDeclarationPriority }
],
// Can not access protected properties overridden in subclass
excludes: ["protectedOverriddenMethod", "protectedOverriddenProperty"],
},
);
| {
"end_byte": 2424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListStaticProtectedMembers.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyConstNamedFunctionExpression.ts_0_229 | /// <reference path="fourslash.ts" />
//// function foo() {
//// bar();
//// }
////
//// const /**/bar = function () {
//// baz();
//// }
////
//// function baz() {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyConstNamedFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/completionListInClosedFunction04.ts_3_342 | / <reference path="fourslash.ts" />
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello") {
////
//// }
////}
verify.completions({
marker: "1",
// Note: `b = b` or `b = c` would be a compile error
includes: ["foo", "x", "y", "z", "bar", "a"],
});
| {
"end_byte": 342,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedFunction04.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationWith.ts_0_216 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_with.baseline
// @Filename: bpSpan_with.ts
////var obj: string;
////with (obj) {
//// x = 10;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationWith.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionObjectSpread.ts_0_233 | /// <reference path='fourslash.ts'/>
////interface A1 { /*1*/a: number };
////interface A2 { /*2*/a?: number };
////let a1: A1;
////let a2: A2;
////let a12 = { ...a1, ...a2 };
////a12.[|a/*3*/|];
verify.baselineGoToDefinition('3');
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionObjectSpread.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts_0_785 | /// <reference path='fourslash.ts' />
// Should give completions for typings discovered via the typeRoots compiler option
// @typeRoots: my_typings,my_other_typings
// @Filename: tests/test0.ts
//// /// <reference types="m/*types_ref0*/" />
//// import * as foo1 from "m/*import_as0*/
//// import foo2 = require("m/*import_equals0*/
//// var foo3 = require("m/*require0*/
// @Filename: my_typings/module-x/index.d.ts
//// export var x = 9;
// @Filename: my_typings/module-x/whatever.d.ts
//// export var w = 9;
// @Filename: my_typings/module-y/index.d.ts
//// export var y = 9;
// @Filename: my_other_typings/module-z/index.d.ts
//// export var z = 9;
verify.completions({ marker: test.markers(), exact: ["module-x", "module-y", "module-z"], isNewIdentifierLocation: true })
| {
"end_byte": 785,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts"
} |
TypeScript/tests/cases/fourslash/gotoDefinitionLinkTag2.ts_0_156 | /// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /*1*/[|A|]} */
//// [|/*2*/A|]
////}
verify.baselineGetDefinitionAtPosition("1"); | {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionLinkTag2.ts"
} |
TypeScript/tests/cases/fourslash/extract-method_jsxElement2.ts_0_610 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<span></span>/*b*/
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in function 'Foo'",
newContent:
`function Foo() {
return (
<div>
{newFunction()}
</div>
);
function /*RENAME*/newFunction() {
return <span></span>;
}
}`
});
| {
"end_byte": 610,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxElement2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateInvalidLocation.ts_0_2012 | /// <reference path='fourslash.ts' />
//// import * as a from "/*1a*/f/*1b*/oobar";
//// export * as b from "/*2a*/f/*2b*/oobar";
//// import * as c from "foobar" assert { "/*3a*/f/*3b*/oobar": "something" };
//// import * as d from "foobar" assert { "something": "/*4a*/f/*4b*/oobar" };
////
//// let x = {
//// "/*5a*/f/*5b*/oobar": 1234,
//// };
verify.getSyntacticDiagnostics([]);
goTo.select("1a", "1b");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
goTo.select("2a", "2b");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
goTo.select("3a", "3b");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
goTo.select("4a", "4b");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
goTo.select("5a", "5b");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
| {
"end_byte": 2012,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateInvalidLocation.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_directory_noUpdateNodeModulesImport.ts_0_275 | /// <reference path='fourslash.ts' />
// @Filename: /a/b/file1.ts
////import { foo } from "foo";
// @Filename: /a/b/node_modules/foo/index.d.ts
////export const foo = 0;
verify.getEditsForFileRename({
oldPath: "/a/b",
newPath: "/a/d",
newFileContents: {},
});
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_directory_noUpdateNodeModulesImport.ts"
} |
TypeScript/tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts_0_309 | /// <reference path='fourslash.ts'/>
//// class Gre/*1*/eter {
//// someFunction() { th/*2*/is; }
//// }
////
//// type Options = "opt/*3*/ion 1" | "option 2";
//// let myOption: Options = "option 1";
////
//// some/*4*/Label:
//// break someLabel;
verify.baselineFindAllReferences("1", "2", "3", "4"); | {
"end_byte": 309,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion8.ts_0_337 | ///<reference path="fourslash.ts" />
// @Filename: first.ts
//// /** @deprecated */
//// export declare function tap<T>(next: null): void;
//// export declare function tap<T>(next: T): T;
// @Filename: second.ts
//// import { tap } from './first';
//// tap
goTo.file('second.ts')
verify.noErrors()
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion8.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentInterface.ts_0_366 | /// <reference path='fourslash.ts'/>
////interface Foo {
//// {| "indentation" : 4 |}
//// x: number;
//// {| "indentation" : 4 |}
//// foo(): number;
//// {| "indentation" : 4 |}
////}
////{| "indentation" : 0 |}
test.markers().forEach((marker) => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation);
}); | {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentInterface.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace1.ts_0_398 | /// <reference path='fourslash.ts' />
/////*a*/import { a, b, foo } from "./foo";/*b*/
////a;
////b;
////foo;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent:
`import * as foo from "./foo";
foo.a;
foo.b;
foo.foo;`,
});
| {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToNamespace1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts_0_386 | /// <reference path="fourslash.ts" />
//// [|foo/*0*/();|]
// @Filename: folder_b/f2.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": ".",
//// "paths": {
//// "b/*": [ "folder_b/*" ]
//// }
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "b/f2";
foo();`
]);
| {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts"
} |
TypeScript/tests/cases/fourslash/localFunction.ts_0_377 | /// <reference path='fourslash.ts' />
////function /*1*/foo() {
//// function /*2*/bar2() {
//// }
//// var y = function /*3*/bar3() {
//// }
////}
////var x = function /*4*/bar4() {
////}
verify.quickInfos({
1: "function foo(): void",
2: "(local function) bar2(): void",
3: "(local function) bar3(): void",
4: "(local function) bar4(): void"
});
| {
"end_byte": 377,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/localFunction.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesThis6.ts_0_3574 | /// <reference path='fourslash.ts' />
////this/*1*/;
////this;
////
////function f() {
//// this/*2*/;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
////}
////
////module m {
//// var x = th/*6*/is;
//// function f() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}
////
////class A {
//// public b = this.method1;
////
//// public method1() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this/*3*/;
//// })(this);
//// }
//// }
////
//// private method2() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////
//// public static staticB = this.staticMethod1;
////
//// public static staticMethod1() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////
//// private static staticMethod2() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}
////
////var x = {
//// a: /*4*/this,
////
//// f() {
//// this/*5*/;
//// function foo() {
//// this;
//// }
//// const bar = () => {
//// this;
//// }
//// },
////
//// g() {
//// this;
//// },
////
//// get h() {
//// /*7*/this;
//// function foo() {
//// this;
//// }
//// const bar = () => {
//// this;
//// }
//// return;
//// },
////
//// set h(foo: any) {
//// this;
//// },
////
//// l: () => {
//// /*8*/this;
//// function foo() {
//// this;
//// }
//// const bar = () => {
//// this;
//// }
//// },
////};
////
verify.baselineDocumentHighlights(test.markers());
| {
"end_byte": 3574,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThis6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties4.ts_0_304 | /// <reference path='fourslash.ts' />
////interface Foo {
//// a: number;
//// b: string;
////}
////[|const foo: Foo = { a: 10 }|];
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const foo: Foo = {
a: 10,
b: ""
}`
});
| {
"end_byte": 304,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties4.ts"
} |
TypeScript/tests/cases/fourslash/extract-const2.ts_0_392 | /// <reference path='fourslash.ts' />
////function foo(bar: number) {
//// /*a*/bar.toString();/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`function foo(bar: number) {
const /*RENAME*/newLocal = bar.toString();
}`
});
| {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses2.ts_0_550 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////function foo() {
//// function test() { return Math.random() > 0.5; }
//// test/**/ ? console.log('test') : undefined;
////}
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_missing_call_parentheses.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_missing_call_parentheses.message,
index: 0,
newFileContent:
`function foo() {
function test() { return Math.random() > 0.5; }
test() ? console.log('test') : undefined;
}`,
});
| {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForJSDocCodefence.ts_0_302 | /// <reference path='fourslash.ts' />
/////**
//// * @example
//// * ```
//// * 1 + 2
//// * ```
//// */
////function fo/*1*/o() {
//// return '2';
////}
/////**
//// * @example
//// * ``
//// * 1 + 2
//// * `
//// */
////function bo/*2*/o() {
//// return '2';
////}
verify.baselineQuickInfo();
| {
"end_byte": 302,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForJSDocCodefence.ts"
} |
TypeScript/tests/cases/fourslash/linkedEditingJsxTag6.ts_0_1886 | /// <reference path='fourslash.ts' />
// @Filename: /namespace.tsx
////const jsx = (
//// </*start*/someNamespa/*3*/ce./*2*/Thing>
//// <//*end*/someNamespace/*1*/.Thing>
////);
//// const jsx1 = </*4*/foo/*5*/ /*6*/./*7*/ /*8*/ba/*9*/r><//*10*/foo.bar>;
//// const jsx2 = <foo./*11*/bar><//*12*/ /*13*/f/*14*/oo /*15*/./*16*/b/*17*/ar/*18*/>;
//// const jsx3 = </*19*/foo/*20*/ //*21*// /*22*/some comment
//// /*23*/./*24*/bar>
//// </f/*25*/oo.bar>;
//// let jsx4 =
//// </*26*/foo /*27*/ .// hi/*28*/
//// /*29*/bar>
//// <//*30*/foo /*31*/ .// hi/*32*/
//// /*33*/bar>
const wordPattern = "[a-zA-Z0-9:\\-\\._$]*";
const startPos1 = test.markerByName("start").position;
const endPos1 = test.markerByName("end").position;
const linkedCursors1 = {
ranges: [{ start: startPos1, length: 19 }, { start: endPos1, length: 19 }],
wordPattern,
};
const startPos2 = test.markerByName("26").position;
const endPos2 = test.markerByName("30").position;
const linkedCursors2 = {
ranges: [{ start: startPos2, length: 21 }, { start: endPos2, length: 21 }],
wordPattern,
};
verify.linkedEditing( {
"1": linkedCursors1,
"2": linkedCursors1,
"3": linkedCursors1,
"4": undefined,
"5": undefined,
"6": undefined,
"7": undefined,
"8": undefined,
"9": undefined,
"10": undefined,
"11": undefined,
"12": undefined,
"13": undefined,
"14": undefined,
"15": undefined,
"16": undefined,
"17": undefined,
"18": undefined,
"19": undefined,
"20": undefined,
"21": undefined,
"22": undefined,
"23": undefined,
"24": undefined,
"25": undefined,
"26": linkedCursors2,
"27": linkedCursors2,
"28": linkedCursors2,
"29": linkedCursors2,
"30": linkedCursors2,
"31": linkedCursors2,
"32": linkedCursors2,
"33": linkedCursors2,
}); | {
"end_byte": 1886,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag6.ts"
} |
TypeScript/tests/cases/fourslash/indentationInJsx2.ts_0_137 | /// <reference path="fourslash.ts"/>
//@Filename: file.tsx
////<div>/*1*/
goTo.marker("1");
edit.insert("\n");
verify.indentationIs(0);
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInJsx2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts_3_257 | / <reference path='fourslash.ts'/>
//// class Foo {
//// constructor(private /*1*/privateParam: number) {
//// let localPrivate = privateParam;
//// this.privateParam += 10;
//// }
//// }
verify.baselineFindAllReferences('1')
| {
"end_byte": 257,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts"
} |
TypeScript/tests/cases/fourslash/unusedClassInNamespaceWithTrivia1.ts_0_240 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// /* comment1 */
//// class /* comment2 */ class1 {
//// }
//// } |]
verify.rangeAfterCodeFix(`namespace greeter {
/* comment1 */
}`);
| {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedClassInNamespaceWithTrivia1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes10.ts_0_389 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////type A = 'a' | 'b' | 'c' | 'd' | 'e';
////type B = 1 | 2 | 3;
////type C = '@' | '!';
////type D = `${A}${Uppercase<A>}${B}${C}`;
////const A = (props: { [K in D]: K }) =>
//// <div {...props}></div>;
////
////const Bar = () =>
//// [|<A></A>|]
verify.not.codeFixAvailable("fixMissingAttributes");
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes10.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames5.ts_0_360 | /// <reference path='fourslash.ts' />
// @Filename: b.ts
////export {Class as [|/*classAliasDefinition*/ClassAlias|]} from "./a";
// @Filename: a.ts
////export module Module {
////}
////export class /*classDefinition*/Class {
//// private f;
////}
////export interface Interface {
//// x;
////}
verify.baselineGoToDefinition("classAliasDefinition");
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames5.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForObjectBindingElementName06.ts_0_363 | /// <reference path="fourslash.ts" />
////type Foo = {
//// /**
//// * Thing is a bar
//// */
//// isBar: boolean
////
//// /**
//// * Thing is a baz
//// */
//// isBaz: boolean
////}
////
////function f(): Foo {
//// return undefined as any
////}
////
////const { isBaz: isBar } = f();
////isBar/**/;
verify.baselineQuickInfo();
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForObjectBindingElementName06.ts"
} |
TypeScript/tests/cases/fourslash/codeFixIncorrectNamedTupleSyntax1.ts_0_258 | /// <reference path='fourslash.ts' />
////type Tup = [first: string, elem: ...any[]];
verify.codeFix({
description: "Move labeled tuple element modifiers to labels",
index: 0,
newFileContent:
`type Tup = [first: string, ...elem: any[]];`
}); | {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixIncorrectNamedTupleSyntax1.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyClassStaticBlock2.ts_0_428 | /// <reference path="fourslash.ts" />
//// class C {
//// /**/static {
//// function foo() {
//// bar();
//// }
////
//// function bar() {
//// baz();
//// quxx();
//// baz();
//// }
////
//// foo();
//// }
//// }
////
//// function baz() {
//// }
////
//// function quxx() {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyClassStaticBlock2.ts"
} |
TypeScript/tests/cases/fourslash/importJsNodeModule1.ts_0_488 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: node_modules/myMod/index.js
//// module.exports = { n: 3, s: 'foo', b: true };
// @Filename: consumer.js
//// var x = require('myMod');
//// x/**/;
goTo.file('consumer.js');
goTo.marker();
edit.insert('.');
verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) });
edit.insert('n.');
verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importJsNodeModule1.ts"
} |
TypeScript/tests/cases/fourslash/eval.ts_0_251 | /// <reference path="fourslash.ts" />
////class SomeObj {
//// public n = 5;
////
//// public getCallback() {
//// return () => this.n;
//// }
////}
////
////var x = new SomeObj();
////var y = x.getCallback()();
verify.eval('y', 5);
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/eval.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.