_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import6.ts_0_424 | /// <reference path='fourslash.ts' />
// @esModuleInterop: true
// @module: amd
// @Filename: foo.d.ts
////declare function foo(): void;
////declare namespace foo {}
////export = foo;
// @Filename: index.ts
////[|import * as foo from "./foo";|]
////foo();
goTo.file(1);
verify.codeFix({
description: `Replace import with 'import foo from "./foo";'.`,
newRangeContent: `import foo from "./foo";`,
index: 0,
});
| {
"end_byte": 424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import6.ts"
} |
TypeScript/tests/cases/fourslash/formattingConditionalOperator.ts_0_140 | /// <reference path='fourslash.ts'/>
////var x=true?1:2
format.document();
goTo.bof();
verify.currentLineContentIs("var x = true ? 1 : 2"); | {
"end_byte": 140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingConditionalOperator.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_delete_templateTag.ts_0_1026 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /first.js
/////**
//// * Doc
//// * @template T,U Comment
//// * @param {U} p
//// */
////function first(p) { return p; }
goTo.file("/first.js");
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'T'",
newFileContent:
`/**
* Doc
* @template U Comment
* @param {U} p
*/
function first(p) { return p; }`,
});
// @Filename: /second.js
/////**
//// * Doc
//// * @template T,U Comment
//// * @param {T} p
//// */
////function second(p) { return p; }
goTo.file("/second.js");
verify.codeFix({
description: "Remove unused declaration for: 'U'",
index: 0,
newFileContent:
`/**
* Doc
* @template T Comment
* @param {T} p
*/
function second(p) { return p; }`,
});
// @Filename: /both.js
/////**
//// * @template T,U Comment
//// */
////function both() {}
goTo.file("/both.js");
verify.codeFix({
description: "Remove template tag",
index: 0,
newFileContent:
`/**
* */
function both() {}`,
});
| {
"end_byte": 1026,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_delete_templateTag.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecommended_namespace.ts_0_1292 | /// <reference path="fourslash.ts" />
// @noLib: true
// @Filename: /a.ts
////export namespace Name {
//// export class C {}
////}
////export function f(c: Name.C) {}
////f(new N/*a0*/);
////f(new /*a1*/);
// @Filename: /b.ts
////import { f } from "./a";
// Here we will recommend a new import of 'Name'
////f(new N/*b0*/);
////f(new /*b1*/);
// @Filename: /c.ts
////import * as alpha from "./a";
// Here we will recommend 'a' because it contains 'Name' which contains 'C'.
////alpha.f(new a/*c0*/);
////alpha.f(new /*c1*/);
verify.completions(
{
marker: ["a0", "a1"],
includes: { name: "Name", text: "namespace Name", kind: "module", kindModifiers: "export", isRecommended: true },
},
{
marker: ["b0", "b1"],
includes: {
name: "Name",
source: "/a",
sourceDisplay: "./a",
text: "namespace Name",
kind: "module",
kindModifiers: "export",
hasAction: true,
isRecommended: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
},
{ marker: ["c0", "c1"], includes: { name: "alpha", text: "import alpha", kind: "alias", isRecommended: true } },
);
| {
"end_byte": 1292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_namespace.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingParam3.ts_0_313 | /// <reference path="fourslash.ts" />
////class C {
//// private a = 1;
////
//// [|m1() {}|]
//// m2() {
//// this.m1(this.a);
//// }
////}
verify.codeFix({
description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "m1"],
index: 0,
newRangeContent: "m1(a: number) {}"
});
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam3.ts"
} |
TypeScript/tests/cases/fourslash/extract-method26.ts_0_592 | /// <reference path='fourslash.ts' />
// Handle having zero modifiers on a method.
// @allowNonTsExtensions: true
// @Filename: file1.js
//// class C {
//// M() {
//// const q = /*a*/1 + 2/*b*/;
//// q.toString();
//// }
//// }
goTo.select('a', 'b')
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to method in class 'C'",
newContent:
`class C {
M() {
const q = this./*RENAME*/newMethod();
q.toString();
}
newMethod() {
return 1 + 2;
}
}`
});
| {
"end_byte": 592,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method26.ts"
} |
TypeScript/tests/cases/fourslash/getDeclarationDiagnostics.ts_0_452 | /// <reference path="fourslash.ts" />
// @declaration: true
// @outFile: true
// @Filename: inputFile1.ts
//// module m {
//// export function foo() {
//// class C implements I { private a; }
//// interface I { }
//// return C;
//// }
//// } /*1*/
// @Filename: input2.ts
//// var x = "hello world"; /*2*/
goTo.marker("1");
verify.numberOfErrorsInCurrentFile(1);
goTo.marker("2");
verify.numberOfErrorsInCurrentFile(0);
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getDeclarationDiagnostics.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts_0_436 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: file.tsx
//// import React = require('react');
//// [|<div/>;|]
//// <div/>;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`import React = require('react');
<div/>;`,
"/tests/cases/fourslash/newFile.tsx":
`import React = require('react');
<div />;
`,
}
});
| {
"end_byte": 436,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_MultiDecl.ts_0_1505 | /// <reference path='fourslash.ts' />
//// /*z*/l/*y*/et /*x*/f/*w*/oo, /*v*/b/*u*/ar = /*t*/(/*s*/) => 42;
goTo.select("z", "y");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("x", "w");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("v", "u");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("t", "s");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
| {
"end_byte": 1505,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_MultiDecl.ts"
} |
TypeScript/tests/cases/fourslash/preparePasteEdits_resolvedTypeParameters.ts_0_454 | /// <reference path='./fourslash.ts' />
// @Filename: /file2.ts
//// import { T } from './file1';
////
//// [|function MyFunction(param: T): T {
//// type U = { value: T }
//// const localVariable: U = { value: param };
//// return localVariable.value;
//// }|]
// @Filename: /file1.ts
//// export type T = string;
verify.preparePasteEdits({
copiedFromFile: "/file2.ts",
copiedTextRange: test.ranges(),
providePasteEdits: true
})
| {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/preparePasteEdits_resolvedTypeParameters.ts"
} |
TypeScript/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts_0_2128 | /// <reference path='fourslash.ts' />
////var o1 : {
//// __proto__: number;
//// p: number;
////} = {
//// /*1*/
//// };
////var o2: {
//// __proto__: number;
//// p: number;
////} = {
//// /*2*/
//// };
////var o3: {
//// "__proto__": number;
//// p: number;
////} = {
//// /*3*/
//// };
////var o4: {
//// "__proto__": number;
//// p: number;
////} = {
//// /*4*/
//// };
////var o5: {
//// __proto__: number;
//// ___proto__: string;
//// p: number;
////} = {
//// /*5*/
//// };
////var o6: {
//// __proto__: number;
//// ___proto__: string;
//// p: number;
////} = {
//// /*6*/
//// };
const tripleProto: FourSlashInterface.ExpectedCompletionEntry = { name: "___proto__", text: "(property) ___proto__: string" };
const proto: FourSlashInterface.ExpectedCompletionEntry = { name: "__proto__", text: "(property) __proto__: number" };
const protoQuoted: FourSlashInterface.ExpectedCompletionEntry = { name: "__proto__", text: '(property) "__proto__": number' };
const p: FourSlashInterface.ExpectedCompletionEntry = { name: "p", text: "(property) p: number" };
verify.completions({ marker: "1", unsorted: [proto, p] });
edit.insert('__proto__: 10,');
verify.completions({ exact: p });
verify.completions({ marker: "2", unsorted: [proto, p] });
edit.insert('"__proto__": 10,');
verify.completions({ exact: p });
verify.completions({ marker: "3", unsorted: [protoQuoted, p] })
edit.insert('__proto__: 10,');
verify.completions({ exact: p });
verify.completions({ marker: "4", unsorted: [protoQuoted, p] });
edit.insert('"__proto__": 10,');
verify.completions({ exact: p });
verify.completions({ marker: "5", unsorted: [proto, tripleProto, p] });
edit.insert('__proto__: 10,');
verify.completions({ unsorted: [tripleProto, p] });
edit.insert('"___proto__": "10",');
verify.completions({ exact: p });
verify.completions({ marker: "6", unsorted: [proto, tripleProto, p] });
edit.insert('___proto__: "10",');
verify.completions({ unsorted: [proto, p] });
edit.insert('"__proto__": 10,');
verify.completions({ exact: p });
| {
"end_byte": 2128,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarFunctionLikePropertyAssignments.ts_0_1915 | /// <reference path="fourslash.ts"/>
////var functions = {
//// a: 0,
//// b: function () { },
//// c: function x() { },
//// d: () => { },
//// e: y(),
//// f() { }
////};
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "functions",
kind: "var",
childItems: [
{
text: "a",
kind: "property"
},
{
text: "b",
kind: "method"
},
{
text: "c",
kind: "method"
},
{
text: "d",
kind: "method"
},
{
text: "e",
kind: "property"
},
{
text: "f",
kind: "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "functions",
"kind": "var"
}
]
},
{
"text": "functions",
"kind": "var",
"childItems": [
{
"text": "a",
"kind": "property"
},
{
"text": "b",
"kind": "method"
},
{
"text": "c",
"kind": "method"
},
{
"text": "d",
"kind": "method"
},
{
"text": "e",
"kind": "property"
},
{
"text": "f",
"kind": "method"
}
],
"indent": 1
}
]); | {
"end_byte": 1915,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarFunctionLikePropertyAssignments.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoLink6.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/quickInfoLink6.ts"
} |
TypeScript/tests/cases/fourslash/formatExportAssignment.ts_0_124 | /// <reference path="fourslash.ts"/>
////export='foo';
format.document();
verify.currentFileContentIs(`export = 'foo';`);
| {
"end_byte": 124,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatExportAssignment.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember7.ts_0_343 | /// <reference path='fourslash.ts' />
// @checkJs: true
// @allowJs: true
// @Filename: a.js
////class C {
//// static p = ()=>{ this.foo === 10 };
////}
verify.codeFix({
description: "Initialize static property 'foo'",
index: 0,
newFileContent: `class C {
static p = ()=>{ this.foo === 10 };
}
C.foo = undefined;
`
});
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember7.ts"
} |
TypeScript/tests/cases/fourslash/typeToStringCrashInCodeFix.ts_0_214 | /// <reference path="fourslash.ts" />
// @noImplicitAny: true
//// function f([|y |], z = { p: y[
verify.rangeAfterCodeFix("y: { [x: string]: any; }",/*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeToStringCrashInCodeFix.ts"
} |
TypeScript/tests/cases/fourslash/genericCombinators1.ts_0_2607 | /// <reference path='fourslash.ts'/>
////interface Collection<T> {
//// length: number;
//// add(x: T): void;
//// remove(x: T): boolean;
////}
////interface Combinators {
//// map<T, U>(c: Collection<T>, f: (x: T) => U): Collection<U>;
//// map<T>(c: Collection<T>, f: (x: T) => any): Collection<any>;
////}
////class A {
//// foo<T>() { return this; }
////}
////class B<T> {
//// foo(x: T): T { return null; }
////}
////var c2: Collection<number>;
////var c3: Collection<Collection<number>>;
////var c4: Collection<A>;
////var c5: Collection<B<any>>;
////var _: Combinators;
////var rf1 = (x: number) => { return x.toFixed() };
////var rf2 = (x: Collection<number>) => { return x.length };
////var rf3 = (x: A) => { return x.foo() };
////var /*9*/r1a = _.map(c2, (/*1*/x) => { return x.toFixed() });
////var /*10*/r1b = _.map(c2, rf1);
////var /*11*/r2a = _.map(c3, (/*2*/x: Collection<number>) => { return x.length });
////var /*12*/r2b = _.map(c3, rf2);
////var /*13*/r3a = _.map(c4, (/*3*/x) => { return x.foo() });
////var /*14*/r3b = _.map(c4, rf3);
////var /*15*/r4a = _.map(c5, (/*4*/x) => { return x.foo(1) });
////var /*17*/r5a = _.map<number, string>(c2, (/*5*/x) => { return x.toFixed() });
////var /*18*/r5b = _.map<number, string>(c2, rf1);
////var /*19*/r6a = _.map<Collection<number>, number>(/*6*/c3, (x: Collection<number>) => { return x.length });
////var /*20*/r6b = _.map<Collection<number>, number>(c3, rf2);
////var /*21*/r7a = _.map<A, A>(c4, (/*7*/x: A) => { return x.foo() });
////var /*22*/r7b = _.map<A, A>(c4, rf3);
////var /*23*/r8a = _.map</*error1*/B/*error2*/, string>(c5, (/*8*/x) => { return x.foo() });
verify.quickInfos({
1: "(parameter) x: number",
2: "(parameter) x: Collection<number>",
3: "(parameter) x: A",
4: "(parameter) x: B<any>",
5: "(parameter) x: number",
6: "var c3: Collection<Collection<number>>",
7: "(parameter) x: A",
8: "(parameter) x: any", // Specialized to any because no type argument was specified
9: "var r1a: Collection<string>",
10: "var r1b: Collection<string>",
11: "var r2a: Collection<number>",
12: "var r2b: Collection<number>",
13: "var r3a: Collection<A>",
14: "var r3b: Collection<A>",
15: "var r4a: Collection<any>",
17: "var r5a: Collection<string>",
18: "var r5b: Collection<string>",
19: "var r6a: Collection<number>",
20: "var r6b: Collection<number>",
21: "var r7a: Collection<A>",
22: "var r7b: Collection<A>",
23: "var r8a: Collection<string>"
});
verify.errorExistsBetweenMarkers('error1', 'error2'); | {
"end_byte": 2607,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCombinators1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsImportNamed.ts_0_266 | /// <reference path='fourslash.ts' />
// @Filename: f.ts
////export { foo as foo }
////function /*start*/foo(a: number, b: number) { }
// @Filename: b.ts
////import x = require("./f");
////x.foo(1, 2);
verify.noErrors();
verify.baselineFindAllReferences('start')
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsImportNamed.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarFunctionPrototypeBroken.ts_0_3319 | /// <reference path="fourslash.ts"/>
// @Filename: foo.js
////function A() {}
////A. // Started typing something here
////A.prototype.a = function() { };
////G. // Started typing something here
////A.prototype.a = function() { };
verify.navigationTree({
"text": "<global>",
"kind": "script",
"spans": [
{
"start": 0,
"length": 151
}
],
"childItems": [
{
"text": "G",
"kind": "method",
"spans": [
{
"start": 84,
"length": 66
}
],
"nameSpan": {
"start": 84,
"length": 1
},
"childItems": [
{
"text": "A",
"kind": "method",
"spans": [
{
"start": 84,
"length": 66
}
],
"nameSpan": {
"start": 120,
"length": 1
},
"childItems": [
{
"text": "a",
"kind": "function",
"spans": [
{
"start": 136,
"length": 14
}
],
"nameSpan": {
"start": 132,
"length": 1
}
}
]
}
]
},
{
"text": "A",
"kind": "class",
"spans": [
{
"start": 0,
"length": 82
}
],
"nameSpan": {
"start": 9,
"length": 1
},
"childItems": [
{
"text": "constructor",
"kind": "constructor",
"spans": [
{
"start": 0,
"length": 15
}
]
},
{
"text": "A",
"kind": "method",
"spans": [
{
"start": 16,
"length": 66
}
],
"nameSpan": {
"start": 52,
"length": 1
},
"childItems": [
{
"text": "a",
"kind": "function",
"spans": [
{
"start": 68,
"length": 14
}
],
"nameSpan": {
"start": 64,
"length": 1
}
}
]
}
]
}
]
}, { checkSpans: true });
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "G",
"kind": "method"
},
{
"text": "A",
"kind": "class"
}
]
},
{
"text": "G",
"kind": "method",
"childItems": [
{
"text": "A",
"kind": "method"
}
],
"indent": 1
},
{
"text": "A",
"kind": "method",
"childItems": [
{
"text": "a",
"kind": "function"
}
],
"indent": 2
},
{
"text": "A",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "A",
"kind": "method"
}
],
"indent": 1
},
{
"text": "A",
"kind": "method",
"childItems": [
{
"text": "a",
"kind": "function"
}
],
"indent": 2
},
]);
| {
"end_byte": 3319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarFunctionPrototypeBroken.ts"
} |
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations7.ts_0_339 | /// <reference path='fourslash.ts'/>
////interface Foo { }
////module Foo {
//// export interface /*1*/Bar { }
//// export module /*2*/Bar { export interface Baz { } }
//// export function /*3*/Bar() { }
////}
////
////// module, value and type
////import a2 = Foo./*4*/Bar;
verify.baselineFindAllReferences('1', '2', '3', '4')
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations7.ts"
} |
TypeScript/tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts_0_252 | /// <reference path='fourslash.ts' />
// Test that we don't crash when encountering a keyword in a JSX identifier.
// @Filename: /a.tsx
////<div module-layout=""></div>
format.document();
verify.currentFileContentIs(`<div module-layout=""></div>`);
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts"
} |
TypeScript/tests/cases/fourslash/incrementalResolveFunctionPropertyAssignment.ts_0_802 | /// <reference path="fourslash.ts" />
////function bar(indexer: { getLength(): number; getTypeAtIndex(index: number): string; }): string {
//// return indexer.getTypeAtIndex(indexer.getLength() - 1);
////}
////function foo(a: string[]) {
//// return bar({
//// getLength(): number {
//// return "a.length";
//// },
//// getTypeAtIndex(index: number) {
//// switch (index) {
//// case 0: return a[0];
//// case 1: return a[1];
//// case 2: return a[2];
//// default: return "invalid";
//// }
//// }
//// });
////}
////var val = foo(["myString1", "myString2"]);
/////*1*/val;
verify.quickInfoAt("1", "var val: string");
// TypeCheck
verify.numberOfErrorsInCurrentFile(1); | {
"end_byte": 802,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalResolveFunctionPropertyAssignment.ts"
} |
TypeScript/tests/cases/fourslash/completionListBuilderLocations_parameters.ts_0_434 | /// <reference path='fourslash.ts' />
////var aa = 1;
////class bar1{ constructor(/*1*/
////class bar2{ constructor(a/*2*/
////class bar3{ constructor(a, /*3*/
////class bar4{ constructor(a, b/*4*/
////class bar6{ constructor(public a, /*5*/
////class bar7{ constructor(private a, /*6*/
verify.completions({
marker: test.markers(),
exact: completion.constructorParameterKeywords,
isNewIdentifierLocation: true
});
| {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListBuilderLocations_parameters.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_callWithThisInside.ts_0_242 | /// <reference path='fourslash.ts' />
////class Base{
//// constructor(id: number) { id; }
////}
////class C extends Base{
//// constructor(private a:number) {
//// super(this.a);
//// }
////}
verify.not.codeFixAvailable();
| {
"end_byte": 242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_callWithThisInside.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport10.ts_0_311 | /// <reference path="fourslash.ts" />
//// import [|{
//// v1,
//// v2
//// }|] 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,
v1,
v2
}`
]);
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport10.ts"
} |
TypeScript/tests/cases/fourslash/completionListInComments3.ts_0_342 | /// <reference path='fourslash.ts' />
//// /*{| "name": "1" |}
//// /* {| "name": "2" |}
//// /* *{| "name": "3" |}
//// /* */{| "name": "4" |}
//// {| "name": "5" |}/* */
/////* {| "name": "6" |}
verify.completions(
{ marker: ["1", "2", "3", "6"], exact: undefined },
{ marker: ["4", "5"], exact: completion.globals },
);
| {
"end_byte": 342,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInComments3.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationClassMethod_00.ts_0_328 | /// <reference path='fourslash.ts'/>
// Should handle calls made on members declared in a class
//// class Bar {
//// [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello|]() {}
//// }
////
//// new Bar().hel/*reference*/lo;
verify.baselineGoToImplementation("reference"); | {
"end_byte": 328,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationClassMethod_00.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionInTypeArgument.ts_0_255 | /// <reference path='fourslash.ts' />
////class /*fooDefinition*/Foo<T> { }
////
////class /*barDefinition*/Bar { }
////
////var x = new Fo/*fooReference*/o<Ba/*barReference*/r>();
verify.baselineGetDefinitionAtPosition("barReference", "fooReference");
| {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionInTypeArgument.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationThis_00.ts_0_322 | /// <reference path='fourslash.ts'/>
// Should go to class declaration when invoked on this keyword in property access expression
//// class [|Bar|] extends Foo {
//// hello() {
//// thi/*this_call*/s.whatever();
//// }
////
//// whatever() {}
//// }
verify.baselineGoToImplementation("this_call");
| {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationThis_00.ts"
} |
TypeScript/tests/cases/fourslash/tsxRename9.ts_0_1702 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// [|[|{| "contextRangeIndex": 0 |}onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;|]
//// }
//// interface LinkProps extends ClickableProps {
//// [|[|{| "contextRangeIndex": 2 |}goTo|]: string;|]
//// }
//// [|declare function [|{| "contextRangeIndex": 4 |}MainButton|](buttonProps: ButtonProps): JSX.Element;|]
//// [|declare function [|{| "contextRangeIndex": 6 |}MainButton|](linkProps: LinkProps): JSX.Element;|]
//// [|declare function [|{| "contextRangeIndex": 8 |}MainButton|](props: ButtonProps | LinkProps): JSX.Element;|]
//// let opt = [|<[|{| "contextRangeIndex": 10 |}MainButton|] />|];
//// let opt = [|<[|{| "contextRangeIndex": 12 |}MainButton|] children="chidlren" />|];
//// let opt = [|<[|{| "contextRangeIndex": 14 |}MainButton|] [|[|{| "contextRangeIndex": 16 |}onClick|]={()=>{}}|] />|];
//// let opt = [|<[|{| "contextRangeIndex": 18 |}MainButton|] [|[|{| "contextRangeIndex": 20 |}onClick|]={()=>{}}|] [|ignore-prop|] />|];
//// let opt = [|<[|{| "contextRangeIndex": 23 |}MainButton|] [|[|{| "contextRangeIndex": 25 |}goTo|]="goTo"|] />|];
//// let opt = [|<[|{| "contextRangeIndex": 27 |}MainButton|] [|wrong|] />|];
verify.baselineRenameAtRangesWithText([
"onClick",
"goTo",
"MainButton",
"ignore-prop",
"wrong"
]); | {
"end_byte": 1702,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_module_compatibleCompilerOptionsInTsConfig.ts_0_335 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: number[];
////for await (const _ of p);
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "target": "es2017",
//// "module": "esnext"
//// }
////}
verify.not.codeFixAvailable("fixModuleOption");
| {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_module_compatibleCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_noUndefinedOnOptionalParameter.ts_0_503 | /// <reference path="fourslash.ts" />
////interface IFoo {
//// bar(x?: number | string): void;
////}
////
////class Foo implements IFoo {
////}
//https://github.com/microsoft/TypeScript/issues/39458
verify.codeFix({
description: [ts.Diagnostics.Implement_interface_0.message, "IFoo"],
newFileContent:
`interface IFoo {
bar(x?: number | string): void;
}
class Foo implements IFoo {
bar(x?: number | string): void {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 503,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_noUndefinedOnOptionalParameter.ts"
} |
TypeScript/tests/cases/fourslash/renameStringLiteralTypes4.ts_0_208 | /// <reference path="fourslash.ts" />
////interface I {
//// "Prop 1": string;
////}
////
////declare const fn: <K extends keyof I>(p: K) => void
////
////fn("Prop 1"/**/)
verify.baselineRename("", {});
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralTypes4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember10.ts_0_451 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
/////**
//// * foo
//// */
////function foo() {}
////export const bar = 1;
// @filename: /b.ts
////import { foo } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "foo", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`/**
* foo
*/
export function foo() {}
export const bar = 1;`,
}
});
| {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember10.ts"
} |
TypeScript/tests/cases/fourslash/completionsJSDocNoCrash3.ts_0_526 | /// <reference path='fourslash.ts' />
// @strict: true
// @filename: index.ts
//// class MssqlClient {
//// /**
//// *
//// * @param {Object} - args
//// * @param {String} - args.parentTable
//// * @returns {Promise<{upStatement/**/, downStatement}>}
//// */
//// async relationCreate(args) {}
//// }
////
//// export default MssqlClient;
verify.completions({
marker: "",
exact: [{
name: "readonly",
sortText: completion.SortText.GlobalsOrKeywords,
}],
isNewIdentifierLocation: true,
});
| {
"end_byte": 526,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocNoCrash3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts_0_204 | /// <reference path='fourslash.ts'/>
// @Filename: b.ts
////export * from [|'e/*1*/'|];
// @Filename: a.ts
////declare module /*2*/"e" {
//// class Foo { }
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_umdModules2_moduleExports.ts_0_874 | /// <reference path="./fourslash.ts" />
// @filename: /package.json
//// { "dependencies": { "@types/classnames": "*" } }
// @filename: /tsconfig.json
//// {}
// @filename: /node_modules/@types/classnames/package.json
//// { "name": "@types/classnames", "types": "index.d.ts" }
// @filename: /node_modules/@types/classnames/index.d.ts
//// declare const classNames: () => string;
//// export = classNames;
//// export as namespace classNames;
// @filename: /SomeReactComponent.tsx
//// import * as React from 'react';
////
//// const el1 = <div className={class/*1*/}>foo</div>;
goTo.marker("1");
verify.completions({
includes: [{
name: "classNames",
hasAction: true,
source: "/node_modules/@types/classnames/index",
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
}
});
| {
"end_byte": 874,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_umdModules2_moduleExports.ts"
} |
TypeScript/tests/cases/fourslash/completionListForExportEquals2.ts_1_372 | ///<reference path="fourslash.ts"/>
// @Filename: /node_modules/foo/index.d.ts
////export = Foo;
////interface Foo { bar: number; }
////declare namespace Foo {
//// interface Static {}
////}
// @Filename: /a.ts
////import { /**/ } from "foo";
verify.completions({ marker: "", exact: ["Static", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] });
| {
"end_byte": 372,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForExportEquals2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixEnableJsxFlag_disabledInCompilerOptionsInTsConfig.ts_0_455 | /// <reference path='fourslash.ts' />
// @Filename: /dir/a.tsx
////export const Component = () => <></>
// @Filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "jsx": false,
//// }
////}
goTo.file("/dir/a.tsx");
verify.codeFix({
description: "Enable the '--jsx' flag in your configuration file",
newFileContent: {
"/dir/tsconfig.json":
`{
"compilerOptions": {
"jsx": "react",
}
}`,
},
});
| {
"end_byte": 455,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixEnableJsxFlag_disabledInCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/completionsIndexSignatureConstraint1.ts_0_539 | /// <reference path="fourslash.ts" />
// @strict: true
////
//// repro #9900
////
//// interface Test {
//// a?: number;
//// b?: string;
//// }
////
//// interface TestIndex {
//// [key: string]: Test;
//// }
////
//// declare function testFunc<T extends TestIndex>(t: T): void;
////
//// testFunc({
//// test: {
//// /**/
//// },
//// });
verify.completions({
marker: '',
exact: [
{ name: 'a', sortText: completion.SortText.OptionalMember },
{ name: 'b', sortText: completion.SortText.OptionalMember },
]
}); | {
"end_byte": 539,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsIndexSignatureConstraint1.ts"
} |
TypeScript/tests/cases/fourslash/forceIndentAfterNewLineInsert.ts_0_348 | ///<reference path="fourslash.ts"/>
////function f1()
////{ return 0; }
////function f2()
////{
////return 0;
////}
////function g()
////{ function h() {
////return 0;
////}}
format.document();
verify.currentFileContentIs(
`function f1() { return 0; }
function f2() {
return 0;
}
function g() {
function h() {
return 0;
}
}`);
| {
"end_byte": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/forceIndentAfterNewLineInsert.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts_0_598 | /// <reference path='fourslash.ts' />
/////*2*/do {
/////*3*/ for (var i = 0; i < 10; i++)
/////*4*/ i -= 2
/////*5*/ }/*1*/while (1 !== 1)
goTo.marker("1");
edit.insert("\n");
verify.currentLineContentIs("while (1 !== 1)");
goTo.marker("2");
verify.currentLineContentIs("do {");
goTo.marker("3");
verify.currentLineContentIs(" for (var i = 0; i < 10; i++)");
goTo.marker("4");
verify.currentLineContentIs(" i -= 2");
goTo.marker("5");
//bug 718362 expected result : "}" , actual result : " }"
//verify.currentLineContentIs("}");
verify.currentLineContentIs("}"); | {
"end_byte": 598,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess2.ts_0_516 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/protected a: string;/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private /*RENAME*/_a: string;
protected get a(): string {
return this._a;
}
protected set a(value: string) {
this._a = value;
}
}`,
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess2.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag5.ts_0_548 | /// <reference path="fourslash.ts"/>
////class Foo {
//// /** @deprecated m */
//// static m() {}
////}
////Foo./**/
verify.completions({
marker: "",
exact: completion.functionMembersPlus([
{
name: "prototype",
sortText: completion.SortText.LocationPriority
},
{
name: "m",
kind: "method",
kindModifiers: "static,deprecated",
sortText: completion.SortText.Deprecated(completion.SortText.LocalDeclarationPriority),
},
])
});
| {
"end_byte": 548,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag5.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts_0_128 | /// <reference path="fourslash.ts" />
//// label1: for(var /**/i = 0; i < 1; i++) { }
goTo.marker();
verify.quickInfoExists(); | {
"end_byte": 128,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses13.ts_0_528 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////function foo() {
//// function test() { return Math.random() > 0.5; }
//// test/**/ && console.log('test');
////}
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');
}`,
});
| {
"end_byte": 528,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses13.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SparseAccess.ts_0_495 | /// <reference path='fourslash.ts' />
////let a = { b: { c: { d: { e: {f: 0} } } } };
/////*a*/a.b && a.b.c.d && a.b.c.d.e.f;/*b*/
// Only convert the accesses for which existence is checked.
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: { d: { e: {f: 0} } } } };
a.b?.c.d?.e.f;`
}); | {
"end_byte": 495,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SparseAccess.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics6.ts_0_136 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////interface I { }
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 136,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics6.ts"
} |
TypeScript/tests/cases/fourslash/arrayConcatTypeCheck1.ts_0_362 | /// <reference path="fourslash.ts" />
//// a.concat(/*2*/"hello"/*1*/, 'world');
////
//// a.concat(/*3*/'Hello');
////
//// var b = new Array/*4*/<>();
//// b.concat('hello');
////
edit.disableFormatting();
goTo.marker('1');
edit.deleteAtCaret(9);
goTo.marker('3');
edit.deleteAtCaret(7);
goTo.marker('2');
edit.deleteAtCaret(7);
goTo.marker('4');
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arrayConcatTypeCheck1.ts"
} |
TypeScript/tests/cases/fourslash/formatInTsxFiles.ts_0_133 | /// <reference path="fourslash.ts"/>
//@Filename: file.tsx
////interface I<T1, T2> {
//// next: I</* */
////}
format.document(); | {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatInTsxFiles.ts"
} |
TypeScript/tests/cases/fourslash/importJsNodeModule3.ts_0_1442 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: node_modules/myMod/index.js
//// exports.n = 3;
//// exports.s = 'foo';
//// exports.b = true;
// @Filename: node_modules/anotherMod/index.js
//// exports.x = 3;
//// exports.y = 'foo';
//// /**
//// * @param {(number | boolean)} a The first param
//// * @param {Array<string>} b The second param
//// */
//// exports.z = function(a,b){ return "test"; };
// @Filename: consumer.js
//// import * as x from 'myMod';
//// import {y,z} from 'anotherMod';
//// 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" } });
edit.backspace(4);
edit.insert('y.');
verify.completions({ includes: { name: "toUpperCase", kind: "method", kindModifiers: "declare" } });
edit.backspace(2);
edit.insert('z(');
verify.signatureHelp({
text: "z(a: (number | boolean), b: Array<string>): string",
parameterDocComment: "The first param",
tags: [
{ name: "param", text: [{ kind: "parameterName", text: "a" }, { kind: "space", text: " " }, { kind: "text", text: "The first param" }] },
{ name: "param", text: [{ kind: "parameterName", text: "b" }, { kind: "space", text: " " }, { kind: "text", text: "The second param" }] },
],
});
| {
"end_byte": 1442,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importJsNodeModule3.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesExport2.ts_0_1478 | /// <reference path='fourslash.ts' />
////module m {
//// export class C1 {
//// public pub1;
//// public pub2;
//// private priv1;
//// private priv2;
//// protected prot1;
//// protected prot2;
////
//// public public;
//// private private;
//// protected protected;
////
//// public constructor(public a, private b, protected c, public d, private e, protected f) {
//// this.public = 10;
//// this.private = 10;
//// this.protected = 10;
//// }
////
//// public get x() { return 10; }
//// public set x(value) { }
////
//// public static statPub;
//// private static statPriv;
//// protected static statProt;
//// }
////
//// export interface I1 {
//// }
////
//// export declare module ma.m1.m2.m3 {
//// interface I2 {
//// }
//// }
////
//// export module mb.m1.m2.m3 {
//// declare var foo;
////
//// [|export|] class C2 {
//// public pub1;
//// private priv1;
//// protected prot1;
////
//// protected constructor(public public, protected protected, private private) {
//// public = private = protected;
//// }
//// }
//// }
////
//// declare var ambientThing: number;
//// export var exportedThing = 10;
//// declare function foo(): string;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 1478,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesExport2.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_cleanUpLastNamedImport.ts_0_602 | /// <reference path='fourslash.ts' />
// @Filename: /has-exports.ts
////
//// export interface Exported { }
//// const defaultExport = ""
//// export default defaultExport
// @Filename: /31195.ts
////
////import defaultExport, { Exported } from "./has-exports"
////console.log(defaultExport)
////[|export const bar = (logger: Exported) => 0;|]
verify.moveToNewFile({
newFileContents: {
"/31195.ts": `
import defaultExport from "./has-exports"
console.log(defaultExport)
`,
"/bar.ts":
`import { Exported } from "./has-exports";
export const bar = (logger: Exported) => 0;
`,
}
});
| {
"end_byte": 602,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_cleanUpLastNamedImport.ts"
} |
TypeScript/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts_0_150 | /// <reference path="fourslash.ts" />
//// function fn(/* comment! */ /**/a: number, c) { }
goTo.marker();
edit.deleteAtCaret('a: number,'.length);
| {
"end_byte": 150,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport8.ts_0_280 | /// <reference path="fourslash.ts" />
//// import [|{v1, v2, v3,}|] from "./module";
//// v4/*0*/();
// @Filename: module.ts
//// export function v4() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([`{v1, v2, v3, v4,}`]);
| {
"end_byte": 280,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport8.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember15.ts_0_249 | /// <reference path="./fourslash.ts"/>
// @noImplicitOverride: true
////class A {
//// static /*2*/m() {}
////}
////class B extends A {}
////class C extends B {
//// static [|/*1*/override|] m() {}
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember15.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts_0_1169 | /// <reference path="fourslash.ts" />
////declare class C { foo(): void }
////declare function getC(): { Class: C };
////declare function foo(): string;
////async function f() {
//// await "";
//// await 0;
//// (await foo()).toLowerCase();
//// (await 0).toFixed();
//// (await new C).foo();
//// (await function() { }());
//// new (await getC()).Class();
////}
verify.codeFix({
description: ts.Diagnostics.Remove_unnecessary_await.message,
index: 0,
newFileContent:
`declare class C { foo(): void }
declare function getC(): { Class: C };
declare function foo(): string;
async function f() {
"";
await 0;
(await foo()).toLowerCase();
(await 0).toFixed();
(await new C).foo();
(await function() { }());
new (await getC()).Class();
}`
});
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Remove_all_unnecessary_uses_of_await.message,
fixId: "removeUnnecessaryAwait",
newFileContent:
`declare class C { foo(): void }
declare function getC(): { Class: C };
declare function foo(): string;
async function f() {
"";
0;
foo().toLowerCase();
(0).toFixed();
(new C).foo();
(function() { } ());
new (getC()).Class();
}`
});
| {
"end_byte": 1169,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinition_filteringGenericMappedType.ts_0_537 | ///<reference path="fourslash.ts"/>
//// const obj = {
//// get /*def*/id() {
//// return 1;
//// },
//// name: "test",
//// };
////
//// type Omit2<T, DroppedKeys extends PropertyKey> = {
//// [K in keyof T as Exclude<K, DroppedKeys>]: T[K];
//// };
////
//// declare function omit2<O, Mask extends { [K in keyof O]?: true }>(
//// obj: O,
//// mask: Mask
//// ): Omit2<O, keyof Mask>;
////
//// const obj2 = omit2(obj, {
//// name: true,
//// });
////
//// obj2.[|/*ref*/id|];
verify.baselineGoToDefinition("ref");
| {
"end_byte": 537,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinition_filteringGenericMappedType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties6.ts_0_457 | /// <reference path='fourslash.ts' />
////interface I {
//// x: number;
//// y: number;
////}
////class C {
//// public p: number;
//// m(x: number, y: I) {}
////}
////[|const foo: C = {}|];
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const foo: C = {
p: 0,
m: function(x: number, y: I): void {
throw new Error("Function not implemented.");
}
}`
});
| {
"end_byte": 457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceWithNegativeNumber.ts_2_239 | /// <reference path='fourslash.ts' />
//// interface X { value: -1 | 0 | 1; }
//// class Y implements X { }
// https://github.com/Microsoft/TypeScript/issues/30431
verify.codeFixAvailable([{ description: "Implement interface 'X'" }]);
| {
"end_byte": 239,
"start_byte": 2,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceWithNegativeNumber.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesThis4.ts_0_2935 | /// <reference path='fourslash.ts' />
////this;
////this;
////
////function f() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
////}
////
////module m {
//// 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;
//// })(this);
//// }
//// }
////
//// private method2() {
//// [|this|];
//// [|this|];
//// () => [|t/**/his|];
//// () => {
//// 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 = {
//// f() {
//// this;
//// },
//// g() {
//// this;
//// }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 2935,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThis4.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionSingleProperty.ts_0_218 | /// <reference path="fourslash.ts" />
//// console.log({
//// }, {
//// /*1*/ a: 1,
//// /*2*/ b: 2
//// })
format.selection("1", "2");
verify.currentFileContentIs(
`console.log({
}, {
a: 1,
b: 2
})`);
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionSingleProperty.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace3.ts_0_605 | /// <reference path='fourslash.ts' />
/////*a*/import { a, b } from "./foo"/*b*/;
////a;
////b;
////function newScope() {
//// const foo = "foo";
//// foo;
//// return a;
////}
////newScope();
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
triggerReason: "invoked",
newContent:
`import * as foo_1 from "./foo";
foo_1.a;
foo_1.b;
function newScope() {
const foo = "foo";
foo;
return foo_1.a;
}
newScope();`,
});
| {
"end_byte": 605,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToNamespace3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts_0_346 | /// <reference path="fourslash.ts" />
////interface Options {
//// /**
//// * A description of 'a'
//// */
//// a: {
//// /**
//// * A description of 'b'
//// */
//// b: string;
//// }
////}
////
////function f({ a, a: { b } }: Options) {
//// a/*1*/;
//// b/*2*/;
////}
verify.baselineQuickInfo();
| {
"end_byte": 346,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon.ts_0_1872 | /// <reference path='fourslash.ts' />
//// /*z*/c/*y*/onst /*x*/f/*w*/oo = /*v*/f/*u*/unction() /*t*/{/*s*/ /*r*/r/*q*/eturn 42;};
goTo.select("z", "y");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("x", "w");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("v", "u");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("t", "s");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
goTo.select("r", "q");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
| {
"end_byte": 1872,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts_3_287 | / <reference path='fourslash.ts'/>
//// class Foo {
//// constructor(protected /*0*/protectedParam: number) {
//// let localProtected = /*1*/protectedParam;
//// this./*2*/protectedParam += 10;
//// }
//// }
verify.baselineFindAllReferences('0', '1', '2')
| {
"end_byte": 287,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames7.ts_0_288 | /// <reference path='fourslash.ts' />
// @Filename: b.ts
////import [|/*classAliasDefinition*/defaultExport|] from "./a";
// @Filename: a.ts
////class /*classDefinition*/Class {
//// private f;
////}
////export default Class;
verify.baselineGoToDefinition("classAliasDefinition");
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames7.ts"
} |
TypeScript/tests/cases/fourslash/linkedEditingJsxTag4.ts_0_1065 | /// <reference path='fourslash.ts' />
// for readability purposes
//const jsx = (
// <div<T>>
// <p>
// <img />
// </p>
// </div>
//);
// @Filename: /typeTag.tsx
////const jsx = (
//// </*0*/div/*1*/</*2*/T/*3*/>/*4*/>/*5*/
//// <p>
//// <img />
//// </p>
//// <//*6*/div>
////);
// @Filename: /typeTagError.tsx
////const jsx = (
//// </*10*/div/*11*/</*12*/T/*13*/>/*14*/
//// </*15*/p />
//// <//*16*/div>
////);
const startPos = test.markerByName("0").position;
const endPos = test.markerByName("6").position;
const wordPattern = "[a-zA-Z0-9:\\-\\._$]*";
const linkedCursors = {
ranges: [{ start: startPos, length: 3 }, { start: endPos, length: 3 }],
wordPattern,
};
verify.linkedEditing( {
"0": linkedCursors,
"1": linkedCursors,
"2": undefined,
"3": undefined,
"4": undefined,
"5": undefined,
"6": linkedCursors,
"10": undefined,
"11": undefined,
"12": undefined,
"13": undefined,
"14": undefined,
"15": undefined,
"16": undefined,
}); | {
"end_byte": 1065,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag4.ts"
} |
TypeScript/tests/cases/fourslash/tsxFindAllReferences2.ts_0_392 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: {
//// /*1*/name?: string;
//// isOpen?: boolean;
//// };
//// span: { n: string; };
//// }
//// }
//// var x = <div name="hello" />;
verify.baselineFindAllReferences('1')
| {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferences2.ts"
} |
TypeScript/tests/cases/fourslash/extract-method-uniqueName.ts_0_391 | /// <reference path='fourslash.ts' />
////const newFunction = 0;
/////*start*/1 + 1/*end*/;
goTo.select('start', 'end')
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to function in global scope",
newContent:
`const newFunction = 0;
/*RENAME*/newFunction_1();
function newFunction_1() {
1 + 1;
}
`
});
| {
"end_byte": 391,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-uniqueName.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocInheritage.ts_0_2824 | /// <reference path='fourslash.ts' />
//// interface A {
//// /**
//// * @description A.foo1
//// */
//// foo1: number;
//// /**
//// * @description A.foo2
//// */
//// foo2: (para1: string) => number;
//// }
////
//// interface B {
//// /**
//// * @description B.foo1
//// */
//// foo1: number;
//// /**
//// * @description B.foo2
//// */
//// foo2: (para2: string) => number;
//// }
////
//// // implement multi interfaces with duplicate name
//// // method for function signature
//// class C implements A, B {
//// /*1*/foo1: number = 1;
//// /*2*/foo2(q: string) { return 1 }
//// }
////
//// // implement multi interfaces with duplicate name
//// // property for function signature
//// class D implements A, B {
//// /*3*/foo1: number = 1;
//// /*4*/foo2 = (q: string) => { return 1 }
//// }
////
//// new C()./*5*/foo1;
//// new C()./*6*/foo2;
//// new D()./*7*/foo1;
//// new D()./*8*/foo2;
////
//// class Base1 {
//// /**
//// * @description Base1.foo1
//// */
//// foo1: number = 1;
////
//// /**
//// *
//// * @param q Base1.foo2 parameter
//// * @returns Base1.foo2 return
//// */
//// foo2(q: string) { return 1 }
//// }
////
//// // extends class and implement interfaces with duplicate name
//// // property override method
//// class Drived1 extends Base1 implements A {
//// /*9*/foo1: number = 1;
//// /*10*/foo2(para1: string) { return 1 };
//// }
////
//// // extends class and implement interfaces with duplicate name
//// // method override method
//// class Drived2 extends Base1 implements B {
//// /*11*/foo1: number = 1;
//// /*12*/foo2 = (para1: string) => { return 1; };
//// }
////
//// class Base2 {
//// /**
//// * @description Base2.foo1
//// */
//// foo1: number = 1;
//// /**
//// *
//// * @param q Base2.foo2 parameter
//// * @returns Base2.foo2 return
//// */
//// foo2(q: string) { return 1 }
//// }
////
//// // extends class and implement interfaces with duplicate name
//// // property override method
//// class Drived3 extends Base2 implements A {
//// /*13*/foo1: number = 1;
//// /*14*/foo2(para1: string) { return 1 };
//// }
////
//// // extends class and implement interfaces with duplicate name
//// // method override method
//// class Drived4 extends Base2 implements B {
//// /*15*/foo1: number = 1;
//// /*16*/foo2 = (para1: string) => { return 1; };
//// }
////
//// new Drived1()./*17*/foo1;
//// new Drived1()./*18*/foo2;
//// new Drived2()./*19*/foo1;
//// new Drived2()./*20*/foo2;
//// new Drived3()./*21*/foo1;
//// new Drived3()./*22*/foo2;
//// new Drived4()./*23*/foo1;
//// new Drived4()./*24*/foo2;
verify.baselineQuickInfo();
| {
"end_byte": 2824,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocInheritage.ts"
} |
TypeScript/tests/cases/fourslash/completionListInClosedFunction06.ts_3_328 | / <reference path="fourslash.ts" />
////interface MyType {
////}
////
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (x: /*1*/);
//// }
////}
verify.completions({ marker: "1", includes: "MyType", excludes: "x" });
| {
"end_byte": 328,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedFunction06.ts"
} |
TypeScript/tests/cases/fourslash/completionsClassMembers4.ts_0_851 | /// <reference path="fourslash.ts" />
// @filename: /foo.ts
////export class Observable<T> {
//// pipe(): Observable<T>;
//// pipe<A>(): Observable<A>;
//// pipe<A, B>(): Observable<B>;
//// pipe<A, B, C>(): Observable<C>;
//// pipe<A, B, C, D>(): Observable<D>;
//// pipe<A, B, C, D, E>(): Observable<E>;
//// pipe<A, B, C, D, E, F>(): Observable<F>;
//// pipe<A, B, C, D, E, F, G>(): Observable<G>;
//// pipe<A, B, C, D, E, F, G, H>(): Observable<H>;
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;
////}
////export class Foo extends Observable<any> {
//// /**/
////}
verify.baselineCompletions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithClassMemberSnippets: true,
});
| {
"end_byte": 851,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassMembers4.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsTypeParameterInMergedInterface.ts_0_170 | /// <reference path='fourslash.ts' />
////interface I</*1*/T> { a: /*2*/T }
////interface I</*3*/T> { b: /*4*/T }
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsTypeParameterInMergedInterface.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts_0_143 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => [1,2,.../*1*/
verify.completions({ marker: "1", includes: ["p", "x"] });
| {
"end_byte": 143,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember15.ts_0_317 | /// <reference path="fourslash.ts" />
////const a = 1;
////
////export const enum E {
////}
////
////const foo = E.Foo/**/;
goTo.marker("");
verify.codeFix({
index: 0,
description: "Add missing enum member 'Foo'",
newFileContent:
`const a = 1;
export const enum E {
Foo
}
const foo = E.Foo;`,
});
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember15.ts"
} |
TypeScript/tests/cases/fourslash/completionUsingKeyword.ts_0_423 | /// <reference path="fourslash.ts" />
////function foo() {
//// usin/*1*/
////}
////async function bar() {
//// await usin/*2*/
////}
////
////class C {
//// foo() {
//// usin/*3*/
//// }
////
//// async bar() {
//// await usin/*4*/
//// }
////}
verify.completions({
marker: ["1", "2", "3", "4"],
includes: [{ name: 'using', sortText: completion.SortText.GlobalsOrKeywords }],
});
| {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionUsingKeyword.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageArrowJS.ts_0_461 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: test.js
////const foo = x => x.y + 1;
////class C {
//// m = x => x.y + 1;
////}
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`const foo = (/** @type {{ y: number; }} */ x) => x.y + 1;
class C {
m = (/** @type {{ y: number; }} */ x) => x.y + 1;
}`,
}); | {
"end_byte": 461,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageArrowJS.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeToplevelInsert.ts_0_253 | ///<reference path="fourslash.ts"/>
// @Filename: /topLevelInsert.ts
//// function foo() {
//// return 1;
//// }[||]
//// function bar() {
//// return 2;
//// }
verify.baselineMapCode([test.ranges()], [
`
function baz() {
return 3;
}
`
]); | {
"end_byte": 253,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeToplevelInsert.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts_0_858 | /// <reference path='fourslash.ts' />
// Should give completions for typings discovered in all visible @types directories
// @Filename: subdirectory/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: subdirectory/node_modules/@types/module-x/index.d.ts
//// export var x = 9;
// @Filename: subdirectory/package.json
//// { "dependencies": { "@types/module-x": "latest" } }
// @Filename: node_modules/@types/module-y/index.d.ts
//// export var y = 9;
// @Filename: package.json
//// { "dependencies": { "@types/module-y": "latest" } }
verify.completions({
marker: ["types_ref0", "import_as0", "import_equals0", "require0"],
exact: ["module-x", "module-y"],
isNewIdentifierLocation: true,
});
| {
"end_byte": 858,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts"
} |
TypeScript/tests/cases/fourslash/formattingAfterMultiLineIfCondition.ts_0_329 | /// <reference path='fourslash.ts' />
//// var foo;
//// if (foo &&
//// foo) {
/////*comment*/ // This is a comment
//// foo.toString();
//// /**/
goTo.marker();
edit.insert('}');
goTo.marker('comment');
// Comment below multi-line 'if' condition formatting
verify.currentLineContentIs(' // This is a comment'); | {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingAfterMultiLineIfCondition.ts"
} |
TypeScript/tests/cases/fourslash/unusedClassInNamespace1.ts_0_185 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// class class1 {
//// }
//// } |]
verify.rangeAfterCodeFix(`namespace greeter {
}`);
| {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedClassInNamespace1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_OptionalInterface.ts_0_548 | /// <reference path='fourslash.ts' />
////interface Foo {
//// bar?:{
//// baz?: string;
//// }
////}
////declare let foo: Foo | undefined;
/////*a*/foo && foo.bar && foo.bar.baz;/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`interface Foo {
bar?:{
baz?: string;
}
}
declare let foo: Foo | undefined;
foo?.bar?.baz;`
}); | {
"end_byte": 548,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_OptionalInterface.ts"
} |
TypeScript/tests/cases/fourslash/toggleMultilineComment5.ts_0_1077 | // Jsx uses block comments for each line commented.
// Common JSX comment scenarios
//@Filename: file.tsx
//// const a = <div tabIndex="0">[|</div>;|]
//// const b = <div>This is [|valid HTML &|] JSX at the same time.</div>;
//// const c = <MyContainer>
//// [|<MyFirstComponent />
//// <MySecondComponent />|]
//// </MyContainer>;
//// const d = <MyContainer>
//// <MyFirstComp[|onent />
//// <MySecondComponent />|]
//// </MyContainer>;
//// const e = <MyComponent>[|{'foo'}|]</MyComponent>;
//// const f = <div>Some text</div[|>;|]
//// const g = <div>Some text<[|/div>;|]
verify.toggleMultilineComment(
`const a = <div tabIndex="0">{/*</div>;*/}
const b = <div>This is {/*valid HTML &*/} JSX at the same time.</div>;
const c = <MyContainer>
{/*<MyFirstComponent />
<MySecondComponent />*/}
</MyContainer>;
const d = <MyContainer>
<MyFirstComp{/*onent />
<MySecondComponent />*/}
</MyContainer>;
const e = <MyComponent>{/*{'foo'}*/}</MyComponent>;
const f = <div>Some text</div{/*>;*/}
const g = <div>Some text<{/*/div>;*/}`
); | {
"end_byte": 1077,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment5.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts_0_328 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
////{ "compilerOptions": { "baseUrl": "./src" } }
// @Filename: /src/d0/d1/d2/file.ts
////foo/**/;
// @Filename: /src/d0/a.ts
////export const foo = 0;
goTo.file("/src/d0/d1/d2/file.ts");
verify.importFixAtPosition([
`import { foo } from "d0/a";
foo;`
]);
| {
"end_byte": 328,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSplitTypeOnlyImport.ts_0_1013 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export type B = {};
////export type C = {};
////export default interface A {}
// @Filename: /b.ts
////export type E = {};
////export type F = {};
////export default class D {}
// @Filename: /c.ts
////import type A, { B, C } from './a';
////import type D, * as types from './b';
goTo.file("/c.ts");
verify.codeFix({
errorCode: ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code,
description: ts.Diagnostics.Split_into_two_separate_import_declarations.message,
applyChanges: false,
index: 0,
newFileContent:
`import type A from './a';
import type { B, C } from './a';
import type D, * as types from './b';`
});
verify.codeFixAll({
fixId: "splitTypeOnlyImport",
fixAllDescription: ts.Diagnostics.Split_all_invalid_type_only_imports.message,
newFileContent:
`import type A from './a';
import type { B, C } from './a';
import type D from './b';
import type * as types from './b';
`
});
| {
"end_byte": 1013,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSplitTypeOnlyImport.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionAwait1.ts_0_277 | /// <reference path="fourslash.ts" />
//// async function /*end1*/foo() {
//// [|/*start1*/await|] Promise.resolve(0);
//// }
//// function notAsync() {
//// [|/*start2*/await|] Promise.resolve(0);
//// }
verify.baselineGoToDefinition(
"start1",
"start2"
);
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionAwait1.ts"
} |
TypeScript/tests/cases/fourslash/jsdocThrowsTag_rename.ts_0_159 | /// <reference path="fourslash.ts" />
////class /**/E extends Error {}
/////**
//// * @throws {E}
//// */
////function f() {}
verify.baselineRename("", {});
| {
"end_byte": 159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocThrowsTag_rename.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport13.ts_0_844 | /// <reference path='fourslash.ts' />
// Should give completions based on typesVersions
// @Filename: node_modules/ext/package.json
//// {
//// "name": "ext",
//// "version": "1.0.0",
//// "types": "index",
//// "typesVersions": {
//// ">=3.1.0-0": { "*" : ["ts3.1/*"] }
//// }
//// }
// @Filename: node_modules/ext/index.d.ts
//// export {};
// @Filename: node_modules/ext/aaa.d.ts
//// export {};
// @Filename: node_modules/ext/ts3.1/index.d.ts
//// export {};
// @Filename: node_modules/ext/ts3.1/zzz.d.ts
//// export {};
// @Filename: main.ts
//// import * as ext1 from "ext//*import_as0*/
//// import ext2 = require("ext//*import_equals0*/
//// var ext2 = require("ext//*require0*/
verify.completions({
marker: test.markerNames(),
exact: ["index", "zzz"],
isNewIdentifierLocation: true,
});
| {
"end_byte": 844,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport13.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization17.ts_0_298 | /// <reference path='fourslash.ts' />
// @strict: true
//// class T {
//// // comment
//// a: string;
//// }
verify.codeFix({
description: `Add definite assignment assertion to property 'a: string;'`,
newFileContent: `class T {
// comment
a!: string;
}`,
index: 1
})
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization17.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties6.ts_0_819 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
// @Filename: fixExactOptionalUnassignableProperties6.ts
// based on snapshotterInjected.ts in microsoft/playwright
//// type Data = {
//// f?: (x: number) => void,
//// additional?: number,
//// nop: string,
//// };
//// declare function e(o: any): Data;
//// e(101).f = undefined
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_undefined_to_optional_property_type.message,
index: 0,
newFileContent:
`type Data = {
f?: ((x: number) => void) | undefined,
additional?: number | undefined,
nop: string,
};
declare function e(o: any): Data;
e(101).f = undefined`,
});
| {
"end_byte": 819,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties6.ts"
} |
TypeScript/tests/cases/fourslash/interfaceRecursiveInheritanceErrors0.ts_0_172 | /// <reference path="fourslash.ts" />
////interface i8 extends i9 { }
////interface i9 /*1*/{ }
edit.disableFormatting();
goTo.marker('1');
edit.insert("extends i8 ");
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/interfaceRecursiveInheritanceErrors0.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports5.ts_0_466 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////const a = 42;
////const b = 42;
////export class C {
//// get property() { return a + b; }
////}
verify.codeFixAvailable([
{ description: "Add return type 'number'" }
]);
verify.codeFix({
description: "Add return type 'number'",
index: 0,
newFileContent:
`const a = 42;
const b = 42;
export class C {
get property(): number { return a + b; }
}`,
});
| {
"end_byte": 466,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports5.ts"
} |
TypeScript/tests/cases/fourslash/formatSpaceAfterTemplateHeadAndMiddle.ts_0_895 | /// <reference path='fourslash.ts' />
////const a1 = `${1}${1}`;
////const a2 = `
//// ${1}${1}
////`;
////const a3 = `
////
////
//// ${1}${1}
////`;
////const a4 = `
////
//// ${1}${1}
////
////`;
////const a5 = `text ${1} text ${1} text`;
////const a6 = `
//// text ${1}
//// text ${1}
//// text
////`;
format.setOption("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", true);
format.document();
verify.currentFileContentIs(
"const a1 = `${ 1 }${ 1 }`;\n" +
"const a2 = `\n" +
" ${ 1 }${ 1 }\n" +
"`;\n" +
"const a3 = `\n" +
"\n" +
"\n" +
" ${ 1 }${ 1 }\n" +
"`;\n" +
"const a4 = `\n" +
"\n" +
" ${ 1 }${ 1 }\n" +
"\n" +
"`;\n" +
"const a5 = `text ${ 1 } text ${ 1 } text`;\n" +
"const a6 = `\n" +
" text ${ 1 }\n" +
" text ${ 1 }\n" +
" text\n" +
"`;"
);
| {
"end_byte": 895,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSpaceAfterTemplateHeadAndMiddle.ts"
} |
TypeScript/tests/cases/fourslash/completionsAtGenericTypeArguments.ts_0_494 | /// <reference path='fourslash.ts' />
////class Foo<T1, T2> {}
////const foo = new Foo</*1*/, /*2*/,
////
////function foo<T1, T2>() {}
////const f = foo</*3*/, /*4*/,
verify.completions({ marker: "1", exact: completion.globalTypesPlus(['Foo']) });
verify.completions({ marker: "2", exact: completion.globalTypesPlus(['Foo']) });
verify.completions({ marker: "3", exact: completion.globalTypesPlus(['Foo']) });
verify.completions({ marker: "4", exact: completion.globalTypesPlus(['Foo']) });
| {
"end_byte": 494,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAtGenericTypeArguments.ts"
} |
TypeScript/tests/cases/fourslash/completionListWithLabel.ts_0_491 | /// <reference path="fourslash.ts"/>
//// label: while (true) {
//// break /*1*/
//// continue /*2*/
//// testlabel: while (true) {
//// break /*3*/
//// continue /*4*/
//// break tes/*5*/
//// continue tes/*6*/
//// }
//// break /*7*/
//// break; /*8*/
////}
verify.completions(
{ marker: ["1", "2", "7"], exact: "label" },
{ marker: ["3", "4", "5", "6"], exact: ["testlabel", "label"] },
{ marker: "8", excludes: ["label"] },
);
| {
"end_byte": 491,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithLabel.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts_0_170 | /// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/`abcd`/*4*/
verify.noSignatureHelp(...test.markerNames());
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion10.ts_0_301 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x1 = <div><//**/
verify.completions({ marker: "", exact: "div>" });
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion10.ts"
} |
TypeScript/tests/cases/fourslash/autoImportTypeImport3.ts_0_1345 | /// <reference path="fourslash.ts" />
// @verbatimModuleSyntax: true
// @target: esnext
// @Filename: /foo.ts
//// export const A = 1;
//// export type B = { x: number };
//// export type C = 1;
//// export class D = { y: string };
// @Filename: /test.ts
//// import { A, type B, type C } from './foo';
//// const b: B | C;
//// console.log(A, D/**/);
goTo.marker("");
// importFixes should only place the import in sorted position if the existing imports are sorted as specified,
// otherwise the import should be placed at the end (regardless of if it's a regular or type-only import)
verify.importFixAtPosition([
`import { A, D, type B, type C } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }
);
verify.importFixAtPosition([
`import { A, type B, type C, D } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" }
);
verify.importFixAtPosition([
`import { A, type B, type C, D } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "first" }
// `D` is added to the end since `A, type B, type C` is not sorted to "first"
); | {
"end_byte": 1345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeImport3.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeNestedClassIfReplacement.ts_0_395 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// class MyClass {
//// x = 1;
//// foo() {
//// return 1;
//// }
//// bar() {
//// if (true) [||]{
//// return 2;
//// }
//// }
//// baz() {
//// return 3;
//// }
//// }
////
verify.baselineMapCode([test.ranges()], [
`
if (true) {
return "hello";
}
`
]); | {
"end_byte": 395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedClassIfReplacement.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.