_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/formatIfWithEmptyCondition.ts_0_188 | /// <reference path="fourslash.ts"/>
//// if () {
//// }
format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true);
format.document();
verify.currentFileContentIs(
`if ()
{
}`);
| {
"end_byte": 188,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatIfWithEmptyCondition.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression_selfReferencing.ts_0_364 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
////class C {
//// m() {
//// return function g() {
//// this;
//// g();
//// };
//// }
////}
// note that no implicitThis fix is available, only a inferFromUsage one:
verify.codeFixAvailable([{
description: "Infer 'this' type of 'g' from usage",
}]);
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression_selfReferencing.ts"
} |
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns3.ts_0_1300 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /ambient1.d.ts
//// declare module "foo" {
//// export const x = 1;
//// }
// @Filename: /ambient2.d.ts
//// declare module "foo" {
//// export const y = 2;
//// }
// @Filename: /index.ts
//// /**/
verify.completions({
marker: "",
exact: completion.globalsPlus([{
// We don't look at what file each individual export came from; we
// only include or exclude modules wholesale, so excluding part of
// an ambient module or a module augmentation isn't supported.
name: "x",
source: "foo",
sourceDisplay: "foo",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}, {
name: "y",
source: "foo",
sourceDisplay: "foo",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}]),
preferences: {
allowIncompleteCompletions: true,
includeCompletionsForModuleExports: true,
autoImportFileExcludePatterns: ["/**/ambient1.d.ts"],
}
});
// Here, *every* file that declared "foo" is excluded.
verify.completions({
marker: "",
exact: completion.globals,
preferences: {
allowIncompleteCompletions: true,
includeCompletionsForModuleExports: true,
autoImportFileExcludePatterns: ["/**/ambient*"],
}
});
| {
"end_byte": 1300,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns3.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion4.ts_0_970 | ///<reference path="fourslash.ts" />
//// interface Foo {
//// /** @deprecated */
//// f: number
//// b: number
//// /** @deprecated */
//// baz: number
//// }
//// declare const f: Foo
//// f.[|f|];
//// f.b;
//// f.[|baz|];
//// const kf = 'f'
//// const kb = 'b'
//// declare const k: 'f' | 'b' | 'baz'
//// declare const kfb: 'f' | 'b'
//// declare const kfz: 'f' | 'baz'
//// declare const keys: keyof Foo
//// f[[|kf|]]
//// f[kb]
//// f[k]
//// f[kfb]
//// f[kfz]
//// f[keys]
const ranges = test.ranges();
verify.getSuggestionDiagnostics([
{
message: "'f' is deprecated.",
code: 6385,
range: ranges[0],
reportsDeprecated: true,
},
{
message: "'baz' is deprecated.",
code: 6385,
range: ranges[1],
reportsDeprecated: true,
},
{
message: "'f' is deprecated.",
code: 6385,
range: ranges[2],
reportsDeprecated: true,
}
])
| {
"end_byte": 970,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion4.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash13.ts_0_453 | /// <reference path="fourslash.ts"/>
//// /// <reference path="./module.ts" /> trailing
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"),
c.comment(" "),
c.jsxAttribute("path"),
c.operator("="),
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
c.comment(" "),
c.punctuation("/>"),
c.comment(" trailing"));
| {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash13.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration11.ts_0_452 | /// <reference path='fourslash.ts' />
// @filename: /test.ts
////export const x = 1;
// @filename: /foo.ts
////import * as test from "./test";
////test.foo();
goTo.file("/foo.ts");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
newFileContent: {
"/test.ts":
`export const x = 1;
export function foo() {
throw new Error("Function not implemented.");
}
`
}
});
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties8.ts_0_478 | /// <reference path='fourslash.ts' />
////class A {
//// constructor() {}
////}
////
////abstract class B {}
////
////class C {
//// constructor(a: string, b: number, c: A) {}
////}
////
////interface I {
//// a: A;
//// b: B;
//// c: C;
////}
////[|const foo: I = {};|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const foo: I = {
a: new A,
b: undefined,
c: undefined
};`
});
| {
"end_byte": 478,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties8.ts"
} |
TypeScript/tests/cases/fourslash/extractSymbolForTriggerReason1.ts_0_348 | /// <reference path='fourslash.ts' />
////function foo() {
//// return 1/*a*//*b*/00;
////}
// Only offer refactor for empty span if explicity requested
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Extract Symbol");
verify.refactorAvailableForTriggerReason("invoked", "Extract Symbol", "constant_scope_0");
| {
"end_byte": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractSymbolForTriggerReason1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts_0_662 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
//// function f([|a, b, c, d, e = 0, ...d |]) {
//// }
//// f(1, "string", { a: 1 }, {shouldNotBeHere: 2}, {shouldNotBeHere: 2}, 3, "string");
verify.codeFix({
description: "Infer parameter types from usage",
index: 3,
newFileContent:
`/**
* @param {number} a
* @param {string} b
* @param {{ a: number; }} c
* @param {{ shouldNotBeHere: number; }} d
* @param {(string | number)[]} d
*/
function f(a, b, c, d, e = 0, ...d ) {
}
f(1, "string", { a: 1 }, {shouldNotBeHere: 2}, {shouldNotBeHere: 2}, 3, "string");`,
});
| {
"end_byte": 662,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts"
} |
TypeScript/tests/cases/fourslash/asOperatorFormatting.ts_0_160 | /// <reference path="fourslash.ts" />
//// /**/var x = 3 as number;
goTo.marker();
format.document();
verify.currentLineContentIs("var x = 3 as number;");
| {
"end_byte": 160,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/asOperatorFormatting.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsage_all.ts_0_580 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
// @strictNullChecks: true
////function f(x, y) {
//// x += 0;
//// y += "";
////}
////
////function g(z) {
//// return z * 2;
////}
////
////let x = null;
////function h() {
//// if (!x) x = 2;
////}
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`function f(x: number, y: string) {
x += 0;
y += "";
}
function g(z: number) {
return z * 2;
}
let x: number | null = null;
function h() {
if (!x) x = 2;
}`,
});
| {
"end_byte": 580,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsage_all.ts"
} |
TypeScript/tests/cases/fourslash/completionOfAwaitPromise5.ts_0_426 | /// <reference path='fourslash.ts'/>
//// interface Foo { foo: string }
//// async function foo(x: (a: number) => Promise<Foo>) {
//// [|x(1)./**/|]
//// }
const replacementSpan = test.ranges()[0]
verify.completions({
marker: "",
includes: [
"then",
{ name: "foo", insertText: '(await x(1)).foo', replacementSpan },
],
preferences: {
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfAwaitPromise5.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames9.ts_0_308 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @Filename: a.js
////class /*classDefinition*/Class {
//// f;
////}
//// export { Class };
// @Filename: b.js
////const { Class } = require("./a");
//// [|/*classAliasDefinition*/Class|];
verify.baselineGoToDefinition("classAliasDefinition");
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames9.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForJSDocWithUnresolvedHttpLinks.ts_0_271 | /// <reference path='fourslash.ts' />
// @checkJs: true
// @filename: quickInfoForJSDocWithHttpLinks.js
// #46734
//// /** @see {@link https://hva} */
//// var /*5*/see2 = true
////
//// /** {@link https://hvaD} */
//// var /*6*/see3 = true
verify.baselineQuickInfo();
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForJSDocWithUnresolvedHttpLinks.ts"
} |
TypeScript/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts_0_446 | /// <reference path="fourslash.ts" />
////module Alpha {
//// export var [|{| "name" : "def" |}x|] = 100;
////}
////
////module Beta {
//// import p = Alpha.[|{| "name" : "import" |}x|];
////}
////
////var x = Alpha.[|{| "name" : "mem" |}x|]
goTo.marker('import');
verify.completions({ includes: { name: "x", text: "var Alpha.x: number" } });
verify.baselineDocumentHighlights("import");
verify.baselineGetDefinitionAtPosition("import"); | {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesThrow2.ts_0_914 | /// <reference path='fourslash.ts' />
////function f(a: number) {
//// try {
//// throw "Hello";
////
//// try {
//// [|t/**/hrow|] 10;
//// }
//// catch (x) {
//// return 100;
//// }
//// finally {
//// throw 10;
//// }
//// }
//// catch (x) {
//// throw "Something";
//// }
//// finally {
//// throw "Also something";
//// }
//// if (a > 0) {
//// return (function () {
//// return;
//// return;
//// return;
////
//// if (false) {
//// return true;
//// }
//// throw "Hello!";
//// })() || true;
//// }
////
//// throw 10;
////
//// var unusued = [1, 2, 3, 4].map(x => { throw 4 })
////
//// return;
//// return true;
//// throw false;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 914,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThrow2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments.ts_0_892 | /// <reference path='fourslash.ts' />
////foo(1, 2); /**a*/
/////**b*/ function /*a*/foo/*b*/(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, /**c*/ a /**d*/: /**e*/ number /**f*/, /**g*/ b /**h*/: /**i*/ number /**j*/ = /**k*/ 1 /**l*/) {
//// // m
//// /**n*/ return a + b; // o
//// // p
////} // q
/////**r*/ foo(1);
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: `foo({ a: 1, b: 2 }); /**a*/
/**b*/ function foo(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, { a, b = /**k*/ 1 /**l*/ }: { /**c*/ a /**d*/: /**e*/ number /**f*/; /**g*/ b /**h*/?: /**i*/ number /**j*/; }) {
// m
/**n*/ return a + b; // o
// p
} // q
/**r*/ foo({ a: 1 });`
}); | {
"end_byte": 892,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionAlias.ts_0_670 | /// <reference path='fourslash.ts' />
// @Filename: b.ts
////import /*alias1Definition*/alias1 = require("fileb");
////module Module {
//// export import /*alias2Definition*/alias2 = alias1;
////}
////
////// Type position
////var t1: [|/*alias1Type*/alias1|].IFoo;
////var t2: Module.[|/*alias2Type*/alias2|].IFoo;
////
////// Value posistion
////var v1 = new [|/*alias1Value*/alias1|].Foo();
////var v2 = new Module.[|/*alias2Value*/alias2|].Foo();
// @Filename: a.ts
////export class Foo {
//// private f;
////}
////export interface IFoo {
//// x;
////}
verify.baselineGoToDefinition(
"alias1Type", "alias1Value",
"alias2Type", "alias2Value",
);
| {
"end_byte": 670,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionAlias.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAmbientClassExtendAbstractMethod.ts_0_1229 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////abstract class A {
//// abstract f(a: number, b: string): boolean;
//// abstract f(a: number, b: string): this;
//// abstract f(a: string, b: number): Function;
//// abstract f(a: string): Function;
////
//// abstract f1(this: A): number;
//// abstract f2(this: A, a: number, b: string): number;
////
//// abstract foo(): number;
////}
////
////declare class C extends A {}
verify.codeFix({
description: ts.Diagnostics.Implement_inherited_abstract_class.message,
newFileContent:
`abstract class A {
abstract f(a: number, b: string): boolean;
abstract f(a: number, b: string): this;
abstract f(a: string, b: number): Function;
abstract f(a: string): Function;
abstract f1(this: A): number;
abstract f2(this: A, a: number, b: string): number;
abstract foo(): number;
}
declare class C extends A {
override f(a: number, b: string): boolean;
override f(a: number, b: string): this;
override f(a: string, b: number): Function;
override f(a: string): Function;
override f1(this: A): number;
override f2(this: A, a: number, b: string): number;
override foo(): number;
}`
});
| {
"end_byte": 1229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAmbientClassExtendAbstractMethod.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_objectTypes.ts_0_183 | /// <reference path="fourslash.ts" />
////type X = {
//// /*1*/foo?: string;
//// /*2*/readonly /*3*/bar: { x: num/*4*/ber };
//// /*5*/meh
////}
verify.baselineSmartSelection(); | {
"end_byte": 183,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_objectTypes.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightVarianceModifiers.ts_0_170 | /// <reference path='fourslash.ts'/>
//// type TFoo<Value> = { value: Value };
//// type TBar<[|in|] [|out|] Value> = TFoo<Value>;
verify.baselineDocumentHighlights();
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightVarianceModifiers.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts_0_142 | /// <reference path='fourslash.ts' />
////function foo(a: "[|option 1|]") { }
////foo("[|option 1|]");
verify.baselineDocumentHighlights();
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInFunction1.ts_0_203 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// [|function f1<T>() {}|]
verify.codeFix({
description: "Remove type parameters",
newRangeContent: "function f1() {}",
});
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInFunction1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_module_nodenext.ts_0_480 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @module: nodenext
// @Filename: /a.js
////module.exports = 0;
// @Filename: /b.ts
////module.exports = 0;
// @Filename: /c.cjs
////module.exports = 0;
// @Filename: /d.cts
////module.exports = 0;
goTo.file("/a.js");
verify.codeFixAvailable([]);
goTo.file("/b.ts");
verify.codeFixAvailable([]);
goTo.file("/c.cjs");
verify.codeFixAvailable([]);
goTo.file("/d.cts");
verify.codeFixAvailable([]); | {
"end_byte": 480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_module_nodenext.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts_0_324 | /// <reference path='fourslash.ts'/>
////interface /*interfaceDefinition*/sInt {
//// sVar: number;
//// sFn: () => void;
////}
////
////class iClass implements /*interfaceReference*/sInt {
//// public sVar = 1;
//// public sFn() {
//// }
////}
verify.baselineGetDefinitionAtPosition("interfaceReference");
| {
"end_byte": 324,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts"
} |
TypeScript/tests/cases/fourslash/formatAfterWhitespace.ts_0_204 | /// <reference path="fourslash.ts" />
////function foo()
////{
//// var bar;
//// /*1*/
////}
goTo.marker('1')
edit.insertLine("");
verify.currentFileContentIs(`function foo()
{
var bar;
}`);
| {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAfterWhitespace.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterface_00.ts_0_805 | /// <reference path='fourslash.ts'/>
// Should go to definitions in object literals in variable like declarations when invoked on interface
//// interface Fo/*interface_definition*/o {
//// hello: () => void
//// }
////
//// interface Baz extends Foo {}
////
//// var bar: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello: helloImpl /**0*/ }|];
//// var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|];
////
//// function helloImpl () {}
////
//// function whatever(x: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello() {/**1*/} }|] ) {
//// }
////
//// class Bar {
//// x: Foo = [|{ hello() {/*2*/} }|]
////
//// constructor(public f: Foo = [|{ hello() {/**3*/} }|] ) {}
//// }
verify.baselineGoToImplementation("interface_definition"); | {
"end_byte": 805,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterface_00.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsPropertyAssignedAfterMethodDeclaration.ts_0_366 | /// <reference path='fourslash.ts' />
// See also `jsPropertyAssignedAfterMethodDeclaration.ts`
// @noLib: true
// @allowJs: true
// @noImplicitThis: true
// @Filename: /a.js
////const o = {
//// test/*1*/() {
//// this./*2*/test = 0;
//// }
////};
verify.quickInfoAt("1", "(method) test(): void");
verify.quickInfoAt("2", "(method) test(): void");
| {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsPropertyAssignedAfterMethodDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport6.ts_0_330 | /// <reference path="fourslash.ts" />
//// import [|{ v1 }|] from "fake-module";
//// f1/*0*/();
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/index.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([`{ f1, v1 }`]);
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport6.ts"
} |
TypeScript/tests/cases/fourslash/importStatementCompletions_esModuleInterop2.ts_0_705 | /// <reference path="fourslash.ts" />
// @esModuleInterop: true
// @Filename: /mod.ts
//// const foo = 0;
//// export = foo;
// @Filename: /importExportEquals.ts
//// [|import f/**/|]
verify.completions({
isNewIdentifierLocation: true,
marker: "",
exact: [{
name: "foo",
source: "./mod",
insertText: `import foo$1 from "./mod";`, // <-- default import
isSnippet: true,
replacementSpan: test.ranges()[0],
sourceDisplay: "./mod",
}, {
name: "type",
sortText: completion.SortText.GlobalsOrKeywords,
}],
preferences: {
includeCompletionsForImportStatements: true,
includeInsertTextCompletions: true,
includeCompletionsWithSnippetText: true,
}
});
| {
"end_byte": 705,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importStatementCompletions_esModuleInterop2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts_0_683 | /// <reference path='fourslash.ts' />
////function /*1*/makePoint(x: number) {
//// return {
//// b: 10,
//// get x() { return x; },
//// set x(a: number) { this.b = a; }
//// };
////};
////var /*4*/point = makePoint(2);
////var /*2*/x = point.x;
////point./*3*/x = 30;
verify.quickInfos({
1: "function makePoint(x: number): {\n b: number;\n x: number;\n}",
2: "var x: number",
3: "(property) x: number",
4: "var point: {\n b: number;\n x: number;\n}",
});
verify.completions({
marker: "3",
exact: [
{ name: "b", text: "(property) b: number" },
{ name: "x", text: "(property) x: number" },
],
});
| {
"end_byte": 683,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_jsx1.ts_0_830 | /// <reference path="fourslash.ts" />
// @jsx: react
// @Filename: /node_modules/react/index.d.ts
////export const React: any;
// @Filename: /a.tsx
////[|<this>|]</this>
// @Filename: /Foo.tsx
////export const Foo = 0;
// @Filename: /c.tsx
////import { React } from "react";
////<Foo />;
// @Filename: /d.tsx
////import { Foo } from "./Foo";
////<Foo />;
// Tests that we don't crash at non-identifier location.
goTo.file("/a.tsx");
verify.importFixAtPosition([]);
// When constructor is missing, provide fix for that
goTo.file("/c.tsx");
verify.importFixAtPosition([
`import { React } from "react";
import { Foo } from "./Foo";
<Foo />;`]);
// When JSX namespace is missing, provide fix for that
goTo.file("/d.tsx");
verify.importFixAtPosition([
`import { React } from "react";
import { Foo } from "./Foo";
<Foo />;`]);
| {
"end_byte": 830,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_jsx1.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts_0_432 | /// <reference path='fourslash.ts' />
////interface SnapCrackle {
//// /*def1*/pop(): string;
////}
////
////interface Magnitude {
//// /*def2*/pop(): number;
////}
////
////interface Art {
//// /*def3*/pop(): boolean;
////}
////
////var art: Art;
////var magnitude: Magnitude;
////var snapcrackle: SnapCrackle;
////
////var x = (snapcrackle || magnitude || art).[|/*usage*/pop|];
verify.baselineGoToDefinition("usage");
| {
"end_byte": 432,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectLiteral4.ts_0_684 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////interface Thing {
//// hello: number;
//// world: string;
////}
////
////declare function funcA(x : Thing): void;
////declare function funcB(x?: Thing): void;
////declare function funcC(x : Thing | null): void;
////declare function funcD(x : Thing | undefined): void;
////declare function funcE(x : Thing | null | undefined): void;
////declare function funcF(x?: Thing | null | undefined): void;
////
////funcA({ /*A*/ });
////funcB({ /*B*/ });
////funcC({ /*C*/ });
////funcD({ /*D*/ });
////funcE({ /*E*/ });
////funcF({ /*F*/ });
verify.completions({ marker: test.markers(), exact: ["hello", "world"] });
| {
"end_byte": 684,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral4.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern10.ts_0_410 | /// <reference path='fourslash.ts'/>
////interface I {
//// propertyOfI_1: number;
//// propertyOfI_2: string;
////}
////interface J {
//// property1: I;
//// property2: string;
////}
////
////var foo: J[];
////var [{ property1: { propertyOfI_1, }, /*1*/ }, { /*2*/ }] = foo;
verify.completions(
{ marker: "1", exact: "property2" },
{ marker: "2", exact: ["property1", "property2"] },
);
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction14.ts_0_313 | /// <reference path='fourslash.ts' />
////const f = function(): number {
//// await Promise.resolve(1);
////}
verify.codeFix({
index: 1,
description: "Add async modifier to containing function",
newFileContent:
`const f = async function(): Promise<number> {
await Promise.resolve(1);
}`,
});
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction14.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard5.ts_0_1738 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/foo/package.json
//// {
//// "name": "foo",
//// "main": "dist/index.js",
//// "module": "dist/index.mjs",
//// "types": "dist/index.d.ts",
//// "exports": {
//// ".": {
//// "import": {
//// "types": "./dist/types/index.d.mts",
//// "default": "./dist/esm/index.mjs"
//// },
//// "default": {
//// "types": "./dist/types/index.d.ts",
//// "default": "./dist/cjs/index.js"
//// }
//// },
//// "./*": {
//// "import": {
//// "types": "./dist/types/*.d.mts",
//// "default": "./dist/esm/*.mjs"
//// },
//// "default": {
//// "types": "./dist/types/*.d.ts",
//// "default": "./dist/cjs/*.js"
//// }
//// },
//// "./only-in-cjs": {
//// "require": {
//// "types": "./dist/types/only-in-cjs/index.d.ts",
//// "default": "./dist/cjs/only-in-cjs/index.js"
//// }
//// }
//// }
//// }
// @Filename: /node_modules/foo/dist/types/index.d.mts
//// export const index = 0;
// @Filename: /node_modules/foo/dist/types/index.d.ts
//// export const index = 0;
// @Filename: /node_modules/foo/dist/types/blah.d.mts
//// export const blah = 0;
// @Filename: /node_modules/foo/dist/types/blah.d.ts
//// export const blah = 0;
// @Filename: /node_modules/foo/dist/types/only-in-cjs/index.d.ts
//// export const onlyInCjs = 0;
// @Filename: /index.mts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{ name: "blah", kind: "script", kindModifiers: "" },
{ name: "index", kind: "script", kindModifiers: "" },
]
});
| {
"end_byte": 1738,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard5.ts"
} |
TypeScript/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts_0_104 | /// <reference path="fourslash.ts" />
////
//// // foo
//// 1;
goTo.bof();
edit.insert("var x;\n");
| {
"end_byte": 104,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts"
} |
TypeScript/tests/cases/fourslash/jsdocLink1.ts_0_329 | ///<reference path="fourslash.ts" />
//// class C {
//// }
//// /**
//// * {@link C}
//// * @wat Makes a {@link C}. A default one.
//// * {@link C()}
//// * {@link C|postfix text}
//// * {@link unformatted postfix text}
//// * @see {@link C} its great
//// */
//// function /**/CC() {
//// }
verify.baselineQuickInfo();
| {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocLink1.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionImport3.ts_0_192 | /// <reference path='fourslash.ts'/>
// @Filename: /b.ts
/////*2*/export const foo = 1;
// @Filename: /a.ts
////import { foo } [|from /*1*/|] "./b";
verify.baselineGoToDefinition("1");
| {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImport3.ts"
} |
TypeScript/tests/cases/fourslash/completionsLiteralDirectlyInArgumentWithNullableConstraint.ts_0_255 | /// <reference path="fourslash.ts" />
// @strict: true
////
//// declare function func<
//// const T extends 'a' | 'b' | undefined = undefined,
//// >(arg?: T): string;
////
//// func('/*1*/');
verify.completions({ marker: ["1"], exact: [`a`, `b`] });
| {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralDirectlyInArgumentWithNullableConstraint.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties14.ts_0_327 | /// <reference path='fourslash.ts' />
////interface Foo {
//// a: number;
//// b: number;
////}
////function f(a: number, b: number, c: Foo) {}
////[|f(1, 2, {})|];
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`f(1, 2, {
a: 0,
b: 0
})`
});
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties14.ts"
} |
TypeScript/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts_0_574 | /// <reference path='fourslash.ts'/>
//// let configFiles1: {
//// jspm: string;
//// 'jspm:browser': string;
//// } = {
//// /*0*/: "",
//// }
//// let configFiles2: {
//// jspm: string;
//// 'jspm:browser': string;
//// } = {
//// jspm: "",
//// '[|/*1*/|]': ""
//// }
const replacementSpan = test.ranges()[0]
verify.completions(
{ marker: "0", exact: ['"jspm:browser"', "jspm"] },
{ marker: "1", exact: [
{ name: "jspm", replacementSpan },
{ name: "jspm:browser", replacementSpan }
] }
);
| {
"end_byte": 574,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts"
} |
TypeScript/tests/cases/fourslash/verifySingleFileEmitOutput1.ts_0_325 | /// <reference path='fourslash.ts' />
// @Filename: verifySingleFileEmitOutput1_file0.ts
////export class A {
////}
////export class Z {
////}
// @Filename: verifySingleFileEmitOutput1_file1.ts
////import f = require("./verifySingleFileEmitOutput1_file0");
////var /**/b = new f.A();
verify.quickInfoAt("", "var b: f.A");
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/verifySingleFileEmitOutput1.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics8.ts_0_132 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////type a = b;
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics8.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts_0_657 | /// <reference path='fourslash.ts' />
////const foo = class Foo {
//// /*a*/constructor/*b*/(a: number, b: number) { }
////}
////class Bar extends foo {
//// constructor() {
//// super(1, 2);
//// }
////}
goTo.select("a", "b");
// Refactor should not make changes
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const foo = class Foo {
constructor(a: number, b: number) { }
}
class Bar extends foo {
constructor() {
super(1, 2);
}
}`
}); | {
"end_byte": 657,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts"
} |
TypeScript/tests/cases/fourslash/propertyDuplicateIdentifierError.ts_0_166 | /// <reference path="fourslash.ts" />
////export class C {
//// x: number;
//// get x(): number { return 1; }
////}/*1*/
goTo.marker('1');
edit.insert('/n');
| {
"end_byte": 166,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/propertyDuplicateIdentifierError.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts_0_213 | /// <reference path='fourslash.ts'/>
// @Filename: b.ts
////import {Foo, Bar} from [|'e/*1*/'|];
// @Filename: a.ts
////declare module /*2*/"e" {
//// class Foo { }
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts"
} |
TypeScript/tests/cases/fourslash/deleteClassWithEnumPresent.ts_0_1317 | ///<reference path="fourslash.ts"/>
////enum Foo { a, b, c }
/////**/class Bar { }
goTo.marker();
edit.deleteAtCaret('class Bar { }'.length);
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Foo",
"kind": "enum",
"childItems": [
{
"text": "a",
"kind": "enum member"
},
{
"text": "b",
"kind": "enum member"
},
{
"text": "c",
"kind": "enum member"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Foo",
"kind": "enum"
}
]
},
{
"text": "Foo",
"kind": "enum",
"childItems": [
{
"text": "a",
"kind": "enum member"
},
{
"text": "b",
"kind": "enum member"
},
{
"text": "c",
"kind": "enum member"
}
],
"indent": 1
}
]);
| {
"end_byte": 1317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deleteClassWithEnumPresent.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts_0_931 | /// <reference path='fourslash.ts'/>
// Should not return implementations in classes with a shared parent that implements the interface
//// interface Foo {
//// hello (): void;
//// }
////
//// class SuperBar implements Foo {
//// [|hello|]() {}
//// }
////
//// class Bar extends SuperBar {
//// hello2() {}
//// }
////
//// class OtherBar extends SuperBar {
//// hello() {}
//// hello2() {}
//// hello3() {}
//// }
////
//// class NotRelatedToBar {
//// hello() {} // Equivalent to last case, but shares no common ancestors with Bar and so is not returned
//// hello2() {}
//// hello3() {}
//// }
////
//// class NotBar extends SuperBar {
//// hello() {} // Should not be returned because it is not structurally equivalent to Bar
//// }
////
//// function whatever(x: Bar) {
//// x.he/*function_call*/llo()
//// }
verify.baselineGoToImplementation("function_call"); | {
"end_byte": 931,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts"
} |
TypeScript/tests/cases/fourslash/indentationInClassExpression.ts_0_1001 | /// <reference path="fourslash.ts"/>
////function foo() {
//// let x: any;
//// x = /*8_0*/class { constructor(public x: number) { } };
//// x = class /*4_0*/{ constructor(public x: number) { } };
//// x = class { /*8_1*/constructor(public x: number) { } };
//// x = class { constructor(/*12_0*/public x: number) { } };
//// x = class { constructor(public /*12_1*/x: number) { } };
//// x = class { constructor(public x: number) {/*8_2*/ } };
//// x = class {
//// constructor(/*12_2*/public x: number) { }
//// };
//// x = class {
//// constructor(public x: number) {/*8_3*/ }
//// };
//// x = class {
//// constructor(public x: number) { }/*4_1*/};
////}
function verifyIndentation(level: number, count: number) {
for (let i = 0; i < count; ++i) {
goTo.marker(`${level}_${i}`);
edit.insertLine("");
verify.indentationIs(level);
}
}
verifyIndentation(4, 2);
verifyIndentation(8, 4);
verifyIndentation(12, 3); | {
"end_byte": 1001,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInClassExpression.ts"
} |
TypeScript/tests/cases/fourslash/referencesForDeclarationKeywords.ts_0_1582 | /// <reference path='fourslash.ts'/>
////class Base {}
////interface Implemented1 {}
/////*classDecl1_classKeyword*/class C1 /*classDecl1_extendsKeyword*/extends Base /*classDecl1_implementsKeyword*/implements Implemented1 {
//// /*getDecl_getKeyword*/get e() { return 1; }
//// /*setDecl_setKeyword*/set e(v) {}
////}
/////*interfaceDecl1_interfaceKeyword*/interface I1 /*interfaceDecl1_extendsKeyword*/extends Base { }
/////*typeDecl_typeKeyword*/type T = { }
/////*enumDecl_enumKeyword*/enum E { }
/////*namespaceDecl_namespaceKeyword*/namespace N { }
/////*moduleDecl_moduleKeyword*/module M { }
/////*functionDecl_functionKeyword*/function fn() {}
/////*varDecl_varKeyword*/var x;
/////*letDecl_letKeyword*/let y;
/////*constDecl_constKeyword*/const z = 1;
////interface Implemented2 {}
////interface Implemented3 {}
////class C2 /*classDecl2_implementsKeyword*/implements Implemented2, Implemented3 {}
////interface I2 /*interfaceDecl2_extendsKeyword*/extends Implemented2, Implemented3 {}
verify.baselineFindAllReferences(
'classDecl1_classKeyword',
'classDecl1_extendsKeyword',
'classDecl1_implementsKeyword',
'classDecl2_implementsKeyword',
'getDecl_getKeyword',
'setDecl_setKeyword',
'interfaceDecl1_interfaceKeyword',
'interfaceDecl1_extendsKeyword',
'interfaceDecl2_extendsKeyword',
'typeDecl_typeKeyword',
'enumDecl_enumKeyword',
'namespaceDecl_namespaceKeyword',
'moduleDecl_moduleKeyword',
'functionDecl_functionKeyword',
'varDecl_varKeyword',
'letDecl_letKeyword',
'constDecl_constKeyword',)
| {
"end_byte": 1582,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForDeclarationKeywords.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts_3_498 | / <reference path="fourslash.ts"/>
////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/}/*6*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 8);
verifyIndentationAfterNewLine("6", 0);
| {
"end_byte": 498,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts"
} |
TypeScript/tests/cases/fourslash/updateSourceFile_jsdocSignature.ts_0_240 | /// <reference path='fourslash.ts' />
/////**
//// * @callback Cb
//// * @return {/**/}
//// */
////let x;
// Previously this crashed due to an invalid cast in `forEachChild` for `JSDocSignature`.
goTo.marker("");
edit.insert("number");
| {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/updateSourceFile_jsdocSignature.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties45.ts_0_262 | /// <reference path='fourslash.ts' />
// @strict: true
//// type U = { u?: { v: string } };
//// const u: U = { [|u: {}|] };
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`u: {
v: ""
}`,
});
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties45.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts_0_433 | /// <reference path='fourslash.ts' />
//// function f(templateStrings, x, y, z) { return 10; }
//// function g(templateStrings, x, y, z) { return ""; }
////
//// f `/*1*/ /*2*/${
verify.signatureHelp({
marker: test.markers(),
text: "f(templateStrings: any, x: any, y: any, z: any): number",
argumentCount: 2,
parameterCount: 4,
parameterName: "templateStrings",
parameterSpan: "templateStrings: any",
});
| {
"end_byte": 433,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeExtendsToImplementsTypeParams.ts_0_283 | /// <reference path='fourslash.ts' />
////interface I<X, Y> { x: X; y: Y; }
////[|class C<T extends string , U> extends I<T , U>|]{}
verify.codeFix({
description: "Change 'extends' to 'implements'",
newRangeContent: "class C<T extends string , U> implements I<T , U>",
});
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeExtendsToImplementsTypeParams.ts"
} |
TypeScript/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType2.ts_0_1406 | /// <reference path="fourslash.ts" />
// @Filename: /a.tsx
//// type Values<T> = T[keyof T];
////
//// type GetStates<T> = T extends { states: object } ? T["states"] : never;
////
//// type IsNever<T> = [T] extends [never] ? 1 : 0;
////
//// type GetIds<T, Gathered extends string = never> = IsNever<T> extends 1
//// ? Gathered
//// : "id" extends keyof T
//// ? GetIds<Values<GetStates<T>>, Gathered | `#${T["id"] & string}`>
//// : GetIds<Values<GetStates<T>>, Gathered>;
////
//// type StateConfig<
//// TStates extends Record<string, StateConfig> = Record<
//// string,
//// StateConfig<any>
//// >,
//// TIds extends string = string
//// > = {
//// id?: string;
//// initial?: keyof TStates & string;
//// states?: {
//// [K in keyof TStates]: StateConfig<GetStates<TStates[K]>, TIds>;
//// };
//// on?: Record<string, TIds | `.${keyof TStates & string}`>;
//// };
////
//// declare function createMachine<const T extends StateConfig<GetStates<T>, GetIds<T>>>(
//// config: T
//// ): void;
////
//// createMachine({
//// initial: "child",
//// states: {
//// child: {
//// initial: "foo",
//// states: {
//// foo: {
//// id: "wow_deep_id",
//// },
//// },
//// },
//// },
//// on: {
//// EV: "/*ts*/",
//// },
//// });
verify.completions({ marker: ["ts"], exact: ["#wow_deep_id", ".child"] });
| {
"end_byte": 1406,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_initializer1.ts_0_620 | /// <reference path="fourslash.ts" />
////async function fn(a: string, b: Promise<string>) {
//// const x = b;
//// fn(x, b);
//// fn(b, b);
////}
verify.codeFix({
description: "Add 'await' to initializer for 'x'",
index: 0,
newFileContent:
`async function fn(a: string, b: Promise<string>) {
const x = await b;
fn(x, b);
fn(b, b);
}`
});
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Fix_all_expressions_possibly_missing_await.message,
fixId: "addMissingAwait",
newFileContent:
`async function fn(a: string, b: Promise<string>) {
const x = await b;
fn(x, b);
fn(await b, b);
}`
});
| {
"end_byte": 620,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_initializer1.ts"
} |
TypeScript/tests/cases/fourslash/whiteSpaceTrimming4.ts_0_161 | /// <reference path="fourslash.ts" />
////var re = /\w+ /*1*//;
goTo.marker('1');
edit.insert("\n");
verify.currentFileContentIs("var re = /\\w+\n /;");
| {
"end_byte": 161,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/whiteSpaceTrimming4.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletionOnClosingTag2.ts_3_385 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x1 = <div>
//// <h1> Hello world </ /*2*/>
//// </ /*1*/>
verify.completions({ marker: "1", exact: ["div"] }, { marker: "2", exact: ["h1"] });
| {
"end_byte": 385,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionOnClosingTag2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnInternalAliases.ts_0_1460 | /// <reference path='fourslash.ts' />
/////** Module comment*/
////export module m1 {
//// /** m2 comments*/
//// export module m2 {
//// /** class comment;*/
//// export class /*1*/c {
//// };
//// }
//// export function foo() {
//// }
////}
/////**This is on import declaration*/
////import /*2*/internalAlias = m1.m2./*3*/c;
////var /*4*/newVar = new /*5*/internalAlias();
////var /*6*/anotherAliasVar = /*7*/internalAlias;
////import /*8*/internalFoo = m1./*9*/foo;
////var /*10*/callVar = /*11*/internalFoo();
////var /*12*/anotherAliasFoo = /*13*/internalFoo;
verify.quickInfos({
1: ["class m1.m2.c", "class comment;"],
2: ["(alias) class internalAlias\nimport internalAlias = m1.m2.c", "This is on import declaration"],
3: ["class m1.m2.c", "class comment;"],
4: "var newVar: internalAlias",
5: ["(alias) new internalAlias(): internalAlias\nimport internalAlias = m1.m2.c", "This is on import declaration"],
6: "var anotherAliasVar: typeof internalAlias",
7: ["(alias) class internalAlias\nimport internalAlias = m1.m2.c", "This is on import declaration"],
8: "(alias) function internalFoo(): void\nimport internalFoo = m1.foo",
9: "function m1.foo(): void",
10: "var callVar: void",
11: "(alias) internalFoo(): void\nimport internalFoo = m1.foo",
12: "var anotherAliasFoo: () => void",
13: "(alias) function internalFoo(): void\nimport internalFoo = m1.foo"
});
| {
"end_byte": 1460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnInternalAliases.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization_all_3.ts_0_1190 | /// <reference path='fourslash.ts' />
// @strict: true
//// abstract class A { abstract a (); }
////
//// class TT { constructor () {} }
////
//// class AT extends A { a () {} }
////
//// class Foo {}
////
//// class T {
////
//// a: boolean;
////
//// static b: boolean;
////
//// private c: boolean;
////
//// d: number | undefined;
////
//// e: string | boolean;
////
//// f: 1;
////
//// g: "123" | "456";
////
//// h: boolean;
////
//// i: TT;
////
//// j: A;
////
//// k: AT;
////
//// l: Foo;
////
//// m: number[];
//// }
verify.codeFixAll({
fixId: 'addMissingPropertyInitializer',
fixAllDescription: "Add initializers to all uninitialized properties",
newFileContent: `abstract class A { abstract a (); }
class TT { constructor () {} }
class AT extends A { a () {} }
class Foo {}
class T {
a: boolean = false;
static b: boolean;
private c: boolean = false;
d: number | undefined;
e: string | boolean = false;
f: 1 = 1;
g: "123" | "456" = "123";
h: boolean = false;
i: TT = new TT;
j: A;
k: AT = new AT;
l: Foo = new Foo;
m: number[] = [];
}`
}); | {
"end_byte": 1190,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization_all_3.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts_0_352 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => a + 1;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Add braces to arrow function",
actionDescription: "Add braces to arrow function",
newContent: `const foo = a => {
return a + 1;
};`,
});
| {
"end_byte": 352,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts"
} |
TypeScript/tests/cases/fourslash/tsxRename7.ts_0_755 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// [|[|{| "contextRangeIndex": 0 |}propx|]: number|]
//// propString: string
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt />;
//// let opt1 = <Opt [|[|{| "contextRangeIndex": 2 |}propx|]={100}|] propString />;
//// let opt2 = <Opt [|[|{| "contextRangeIndex": 4 |}propx|]={100}|] optional/>;
//// let opt3 = <Opt wrong />;
verify.baselineRenameAtRangesWithText("propx");
| {
"end_byte": 755,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename7.ts"
} |
TypeScript/tests/cases/fourslash/renameReferenceFromLinkTag4.ts_0_139 | /// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/B} */
//// A,
//// B
////}
verify.baselineRename("", {});
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameReferenceFromLinkTag4.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoGetterSetter.ts_0_737 | /// <reference path="fourslash.ts" />
// @target: es2015
//// class C {
//// #x = Promise.resolve("")
//// set /*setterDef*/myValue(x: Promise<string> | string) {
//// this.#x = Promise.resolve(x);
//// }
//// get /*getterDef*/myValue(): Promise<string> {
//// return this.#x;
//// }
//// }
//// let instance = new C();
//// instance./*setterUse*/myValue = instance./*getterUse*/myValue;
verify.quickInfoAt("getterUse", "(property) C.myValue: Promise<string>");
verify.quickInfoAt("getterDef", "(getter) C.myValue: Promise<string>");
verify.quickInfoAt("setterUse", "(property) C.myValue: string | Promise<string>");
verify.quickInfoAt("setterDef", "(setter) C.myValue: string | Promise<string>");
| {
"end_byte": 737,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoGetterSetter.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInForLoop4FS.ts_0_293 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// function f1 () {
//// [|for(var i = 0, j= 0, k=0; ;j++, k++) |]{
////
//// }
//// }
verify.codeFix({
description: "Remove unused declaration for: 'i'",
newRangeContent: "for(var j= 0, k=0; ;j++, k++) ",
});
| {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInForLoop4FS.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFromAtTypesScopedPackage.ts_0_250 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: node_modules/@types/myLib__scoped/index.d.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([
`import { f1 } from "@myLib/scoped";
f1();`
]); | {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFromAtTypesScopedPackage.ts"
} |
TypeScript/tests/cases/fourslash/completionsStringsWithTriggerCharacter.ts_0_1784 | /// <reference path="fourslash.ts" />
//// type A = "a/b" | "b/a";
//// const a: A = "[|a/*1*/|]";
////
//// type B = "a@b" | "b@a";
//// const a: B = "[|a@/*2*/|]";
////
//// type C = "a.b" | "b.a";
//// const c: C = "[|a./*3*/|]";
////
//// type D = "a'b" | "b'a";
//// const d: D = "[|a'/*4*/|]";
////
//// type E = "a`b" | "b`a";
//// const e: E = "[|a`/*5*/|]";
////
//// type F = 'a"b' | 'b"a';
//// const f: F = '[|a"/*6*/|]';
////
//// type G = "a<b" | "b<a";
//// const g: G = '[|a</*7*/|]';
verify.completions({ marker: '1', exact: [
{ name: "a/b", replacementSpan: test.ranges()[0] },
{ name: "b/a", replacementSpan: test.ranges()[0] }
], triggerCharacter: "/" });
verify.completions({ marker: "2", exact: [
{ name: "a@b", replacementSpan: test.ranges()[1] },
{ name: "b@a", replacementSpan: test.ranges()[1] }
], triggerCharacter: "@" });
verify.completions({ marker: "3", exact: [
{ name: "a.b", replacementSpan: test.ranges()[2] },
{ name: "b.a", replacementSpan: test.ranges()[2] }
], triggerCharacter: "." });
verify.completions({ marker: "4", exact: [
{ name: "a'b", replacementSpan: test.ranges()[3] },
{ name: "b'a", replacementSpan: test.ranges()[3] }
], triggerCharacter: "'" });
verify.completions({ marker: "5", exact: [
{ name: "a`b", replacementSpan: test.ranges()[4] },
{ name: "b`a", replacementSpan: test.ranges()[4] }
], triggerCharacter: "`" });
verify.completions({ marker: "6", exact: [
{ name: 'a"b', replacementSpan: test.ranges()[5] },
{ name: 'b"a', replacementSpan: test.ranges()[5] }
], triggerCharacter: '"' });
verify.completions({ marker: "7", exact: [
{ name: 'a<b', replacementSpan: test.ranges()[6] },
{ name: 'b<a', replacementSpan: test.ranges()[6] }
], triggerCharacter: '<' });
| {
"end_byte": 1784,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsStringsWithTriggerCharacter.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts_0_1279 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "@emotion/core": "*"
//// }
////}
//@Filename: /node_modules/@emotion/css/index.d.ts
////export declare const css: any;
////const css2: any;
////export { css2 };
//@Filename: /node_modules/@emotion/css/package.json
////{
//// "name": "@emotion/css",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/@emotion/core/index.d.ts
////import { css2 } from "@emotion/css";
////export { css } from "@emotion/css";
////export { css2 };
//@Filename: /node_modules/@emotion/core/package.json
////{
//// "name": "@emotion/core",
//// "types": "./index.d.ts"
////}
//@Filename: /src/index.ts
////cs/**/
verify.completions({
marker: test.marker(""),
includes: [
completion.undefinedVarEntry,
{
name: "css",
source: "/node_modules/@emotion/core/index",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "css2",
source: "/node_modules/@emotion/core/index",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
...completion.statementKeywordsWithTypes
],
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 1279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveParameterNamesInSpan2.ts_0_745 | /// <reference path="fourslash.ts" />
//// function foo1 (a: number, b: number) {}
//// function foo2 (c: number, d: number) {}
//// function foo3 (e: number, f: number) {}
//// function foo4 (g: number, h: number) {}
//// function foo5 (i: number, j: number) {}
//// function foo6 (k: number, l: number) {}
//// foo1(/*a*/1, /*b*/2);
//// foo2(/*c*/1, /*d*/2);
//// foo3(/*e*/1, /*f*/2);
//// foo4(/*g*/1, /*h*/2);
//// foo5(/*i*/1, /*j*/2);
//// foo6(/*k*/1, /*l*/2);
const start = test.markerByName('c');
const end = test.markerByName('h');
const span = { start: start.position, length: end.position - start.position };
verify.baselineInlayHints(span, {
includeInlayParameterNameHints: "literals",
interactiveInlayHints: true
});
| {
"end_byte": 745,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveParameterNamesInSpan2.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType4.ts_0_520 | /// <reference path="fourslash.ts" />
//// import {
//// d,
//// type d as D,
//// type c,
//// c as C,
//// b,
//// b as B,
//// type A,
//// a
//// } from './foo';
//// console.log(A, a, B, b, c, C, d, D);
verify.organizeImports(
`import {
type A,
a,
b,
b as B,
type c,
c as C,
d,
type d as D
} from './foo';
console.log(A, a, B, b, c, C, d, D);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline" }
);
| {
"end_byte": 520,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType4.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts_0_882 | /// <reference path="fourslash.ts" />
// @module: es2015
// @verbatimModuleSyntax: true
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import type { SomePig, SomeInterface } from "./exports.js";
//// new SomePig/**/
verify.completions({
marker: "",
includes: [{
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
hasAction: true,
}]
});
verify.applyCodeActionFromCompletion("", {
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
description: `Remove 'type' from import declaration from "./exports.js"`,
newFileContent:
`import { SomePig, type SomeInterface } from "./exports.js";
new SomePig`,
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 882,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInLambda4.ts_0_294 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// class A<T> {
//// public x: T;
//// }
//// [|var y: new <T,U>(a:T)=>void;|]
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'U'",
newRangeContent: "var y: new <T>(a:T)=>void;",
});
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInLambda4.ts"
} |
TypeScript/tests/cases/fourslash/renameJsThisProperty05.ts_0_323 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////class C {
//// constructor(y) {
//// this.x = y;
//// }
////}
////[|C.prototype.[|{| "contextRangeIndex": 0 |}z|] = 1;|]
////var t = new C(12);
////[|t.[|{| "contextRangeIndex": 2 |}z|] = 11;|]
verify.baselineRenameAtRangesWithText("z");
| {
"end_byte": 323,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsThisProperty05.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnThis3.ts_0_707 | /// <reference path='fourslash.ts' />
////interface Restricted {
//// n: number;
////}
////function implicitAny(x: number): void {
//// return th/*1*/is;
////}
////function explicitVoid(th/*2*/is: void, x: number): void {
//// return th/*3*/is;
////}
////function explicitInterface(th/*4*/is: Restricted): void {
//// console.log(thi/*5*/s);
////}
////function explicitLiteral(th/*6*/is: { n: number }): void {
//// console.log(th/*7*/is);
////}
verify.quickInfos({
1: "any",
2: "(parameter) this: void",
3: "this: void",
4: "(parameter) this: Restricted",
5: "this: Restricted",
6: "(parameter) this: {\n n: number;\n}",
7: "this: {\n n: number;\n}"
});
| {
"end_byte": 707,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnThis3.ts"
} |
TypeScript/tests/cases/fourslash/regexErrorRecovery.ts_0_369 | /// <reference path="fourslash.ts" />
//// // test code
//////var x = //**/a/;/*1*/
//////x.exec("bab");
//goTo.marker("");
//debug.printCurrentFileState();
//verify.quickInfoIs("RegExp");
//// Bug 579071: Parser no longer detects a Regex when an open bracket is inserted
edit.insert("(");
////verify.quickInfoIs("RegExp");
////verify.not.errorExistsAfterMarker("1"); | {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/regexErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration25.ts_0_563 | /// <reference path="fourslash.ts" />
////interface Foo {
//// f(type: string, listener: (this: object, type: string) => any): void;
////}
////declare let foo: Foo;
////foo.f("test", fn);
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "fn"],
newFileContent:
`interface Foo {
f(type: string, listener: (this: object, type: string) => any): void;
}
declare let foo: Foo;
foo.f("test", fn);
function fn(this: object, type: string) {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 563,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration25.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter2.ts_0_358 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////[|function f(
//// a: number, b: number,
//// c: number,
////)|] {
//// a;
//// c;
////}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'b'",
newRangeContent:
`function f(
a: number,
c: number,
)`
});
| {
"end_byte": 358,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter2.ts"
} |
TypeScript/tests/cases/fourslash/navigateItemsImports.ts_0_823 | /// <reference path="fourslash.ts" />
// @noLib: true
////import [|{| "name": "ns", "kind": "alias" |}* as ns|] from "a";
////
////import { [|{| "name": "a", "kind": "alias" |}a|] } from "a";
////
////import { [|{| "name": "B", "kind": "alias" |}b as B|] } from "a";
////
////import { [|{| "name": "c", "kind": "alias" |}c|],
//// [|{| "name": "dee", "kind": "alias" |}d as dee|] } from "a";
////
////import [|{| "name": "d1", "kind": "alias" |}d1|], {
//// [|{| "name": "e", "kind": "alias" |}e|] } from "a";
////
////[|{| "name": "f", "kind": "alias" |}import f = require("a");|]
// TODO: GH#25237 (range for `d1` is too big)
for (const range of test.ranges()) {
verify.navigateTo({
pattern: range.marker.data.name,
expected: [{ ...range.marker.data, range }],
});
}
| {
"end_byte": 823,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigateItemsImports.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember9.ts_0_519 | /// <reference path='fourslash.ts' />
////class C {
//// z: boolean = true;
//// method() {
//// const x = 0;
//// this.y(x, "a", this.z);
//// }
////}
verify.codeFix({
index: 0,
description: ignoreInterpolations(ts.Diagnostics.Declare_method_0),
newFileContent:
`class C {
z: boolean = true;
method() {
const x = 0;
this.y(x, "a", this.z);
}
y(x: number, arg1: string, z: boolean) {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 519,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember9.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTemplates1.ts_0_1042 | /// <reference path="fourslash.ts"/>
////var v = 10e0;
////var x = {
//// p1: `hello world`,
//// p2: `goodbye ${0} cruel ${0} world`,
////};
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"),
c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"),
c.identifier("p1"), c.punctuation(":"), c.stringLiteral("`hello world`"), c.punctuation(","),
c.identifier("p2"), c.punctuation(":"), c.stringLiteral("`goodbye ${"), c.numericLiteral("0"), c.stringLiteral("} cruel ${"), c.numericLiteral("0"), c.stringLiteral("} world`"), c.punctuation(","),
c.punctuation("}"), c.punctuation(";"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "v"),
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("property.declaration", "p1"),
c2.semanticToken("property.declaration", "p2"),
);
| {
"end_byte": 1042,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTemplates1.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassificatonTypeAlias.ts_0_1061 | /// <reference path="fourslash.ts"/>
////type /*0*/Alias = number
////var x: /*1*/Alias;
////var y = </*2*/Alias>{};
////function f(x: /*3*/Alias): /*4*/Alias { return undefined; }
const c = classification("original");
verify.semanticClassificationsAre("original",
c.typeAliasName("Alias", test.marker("0").position),
c.typeAliasName("Alias", test.marker("1").position),
c.typeAliasName("Alias", test.marker("2").position),
c.typeAliasName("Alias", test.marker("3").position),
c.typeAliasName("Alias", test.marker("4").position)
);
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("type.declaration", "Alias"),
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("type", "Alias"),
c2.semanticToken("variable.declaration", "y"),
c2.semanticToken("type", "Alias"),
c2.semanticToken("function.declaration", "f"),
c2.semanticToken("parameter.declaration", "x"),
c2.semanticToken("type", "Alias"),
c2.semanticToken("type", "Alias"),
);
| {
"end_byte": 1061,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificatonTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts_0_499 | /// <reference path='fourslash.ts' />
//// [|class A {
//// constructor() {
//// let e: any = 10;
//// this.x = { a: 10, b: "hello", c: undefined, d: null, e: e };
//// }
//// }|]
verify.rangeAfterCodeFix(`
class A {
x: { a: number; b: string; c: any; d: any; e: any; };
constructor() {
let e: any = 10;
this.x = { a: 10, b: "hello", c: undefined, d: null, e: e };
}
}
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
| {
"end_byte": 499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction32.ts_0_489 | /// <reference path='fourslash.ts' />
////const a = /*a*/()/*b*/ => {
//// return (
//// /*
//// multi-line comment
//// */
//// 1
//// );
////};
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Remove braces from arrow function",
actionDescription: "Remove braces from arrow function",
newContent: `const a = () => (
/*
multi-line comment
*/
1
);`,
});
| {
"end_byte": 489,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction32.ts"
} |
TypeScript/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts_0_163 | /// <reference path="fourslash.ts" />
////function alpha() {
////
////function beta() { /*1*/alpha()/*2*/; }
////
verify.not.errorExistsBetweenMarkers("1", "2"); | {
"end_byte": 163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/jsdocLink_findAllReferences1.ts_0_169 | /// <reference path='fourslash.ts'/>
//// interface A/**/ {}
//// /**
//// * {@link A()} is ok
//// */
//// declare const a: A
verify.baselineFindAllReferences("");
| {
"end_byte": 169,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocLink_findAllReferences1.ts"
} |
TypeScript/tests/cases/fourslash/protoPropertyInObjectLiteral.ts_0_551 | /// <reference path='fourslash.ts' />
////var o1 = {
//// "__proto__": 10
////};
////var o2 = {
//// __proto__: 10
////};
////o1./*1*/
////o2./*2*/
verify.completions({ marker: "1", exact: { name: "__proto__", text: '(property) "__proto__": number' } });
edit.insert("__proto__ = 10;");
verify.quickInfoAt("1", '(property) "__proto__": number');
verify.completions({ marker: "2", exact: { name: "__proto__", text: "(property) __proto__: number" } });
edit.insert("__proto__ = 10;");
verify.quickInfoAt("2", "(property) __proto__: number");
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/protoPropertyInObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoLink8.ts_0_168 | /// <reference path="fourslash.ts" />
////const A = 123;
/////**
//// * See {@link A | constant A} instead
//// */
////const /**/B = 456;
verify.baselineQuickInfo();
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLink8.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringForOfArrayBindingPattern.ts_0_2965 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////type Robot = [number, string, string];
////type MultiSkilledRobot = [string, [string, string]];
////let robotA: Robot = [1, "mower", "mowing"];
////let robotB: Robot = [2, "trimmer", "trimming"];
////let robots = [robotA, robotB];
////function getRobots() {
//// return robots;
////}
////let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]];
////let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]];
////let multiRobots = [multiRobotA, multiRobotB];
////function getMultiRobots() {
//// return multiRobots;
////}
////for (let [, nameA] of robots) {
//// console.log(nameA);
////}
////for (let [, nameA] of getRobots()) {
//// console.log(nameA);
////}
////for (let [, nameA] of [robotA, robotB]) {
//// console.log(nameA);
////}
////for (let [, [primarySkillA, secondarySkillA]] of multiRobots) {
//// console.log(primarySkillA);
////}
////for (let [, [primarySkillA, secondarySkillA]] of getMultiRobots()) {
//// console.log(primarySkillA);
////}
////for (let [, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) {
//// console.log(primarySkillA);
////}
////for (let [numberB] of robots) {
//// console.log(numberB);
////}
////for (let [numberB] of getRobots()) {
//// console.log(numberB);
////}
////for (let [numberB] of [robotA, robotB]) {
//// console.log(numberB);
////}
////for (let [nameB] of multiRobots) {
//// console.log(nameB);
////}
////for (let [nameB] of getMultiRobots()) {
//// console.log(nameB);
////}
////for (let [nameB] of [multiRobotA, multiRobotB]) {
//// console.log(nameB);
////}
////for (let [numberA2, nameA2, skillA2] of robots) {
//// console.log(nameA2);
////}
////for (let [numberA2, nameA2, skillA2] of getRobots()) {
//// console.log(nameA2);
////}
////for (let [numberA2, nameA2, skillA2] of [robotA, robotB]) {
//// console.log(nameA2);
////}
////for (let [nameMA, [primarySkillA, secondarySkillA]] of multiRobots) {
//// console.log(nameMA);
////}
////for (let [nameMA, [primarySkillA, secondarySkillA]] of getMultiRobots()) {
//// console.log(nameMA);
////}
////for (let [nameMA, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) {
//// console.log(nameMA);
////}
////for (let [numberA3, ...robotAInfo] of robots) {
//// console.log(numberA3);
////}
////for (let [numberA3, ...robotAInfo] of getRobots()) {
//// console.log(numberA3);
////}
////for (let [numberA3, ...robotAInfo] of [robotA, robotB]) {
//// console.log(numberA3);
////}
////for (let [...multiRobotAInfo] of multiRobots) {
//// console.log(multiRobotAInfo);
////}
////for (let [...multiRobotAInfo] of getMultiRobots()) {
//// console.log(multiRobotAInfo);
////}
////for (let [...multiRobotAInfo] of [multiRobotA, multiRobotB]) {
//// console.log(multiRobotAInfo);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 2965,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringForOfArrayBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputSourceMap.ts_0_298 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputSourceMap.baseline
// @sourceMap: true
// @Filename: inputFile.ts
// @emitThisFile: true
//// var x = 109;
//// var foo = "hello world";
//// class M {
//// x: number;
//// y: string;
//// }
verify.baselineGetEmitOutput(); | {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputSourceMap.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnParameterProperties.ts_0_632 | /// <reference path='fourslash.ts' />
////interface IFoo {
//// /** this is the name of blabla
//// * - use blabla
//// * @example blabla
//// */
//// name?: string;
////}
////
////// test1 should work
////class Foo implements IFoo {
//// //public name: string = '';
//// constructor(
//// public na/*1*/me: string, // documentation should leech and work !
//// ) {
//// }
////}
////
////// test2 work
////class Foo2 implements IFoo {
//// public na/*2*/me: string = ''; // documentation leeched and work !
//// constructor(
//// //public name: string,
//// ) {
//// }
////}
verify.baselineQuickInfo()
| {
"end_byte": 632,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnParameterProperties.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableTemplateString2.ts_0_606 | /// <reference path="fourslash.ts" />
////const /*a*/codeText/*b*/ = "Code-formatted text looks `like this` and requires surrounding by backticks (\\`).";
////export const mdTutorial = `Let's talk about markdown.\n${codeText}?`;
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: "export const mdTutorial = `Let's talk about markdown.\\nCode-formatted text looks \\`like this\\` and requires surrounding by backticks (\\\\\\\`).?`;"
}); | {
"end_byte": 606,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString2.ts"
} |
TypeScript/tests/cases/fourslash/pasteLambdaOverModule.ts_0_238 | /// <reference path="fourslash.ts" />
//// /**/
goTo.marker();
var code = 'module B { }';
edit.paste(code);
goTo.bof();
edit.deleteAtCaret(code.length);
edit.insert('var t = (public x) => { };');
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 238,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pasteLambdaOverModule.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc_all.ts_0_376 | /// <reference path='fourslash.ts' />
// @Filename: test123.ts
/////** @type {number} */
////var [|x|];
/////** @type {string} */
////var [|y|];
verify.codeFixAll({
fixId: "annotateWithTypeFromJSDoc",
fixAllDescription: "Annotate everything with types from JSDoc",
newFileContent:
`/** @type {number} */
var x: number;
/** @type {string} */
var y: string;`,
});
| {
"end_byte": 376,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc_all.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOneExpr.ts_0_415 | /// <reference path='fourslash.ts' />
//// const age = 42
//// const foo = "/*x*/f/*y*/oobar is " + age + " 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 age = 42
const foo = \`foobar is \${age} years old\``,
});
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOneExpr.ts"
} |
TypeScript/tests/cases/fourslash/tsxQuickInfo1.ts_3_275 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// var x1 = <di/*1*/v></di/*2*/v>
//// class MyElement {}
//// var z = <My/*3*/Element></My/*4*/Element>
verify.quickInfos({
1: "any",
2: "any",
3: "class MyElement",
4: "class MyElement"
});
| {
"end_byte": 275,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxQuickInfo1.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod4.ts_0_1284 | /// <reference path="fourslash.ts" />
// @newline: LF
// @Filename: secret.ts
// Case: accessibility modifier inheritance
////class Secret {
//// #secret(): string {
//// return "secret";
//// }
////
//// private tell(): string {
//// return this.#secret();
//// }
////
//// protected hint(): string {
//// return "hint";
//// }
////
//// public refuse(): string {
//// return "no comments";
//// }
////}
////
////class Gossip extends Secret {
//// /* no telling secrets */
//// /*a*/
////}
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
excludes: [
"tell",
"#secret",
],
includes: [
{
name: "hint",
sortText: completion.SortText.LocationPriority,
insertText: "protected hint(): string {\n}",
filterText: "hint",
},
{
name: "refuse",
sortText: completion.SortText.LocationPriority,
insertText: "public refuse(): string {\n}",
filterText: "refuse",
}
],
}); | {
"end_byte": 1284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod4.ts"
} |
TypeScript/tests/cases/fourslash/genericRespecialization1.ts_0_2636 | /// <reference path='fourslash.ts' />
//// class Food {
//// private amount: number;
//// constructor(public name: string) {
//// this.amount = 100;
//// }
//// public eat(amountToEat: number): boolean {
//// this.amount -= amountToEat;
//// if (this.amount <= 0) {
//// this.amount = 0;
//// return false;
//// }
//// else {
//// return true;
//// }
//// }
//// }
//// class IceCream extends Food {
//// private isDairyFree: boolean;
//// constructor(public flavor: string) {
//// super("Ice Cream");
//// }
//// }
//// class Cookie extends Food {
//// constructor(public flavor: string, public isGlutenFree: boolean) {
//// super("Cookie");
//// }
//// }
//// class Slug {
//// // This is NOT a food!!!
//// }
//// class GenericMonster<T extends Food, V> {
//// private name: string;
//// private age: number;
//// private isFriendly: boolean;
//// constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) {
//// this.name = name;
//// this.age = age;
//// this.isFriendly = isFriendly;
//// }
//// public getFood(): T {
//// return this.food;
//// }
//// public getVariant(): V {
//// return this.variant;
//// }
//// public eatFood(amountToEat: number): boolean {
//// return this.food.eat(amountToEat);
//// }
//// public sayGreeting(): string {
//// return ("My name is " + this.name + ", and my age is " + this.age + ". I enjoy eating " + this.food.name + " and my variant is " + this.variant);
//// }
//// }
//// class GenericPlanet<T extends GenericMonster</*2*/Cookie, any>> {
//// constructor(public name: string, public solarSystem: string, public species: T) { }
//// }
//// var cookie = new Cookie("Chocolate Chip", false);
//// var cookieMonster = new GenericMonster<Cookie, string>("Cookie Monster", 50, true, cookie, "hello");
//// var sesameStreet = new GenericPlanet<GenericMonster<Cookie, string>>("Sesame Street", "Alpha Centuri", cookieMonster);
//// class GenericPlanet2<T extends Food, V>{
//// constructor(public name: string, public solarSystem: string, public species: GenericMonster<T, V>) { }
//// }
//// /*1*/
verify.noErrors();
goTo.marker('1');
edit.insertLine('');
edit.insertLine('');
verify.noErrors();
goTo.marker('2');
edit.deleteAtCaret("Cookie".length);
edit.insert("any");
verify.noErrors();
edit.insertLine('var narnia = new GenericPlanet2<Cookie, string>('); // shouldn't crash at this point | {
"end_byte": 2636,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericRespecialization1.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.