_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/signatureHelp_contextual.ts_0_2370 | /// <reference path='fourslash.ts' />
////interface I {
//// m(n: number, s: string): void;
//// m2: () => void;
////}
////declare function takesObj(i: I): void;
////takesObj({ m: (/*takesObj0*/) });
////takesObj({ m(/*takesObj1*/) });
////takesObj({ m: function(/*takesObj2*/) });
////takesObj({ m2: (/*takesObj3*/) });
////
////declare function takesCb(cb: (n: number, s: string, b: boolean) => void): void;
////takesCb((/*contextualParameter1*/));
////takesCb((/*contextualParameter1b*/) => {});
////takesCb((n, /*contextualParameter2*/));
////takesCb((n, s, /*contextualParameter3*/));
////takesCb((n,/*contextualParameter3_2*/ s, b));
////takesCb((n, s, b, /*contextualParameter4*/));
////
////type Cb = () => void;
////const cb: Cb = (/*contextualTypeAlias*/)
////
////const cb2: () => void = (/*contextualFunctionType*/)
verify.signatureHelp(
{
marker: ["takesObj0", "takesObj1", "takesObj2"],
text: "m(n: number, s: string): void",
parameterCount: 2,
parameterName: "n",
parameterSpan: "n: number",
},
{
marker: "takesObj3",
text: "m2(): void",
parameterCount: 0,
},
{
marker: ["contextualParameter1", "contextualParameter1b"],
text: "cb(n: number, s: string, b: boolean): void",
parameterCount: 3,
parameterName: "n",
parameterSpan: "n: number",
},
{
marker: "contextualParameter2",
text: "cb(n: number, s: string, b: boolean): void",
parameterCount: 3,
parameterName: "s",
parameterSpan: "s: string",
},
{
marker: "contextualParameter3",
text: "cb(n: number, s: string, b: boolean): void",
parameterCount: 3,
parameterName: "b",
parameterSpan: "b: boolean",
},
{
marker: "contextualParameter3_2",
text: "cb(n: number, s: string, b: boolean): void",
parameterCount: 3,
parameterName: "s",
parameterSpan: "s: string",
},
{
marker: "contextualParameter4",
text: "cb(n: number, s: string, b: boolean): void",
parameterCount: 3,
},
{
marker: "contextualTypeAlias",
text: "Cb(): void",
parameterCount: 0,
},
{
marker: "contextualFunctionType",
text: "cb2(): void",
parameterCount: 0,
},
);
| {
"end_byte": 2370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelp_contextual.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_dotDefault.ts_0_349 | /// <reference path='fourslash.ts' />
// Test that we leave it alone if the name is a keyword.
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////exports.default = 0;
////exports.default;
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`const _default = 0;
export { _default as default };
_default;`,
});
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_dotDefault.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingCaseWeight2.ts_0_144 | /// <reference path='fourslash.ts' />
////let ABCDEFGHI = 1;
////let abcdefghij = 1;
////[|abcdefghi|]
verify.rangeAfterCodeFix('ABCDEFGHI');
| {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingCaseWeight2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_HeaderComment2.ts_0_569 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////export const bar = 0;
// @Filename: /c.ts
/////*--------------------
//// * Copyright Header
//// *--------------------*/
////
////const afterHeader = 1;
////
////// non-header comment
////import { bar } from "./b";
////foo;
goTo.file("/c.ts");
verify.importFixAtPosition([
`/*--------------------
* Copyright Header
*--------------------*/
const afterHeader = 1;
import { foo } from "./a";
// non-header comment
import { bar } from "./b";
foo;`,
]);
| {
"end_byte": 569,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_HeaderComment2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageCommentAfterParameter.ts_0_477 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: important.js
////function coll(callback /*, name1, name2, ... */) {
//// return callback(this);
////}
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {(arg0: any) => any} callback
*/
function coll(callback /*, name1, name2, ... */) {
return callback(this);
}`,
});
| {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageCommentAfterParameter.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecommended_contextualTypes.ts_0_1233 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @Filename: /a.tsx
////enum E {}
////enum F {}
////interface I { e: E }
////function f(e: E, f: F) {}
////f(/*arg0*/, /*arg1*/);
////
////const i: I = { e: /*prop*/ };
////
////function tag(arr: TemplateStringsArray, x: E) {}
////tag`${/*tag*/}`;
////
////declare function MainButton(props: { e: E }): any;
////<MainButton e={/*jsx*/} />
////<MainButton e=/*jsx2*/ />
recommended("arg0");
recommended("arg1", { enumName: "F" });
recommended("prop", { isNewIdentifierLocation: false });
recommended("tag");
recommended("jsx", { isNewIdentifierLocation: false });
recommended("jsx2", { isNewIdentifierLocation: false, insertText: "{E}" });
function recommended(marker: string, { insertText, isNewIdentifierLocation = true, enumName = "E" }: { insertText?: string, isNewIdentifierLocation?: boolean, enumName?: string } = {}) {
verify.completions({
marker,
includes: {
name: enumName,
text: `enum ${enumName}`,
kind: "enum",
isRecommended: true,
insertText,
},
isNewIdentifierLocation,
preferences: {
includeInsertTextCompletions: true,
},
});
}
| {
"end_byte": 1233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_contextualTypes.ts"
} |
TypeScript/tests/cases/fourslash/unusedImports4FS.ts_0_470 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import {Calculator, test, test2} from "./file1" |]
////
//// var x = new Calculator();
//// x.handleChar();
//// test2();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() {}
//// }
////
//// export function test() {
////
//// }
////
//// export function test2() {
////
//// }
verify.rangeAfterCodeFix(`import {Calculator, test2} from "./file1"`); | {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports4FS.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptClass2.ts_0_470 | ///<reference path="fourslash.ts" />
// In an inferred class, we can rename successfully
// @allowNonTsExtensions: true
// @Filename: Foo.js
//// class Foo {
//// constructor() {
//// [|this.[|{| "contextRangeIndex": 0 |}union|] = 'foo';|]
//// [|this.[|{| "contextRangeIndex": 2 |}union|] = 100;|]
//// }
//// method() { return this.[|union|]; }
//// }
//// var x = new Foo();
//// x.[|union|];
verify.baselineRenameAtRangesWithText("union");
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptClass2.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecommended_local.ts_0_1206 | /// <reference path="fourslash.ts" />
////enum Enu {}
////class Cls {}
////abstract class Abs {}
////const e: Enu = E/*e0*/;
////const e: Enu = /*e1*/;
////const c: Cls = new C/*c0*/;
////const c: Cls = new /*c1*/;
////const a: Abs = new A/*a0*/;
////const a: Abs = new /*a1*/;
// Also works on mutations
////let enu: Enu;
////enu = E/*let0*/;
////enu = E/*let1*/;
const cls = (ctr: boolean): FourSlashInterface.ExpectedCompletionEntry => ({
name: "Cls",
text: ctr ? "constructor Cls(): Cls" : "class Cls",
kind: "class",
isRecommended: true,
});
// Not recommended, because it's an abstract class
const abs = (ctr: boolean): FourSlashInterface.ExpectedCompletionEntry => ({
name: "Abs",
text: ctr ? "constructor Abs(): Abs" : "class Abs",
kind: "class",
kindModifiers: "abstract",
});
verify.completions(
{
marker: ["e0", "e1", "let0", "let1"],
includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true },
isNewIdentifierLocation: true,
},
{ marker: "c0", includes: cls(true) },
{ marker: "c1", includes: cls(false) },
{ marker: "a0", includes: abs(true) },
{ marker: "a1", includes: abs(false) },
);
| {
"end_byte": 1206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_local.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts_0_198 | /// <reference path='fourslash.ts'/>
////class Foo {
//// /*1*/public /*2*/___bar() { return 0; }
////}
////
////var x: Foo;
////x./*3*/___bar;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 198,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDoc.ts_0_216 | /// <reference path="fourslash.ts" />
////// Not a JSDoc comment
/////**
//// * @param {number} x The number to square
//// */
////function /**/square(x) {
//// return x * x;
////}
verify.baselineSmartSelection(); | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDoc.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentParenth.ts_0_432 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/"/*y*/foobar is" + ( /* C1 */ 42 ) /* C2 */ + /* C3 */ " years old"
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent:
"const foo = `foobar is\${/* C1 */ 42 /* C2 */ /* C3 */} years old`",
});
| {
"end_byte": 432,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentParenth.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyCrossFile.ts_0_453 | /// <reference path="fourslash.ts" />
// @filename: /a.ts
////export function /**/createModelReference() {}
// @filename: /b.ts
////import { createModelReference } from "./a";
////function openElementsAtEditor() {
//// createModelReference();
////}
// @filename: /c.ts
////import { createModelReference } from "./a";
////function registerDefaultLanguageCommand() {
//// createModelReference();
////}
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyCrossFile.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts_0_214 | /// <reference path='fourslash.ts' />
////var /*varDef*/x = {
//// [|/*varProp*/x|]
////}
////let /*letDef*/y = {
//// [|/*letProp*/y|]
////}
verify.baselineGoToDefinition(
"varProp",
"letProp",
);
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts"
} |
TypeScript/tests/cases/fourslash/importTypeCompletions4.ts_0_648 | /// <reference path="fourslash.ts" />
// @esModuleInterop: true
// @Filename: /foo.ts
////interface Foo { };
////export = Foo;
// @Filename: /bar.ts
//// [|import type f/**/|]
goTo.file("/bar.ts")
verify.completions({
marker: "",
exact: [{
name: "Foo",
sourceDisplay: "./foo",
source: "./foo",
insertText: "import type Foo from \"./foo\";",
replacementSpan: test.ranges()[0]
}],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true
}
});
| {
"end_byte": 648,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions4.ts"
} |
TypeScript/tests/cases/fourslash/completionInJsDocQualifiedNames.ts_0_452 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /node_modules/foo/index.d.ts
/////** tee */
////export type T = number;
// @Filename: /a.js
////import * as Foo from "foo";
/////** @type {Foo./**/} */
////const x = 0;
verify.completions({
marker: "",
includes: {
name: "T",
text: "type T = number",
documentation: "tee",
kind: "type",
kindModifiers: "export,declare",
},
});
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInJsDocQualifiedNames.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember4.ts_0_278 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.d.ts
////declare function foo(): any;
////declare function bar(): any;
// @filename: /b.ts
////import { bar } from "./a";
goTo.file("/b.ts");
verify.not.codeFixAvailable("fixImportNonExportedMember");
| {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember4.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_preferences.ts_0_644 | /// <reference path='fourslash.ts' />
// @Filename: /dir/a.ts
////export const a = 0;
// @Filename: /dir/b.ts
////import {} from "dir/a";
////import {} from 'dir/a';
// @Filename: /tsconfig.json
////{ "compilerOptions": { "baseUrl": "." } }
verify.getEditsForFileRename({
oldPath: "/dir/a.ts",
newPath: "/dir/a1.ts",
newFileContents: {
"/dir/b.ts":
`import {} from "dir/a1";
import {} from 'dir/a1';`,
},
preferences: {
importModuleSpecifierPreference: "non-relative",
// No effect because we are changing existing imports, which already have quotes
quotePreference: "single",
},
});
| {
"end_byte": 644,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_preferences.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_namedToDefault_alreadyHasDefault.ts_0_214 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////*a*/export function f() {}/*b*/
////export default function g() {}
goTo.select("a", "b");
verify.refactorsAvailable(["Infer function return type"]);
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_namedToDefault_alreadyHasDefault.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl_Modifier.ts_0_382 | /// <reference path='fourslash.ts' />
//// export let foo, bar = /*x*/(/*y*/) => 1 + 1;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `export let foo;
export function bar() {
return 1 + 1;
}
`,
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl_Modifier.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToDefault2.ts_0_728 | /// <reference path="fourslash.ts" />
// @esModuleInterop: true
// @allowJs: true
// @checkJs: true
// @Filename: /process.d.ts
////declare module "process" {
//// interface Process {
//// pid: number;
//// addListener(event: string, listener: (...args: any[]) => void): void;
//// }
//// var process: Process;
//// export = process;
////}
// @Filename: /a.js
/////** [|@import { pid, addListener } from "process"|] */
goTo.selectRange(test.ranges()[0]);
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to default import",
actionDescription: "Convert named imports to default import",
newContent: `/** @import process from "process" */`,
});
| {
"end_byte": 728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToDefault2.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTypeArguments.ts_0_1559 | /// <reference path="fourslash.ts"/>
////declare function f(a: number, b: string, c: boolean): void; // ignored, not generic
////declare function f<T extends number>(): void;
////declare function f<T, U>(): void;
////declare function f<T, U, V extends string>(): void;
////f</*f0*/;
////f<number, /*f1*/;
////f<number, string, /*f2*/;
////
////declare const C: {
//// new<T extends number>(): void;
//// new<T, U>(): void;
//// new<T, U, V extends string>(): void;
////};
////new C</*C0*/;
////new C<number, /*C1*/;
////new C<number, string, /*C2*/;
verify.signatureHelp(
{
marker: "f0",
overloadsCount: 3,
text: "f<T extends number>(): void",
parameterName: "T",
parameterSpan: "T extends number",
},
{
marker: "f1",
overloadsCount: 2,
text: "f<T, U>(): void",
parameterName: "U",
parameterSpan: "U",
},
{
marker: "f2",
text: "f<T, U, V extends string>(): void",
parameterName: "V",
parameterSpan: "V extends string",
},
{
marker: "C0",
overloadsCount: 3,
text: "C<T extends number>(): void",
parameterName: "T",
parameterSpan: "T extends number",
},
{
marker: "C1",
overloadsCount: 2,
text: "C<T, U>(): void",
parameterName: "U",
parameterSpan: "U",
},
{
marker: "C2",
text: "C<T, U, V extends string>(): void",
parameterName: "V",
parameterSpan: "V extends string",
},
);
| {
"end_byte": 1559,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTypeArguments.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference7.ts_0_450 | /// <reference path='fourslash.ts'/>
// @filename: /a.ts
////export const a = null;
// @filename: /b.ts
////import { a } from './a';
////
////const foo = { '#': null };
////foo[|./**/|]
goTo.file("/b.ts");
verify.completions({
marker: "",
exact: [
{ name: "#", insertText: "['#']", replacementSpan: test.ranges()[0] },
],
preferences: {
includeInsertTextCompletions: true,
quotePreference: "auto"
}
});
| {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference7.ts"
} |
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns12.ts_0_961 | /// <reference path="fourslash.ts" />
// @Filename: /src/vs/test.ts
//// import { Parts } from './parts';
//// export class /**/Extended implements Parts {
//// }
// @Filename: /src/vs/parts.ts
//// import { Event } from '../thing';
//// export interface Parts {
//// readonly options: Event;
//// }
// @Filename: /src/event/event.ts
//// export interface Event {
//// (): string;
//// }
// @Filename: /src/thing.ts
//// import { Event } from '../event/event';
//// export { Event };
// @Filename: /src/a.ts
//// import './thing'
//// declare module './thing' {
//// interface Event {
//// c: string;
//// }
//// }
// In this test, `Event` is incorrectly imported in `thing.ts`
verify.codeFix({
description: "Implement interface 'Parts'",
newFileContent:
`import { Parts } from './parts';
export class Extended implements Parts {
options: Event;
}`,
preferences: {
autoImportFileExcludePatterns: ["src/thing.ts"],
}
});
| {
"end_byte": 961,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns12.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationSwitch.ts_0_777 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_switch.baseline
// @Filename: bpSpan_switch.ts
////var x = 10;
////switch (x) {
//// case 5:
//// x++;
//// break;
//// case 10:
//// {
//// x--;
//// break;
//// }
//// default:
//// x = x *10;
////}
////switch (x)
////{
//// case 5:
//// x++;
//// break;
//// case 10:
//// {
//// x--;
//// break;
//// }
//// default:
//// {
//// x = x * 10;
//// }
////}
////switch ((function foo() {
//// return x * 30;
////})()) {
//// case (function bar() {
//// return 30;
//// })():
//// x++;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 777,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationSwitch.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithOptionalPropertiesGenericPartial3.ts_0_533 | /// <reference path="fourslash.ts" />
// @strict: true
////interface Foo {
//// a: boolean;
////}
////function partialFoo<T extends Partial<Foo>>(x: T, y: T extends { b?: boolean } ? T & { c: true } : T) {
//// return x;
////}
////
////partialFoo({ a: true, b: true }, { /*1*/ });
verify.completions({
marker: '1',
includes: [
{
sortText: completion.SortText.OptionalMember,
name: 'a'
},
{
sortText: completion.SortText.OptionalMember,
name: 'b'
},
{
name: 'c'
}
]
})
| {
"end_byte": 533,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithOptionalPropertiesGenericPartial3.ts"
} |
TypeScript/tests/cases/fourslash/aliasMergingWithNamespace.ts_0_144 | ///<reference path="fourslash.ts"/>
////namespace bar { }
////import bar = bar/**/;
verify.quickInfoAt("",
`namespace bar
import bar = bar`);
| {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/aliasMergingWithNamespace.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_all_js.ts_0_456 | /// <reference path='fourslash.ts' />
// @module: esnext
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
////export class C {}
/////** @typedef {number} T */
// @Filename: /b.js
////C;
/////** @type {T} */
////const x = 0;
goTo.file("/b.js");
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`import { C } from "./a";
C;
/** @type {import("./a").T} */
const x = 0;`,
});
| {
"end_byte": 456,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_all_js.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts_0_920 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "react": "*"
//// }
////}
//@Filename: /node_modules/@types/react/index.d.ts
////export declare var React: any;
//@Filename: /node_modules/@types/react/package.json
////{
//// "name": "@types/react"
////}
//@Filename: /node_modules/@types/fake-react/index.d.ts
////export declare var ReactFake: any;
//@Filename: /node_modules/@types/fake-react/package.json
////{
//// "name": "@types/fake-react"
////}
//@Filename: /src/index.ts
////const x = Re/**/
verify.completions({
marker: test.marker(""),
isNewIdentifierLocation: true,
includes: {
name: "React",
hasAction: true,
source: "/node_modules/@types/react/index",
sortText: completion.SortText.AutoImportSuggestions
},
excludes: "ReactFake",
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 920,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts"
} |
TypeScript/tests/cases/fourslash/navbar_const.ts_0_448 | /// <reference path="fourslash.ts" />
//// const c = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "const"
}
]
}
]);
| {
"end_byte": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navbar_const.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc16.ts_0_425 | /// <reference path='fourslash.ts' />
// @strict: true
/////** @type {function(*, ...number, ...boolean): void} */
////var x = (x, ys, ...zs) => { x; ys; zs; };
verify.codeFix({
index: 3,
description: "Annotate with type from JSDoc",
newFileContent:
`/** @type {function(*, ...number, ...boolean): void} */
var x: (arg0: any, arg1: number[], ...rest: boolean[]) => void = (x, ys, ...zs) => { x; ys; zs; };`,
});
| {
"end_byte": 425,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc16.ts"
} |
TypeScript/tests/cases/fourslash/toggleLineComment3.ts_0_329 | // Comment and uncomment ignores empty lines.
//// let var1[| = 1;
////
//// let var2 = 2;
////
//// let var3 |]= 3;
////
//// //let var4[| = 1;
////
//// //let var5 = 2;
////
//// //let var6 |]= 3;
verify.toggleLineComment(
`//let var1 = 1;
//let var2 = 2;
//let var3 = 3;
let var4 = 1;
let var5 = 2;
let var6 = 3;`); | {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_namedToDefaultInModuleAugmentation2.ts_0_439 | /// <reference path='fourslash.ts' />
////export {};
////declare module "foo" {
//// /*a*/export function func(): void;/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert export",
actionName: "Convert named export to default export",
actionDescription: "Convert named export to default export",
newContent:
`export {};
declare module "foo" {
export default function func(): void;
}`
});
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_namedToDefaultInModuleAugmentation2.ts"
} |
TypeScript/tests/cases/fourslash/formattingOfMultilineBlockConstructs.ts_0_1508 | ///<reference path="fourslash.ts"/>
////module InternalModule/*1*/
////{
////}
////interface MyInterface/*2*/
////{
////}
////enum E/*3*/
////{
////}
////class MyClass/*4*/
////{
////constructor()/*cons*/
////{ }
//// public MyFunction()/*5*/
//// {
//// return 0;
//// }
////public get Getter()/*6*/
////{
////}
////public set Setter(x)/*7*/
////{
////}
////}
////function foo()/*8*/
////{
////{}/*9*/
////}
////(function()/*10*/
////{
////});
////(() =>/*11*/
////{
////});
////var x :/*12*/
////{};/*13*/
format.document();
goTo.marker('1');
verify.currentLineContentIs("module InternalModule {");
goTo.marker('2');
verify.currentLineContentIs("interface MyInterface {");
goTo.marker('3');
verify.currentLineContentIs("enum E {");
goTo.marker('4');
verify.currentLineContentIs("class MyClass {");
goTo.marker('cons');
verify.currentLineContentIs(" constructor() { }");
goTo.marker('5');
verify.currentLineContentIs(" public MyFunction() {");
goTo.marker('6');
verify.currentLineContentIs(" public get Getter() {");
goTo.marker('7');
verify.currentLineContentIs(" public set Setter(x) {");
goTo.marker('8');
verify.currentLineContentIs("function foo() {");
goTo.marker('9');
verify.currentLineContentIs(" { }");
goTo.marker('10');
verify.currentLineContentIs("(function() {");
goTo.marker('11');
verify.currentLineContentIs("(() => {");
goTo.marker('12');
verify.currentLineContentIs("var x:");
goTo.marker('13');
verify.currentLineContentIs(" {};"); | {
"end_byte": 1508,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOfMultilineBlockConstructs.ts"
} |
TypeScript/tests/cases/fourslash/formatRangeEndingAfterCommaOfCall.ts_0_159 | /// <reference path="fourslash.ts"/>
////someCall(
//// /*start*/"firstParameter",/*end*/
//// "something else"
////);
format.selection("start", "end"); | {
"end_byte": 159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRangeEndingAfterCommaOfCall.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingJs6.ts_0_1244 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @checkjs: false
// @noEmit: true
// @filename: spellingUncheckedJS.js
//// export var inModule = 1
//// inmodule.toFixed()
////
//// function f() {
//// var locals = 2 + true
//// locale.toFixed()
//// }
//// class Classe {
//// non = 'oui'
//// methode() {
//// // no error on 'this' references
//// return this.none
//// }
//// }
//// class Derivee extends Classe {
//// methode() {
//// // no error on 'super' references
//// return super.none
//// }
//// }
////
////
//// var object = {
//// spaaace: 3
//// }
//// object.spaaaace // error on read
//// object.spaace = 12 // error on write
//// object.fresh = 12 // OK
//// other.puuuce // OK, from another file
//// new Date().getGMTDate() // OK, from another file
////
//// // No suggestions for globals from other files
//// const atoc = setIntegral(() => console.log('ok'), 500)
//// AudioBuffin // etc
//// Jimmy
//// Jon
//// window.argle
//// self.blargle
// @filename: other.js
//// var Jimmy = 1
//// var John = 2
//// Jon // error, it's from the same file
//// var other = {
//// puuce: 4
//// }
//// window.argle
//// self.blargle
verify.noErrors()
| {
"end_byte": 1244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddAllParameterNames.ts_0_412 | /// <reference path='fourslash.ts' />
////interface I { i: number }
////class C { a = 1 }
////var x: { (boolean, undefined, I, C): string };
verify.codeFixAll({
fixId: "addNameToNamelessParameter",
fixAllDescription: "Add names to all parameters without names",
newFileContent:
`interface I { i: number }
class C { a = 1 }
var x: { (arg0: boolean, arg1: undefined, arg2: I, arg3: C): string };`
});
| {
"end_byte": 412,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddAllParameterNames.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction.ts_0_657 | /// <reference path='fourslash.ts' />
// @Filename: f.ts
////export function f(/*a*/a: number, b: string/*b*/): string {
//// return b;
////}
// @Filename: a.ts
////import { f as g } from "./f";
////g(4, "b");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `export function f({ a, b }: { a: number; b: string; }): string {
return b;
}`
});
goTo.file("a.ts");
verify.currentFileContentIs(`import { f as g } from "./f";
g({ a: 4, b: "b" });`)
| {
"end_byte": 657,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember6.ts_0_212 | /// <reference path="./fourslash.ts"/>
// @noImplicitOverride: true
////class Foo {
//// m() {}
////}
////class Bar extends Foo {
//// [|/*1*/override|] m1() {}
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 212,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember6.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptModules15.ts_0_651 | ///<reference path="fourslash.ts" />
// Assignments to 'exports.p' define a property 'p' even if they're not at top-level
// @allowJs: true
// @Filename: myMod.js
//// if (true) {
//// exports.b = true;
//// } else {
//// exports.n = 3;
//// }
//// function fn() {
//// exports.s = 'foo';
//// }
// @Filename: consumer.js
//// var x = require('./myMod');
//// x/**/;
goTo.file('consumer.js');
goTo.marker();
edit.insert('.');
verify.completions({ includes: ["s", "b", "n"].map(name => ({ name, kind: "property" })) });
edit.insert('n.');
verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 651,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModules15.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyFunctionAmbiguity.5.ts_0_338 | /// <reference path="fourslash.ts" />
// @filename: a.d.ts
//// declare function foo(x?: number): void;
// @filename: b.d.ts
//// declare function foo(x?: string): void;
//// declare function foo(x?: boolean): void;
// @filename: main.ts
//// function /**/bar() {
//// foo();
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 338,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyFunctionAmbiguity.5.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral4.ts_0_794 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: in.js
/////** I am documentation
//// * @param {'literal'} p1
//// * @param {"literal"} p2
//// * @param {'other1' | 'other2'} p3
//// * @param {'literal' | number} p4
//// * @param {12 | true} p5
//// */
////function f(p1, p2, p3, p4, p5) {
//// return p1 + p2 + p3 + p4 + p5 + '.';
////}
////f/*1*/('literal', 'literal', "[|o/*2*/ther1|]", 12);
goTo.marker('1');
verify.quickInfoExists();
verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: "literal" | number, p5: 12 | true): string', 'I am documentation');
const replacementSpan = test.ranges()[0]
verify.completions({ marker: "2", exact: [
{ name: "other1", replacementSpan },
{ name: "other2", replacementSpan }
] });
| {
"end_byte": 794,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral4.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputExternalModule.ts_0_374 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputExternalModule.baseline
// @outFile: declSingleFile.js
// @Filename: inputFile1.ts
// @emitThisFile: true
//// var x: number = 5;
//// class Bar {
//// x : string;
//// y : number
//// }
// @Filename: inputFile2.ts
//// export module M {
//// class C {c}
//// }
verify.baselineGetEmitOutput();
| {
"end_byte": 374,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputExternalModule.ts"
} |
TypeScript/tests/cases/fourslash/formatAsyncAwait.ts_0_669 | /// <reference path="fourslash.ts"/>
////async function asyncFunction() {/*asyncKeyword*/
//// await
/////*awaitExpressionIndent*/
//// Promise.resolve("await");/*awaitExpressionAutoformat*/
//// return await Promise.resolve("completed");/*awaitKeyword*/
////}
format.document();
goTo.marker("asyncKeyword");
verify.currentLineContentIs("async function asyncFunction() {");
goTo.marker("awaitExpressionIndent");
verify.indentationIs(8);
goTo.marker("awaitExpressionAutoformat");
verify.currentLineContentIs(' Promise.resolve("await");');
goTo.marker("awaitKeyword");
verify.currentLineContentIs(' return await Promise.resolve("completed");'); | {
"end_byte": 669,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAsyncAwait.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsCrash1.ts_0_337 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: foo.js
//// /**
//// * @param {function(string): boolean} f
//// */
//// function doThing(f) {
//// f(100)
//// }
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
includeInlayParameterNameHints: "all",
});
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsCrash1.ts"
} |
TypeScript/tests/cases/fourslash/nodeModulesImportCompletions1.ts_0_1307 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @module: nodenext
// @Filename: /src/module.mts
//// export {}
// @Filename: /src/module.cts
//// export {}
// @Filename: /src/module.js
//// export {}
// @Filename: /src/decl.d.mts
//// export {}
// @Filename: /src/decl.d.cts
//// export {}
// @Filename: /src/decl.d.ts
//// export {}
// @Filename: /src/js.mjs
//// export {}
// @Filename: /src/js.cjs
//// export {}
// @Filename: /src/js.js
//// export {}
// @Filename: /main.mts
//// import {} from "./src//*1*/";
//// import mod = require("./src//*2*/");
//// const m = import("./src//*3*/");
// @Filename: /main.cts
//// import {} from "./src//*4*/";
//// import mod = require("./src//*5*/");
//// const m = import("./src//*6*/");
// @Filename: /main.ts
//// import {} from "./src//*7*/";
//// import mod = require("./src//*8*/");
//// const m = import("./src//*9*/");
verify.completions({
marker: ["1", "3", "6", "9"],
exact: ["decl.cjs", "decl.mjs", "decl.js", "js.cjs", "js.js", "js.mjs", "module.cjs", "module.js", "module.mjs"],
isNewIdentifierLocation: true,
});
verify.completions({
marker: ["2", "4", "5", "7", "8"],
exact: ["decl.cjs", "decl.mjs", "decl", "js.cjs", "js", "js.mjs", "module.cjs", "module", "module.mjs"],
isNewIdentifierLocation: true,
}); | {
"end_byte": 1307,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/nodeModulesImportCompletions1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts_0_160 | /// <reference path="fourslash.ts" />
//// namespace X {
//// export =
//// }
//// X.add/*1*/
// verify there is no crash
verify.quickInfoAt("1", "any");
| {
"end_byte": 160,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion12.ts_0_1170 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: "hell"
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt /*1*/ />;
//// let opt1 = <Opt prop/*2*/ />;
//// let opt2 = <Opt propx={100} /*3*/ />;
//// let opt3 = <Opt propx={100} optional /*4*/ />;
//// let opt4 = <Opt wrong /*5*/ />;
verify.completions(
{
marker: ["1", "2", "5"],
exact: [
"propString",
"propx",
{ name: "optional", kind: "property", kindModifiers: "optional", sortText: completion.SortText.OptionalMember },
]
},
{
marker: "3",
exact: [
"propString",
{ name: "optional", kind: "property", kindModifiers: "optional", sortText: completion.SortText.OptionalMember },
]
},
{ marker: "4", exact: "propString" },
);
| {
"end_byte": 1170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion12.ts"
} |
TypeScript/tests/cases/fourslash/autoImportTypeImport1.ts_0_1405 | /// <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, D, 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
verify.importFixAtPosition([
`import { A, D, type C, type B } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "inline" }
// `type B` is added to the end since the existing imports are not sorted as specified
);
verify.importFixAtPosition([
`import { A, D, type B, type C } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "last" }
// `type B` is added to the sorted position since the existing imports *are* sorted as specified
);
verify.importFixAtPosition([
`import { A, D, type C, type B } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "first" }
// `type B` is added to the end (default behavior) since the existing imports are not sorted as specified
); | {
"end_byte": 1405,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeImport1.ts"
} |
TypeScript/tests/cases/fourslash/renameAlias2.ts_0_239 | /// <reference path='fourslash.ts'/>
////[|module [|{| "contextRangeIndex": 0 |}SomeModule|] { export class SomeClass { } }|]
////import M = [|SomeModule|];
////import C = M.SomeClass;
verify.baselineRenameAtRangesWithText("SomeModule"); | {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameAlias2.ts"
} |
TypeScript/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts_0_216 | /// <reference path="fourslash.ts" />
// @allowUnreachableCode: true
//// class alpha { static beta() return 5; } }
//// /**/ var gamma = alpha.beta() * 5;
verify.not.errorExistsAfterMarker(); | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts_0_274 | /// <reference path="fourslash.ts" />
////class ABCD {
//// constructor(private x: number, public y: number, /*1*/private /*2*/z: number) {
//// }
////
//// func() {
//// return this./*3*/z;
//// }
////}
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports7.ts_0_396 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////function foo(): number[] { return [42]; }
////export const c = { foo: foo() };
verify.codeFix({
description: `Add annotation of type '{ foo: number[]; }'`,
index: 0,
newFileContent:
`function foo(): number[] { return [42]; }
export const c: {
foo: number[];
} = { foo: foo() };`,
});
| {
"end_byte": 396,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports7.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationBinaryExpressions.ts_0_380 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_binaryExpressions.baseline
// @Filename: bpSpan_binaryExpressions.ts
////var x = 10;
////var y = 20;
////x += 30;
////x *= 0;
////x = x + 1;
////x = (function foo() {
//// return y;
////})() + y;
////x = y + 30 + (function foo() {
//// return y;
////})() * 40;
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 380,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationBinaryExpressions.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties4.ts_0_705 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
// @Filename: fixExactOptionalUnassignableProperties4.ts
//// interface User {
//// name: string
//// email?: string
//// }
//// const user: User = {
//// name: "Andrew",
//// email: 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:
`interface User {
name: string
email?: string | undefined
}
const user: User = {
name: "Andrew",
email: undefined,
}`,
});
| {
"end_byte": 705,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties4.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsOnDecorators.ts_0_346 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
/////*1*/function /*2*/decorator(target) {
//// return target;
////}
/////*3*/decorator();
// @Filename: b.ts
////@/*4*/decorator @/*5*/decorator("again")
////class C {
//// @/*6*/decorator
//// method() {}
////}
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6');
| {
"end_byte": 346,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOnDecorators.ts"
} |
TypeScript/tests/cases/fourslash/unusedMethodInClass2.ts_0_326 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////class greeter {
//// public function2() {
//// }
//// private function1() {
//// }
////}
verify.codeFix({
description: `Remove unused declaration for: 'function1'`,
newFileContent: `class greeter {
public function2() {
}
}`,
});
| {
"end_byte": 326,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedMethodInClass2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport02.ts_0_474 | /// <reference path='fourslash.ts'/>
/////*1*/export default function /*2*/DefaultExportedFunction() {
//// return /*3*/DefaultExportedFunction;
////}
////
////var x: typeof /*4*/DefaultExportedFunction;
////
////var y = /*5*/DefaultExportedFunction();
////
/////*6*/namespace /*7*/DefaultExportedFunction {
////}
// The namespace and function do not merge,
// so the namespace should be all alone.
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7');
| {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport02.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_types_classic.ts_0_498 | /// <reference path="fourslash.ts" />
// @moduleResolution: classic
// @Filename: /node_modules/@types/foo/index.d.ts
////export const xyz: number;
// @Filename: /node_modules/bar/index.d.ts
////export const qrs: number;
// @Filename: /a.ts
////xyz;
////qrs;
goTo.file("/a.ts");
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`import { xyz } from "foo";
import { qrs } from "./node_modules/bar/index";
xyz;
qrs;`,
});
| {
"end_byte": 498,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_types_classic.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter2.ts_0_294 | /// <reference path="fourslash.ts" />
////interface Foo {
//// one: string;
//// two: number;
////}
////
////interface Bar<T extends Foo> {
//// foo: T;
////}
////
////var foobar: Bar<{ on/**/
verify.completions({ marker: "", exact: ["one", "two"], isNewIdentifierLocation: true });
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter2.ts"
} |
TypeScript/tests/cases/fourslash/referencesForUnionProperties.ts_0_431 | /// <reference path='fourslash.ts'/>
////interface One {
//// common: { /*one*/a: number; };
////}
////
////interface Base {
//// /*base*/a: string;
//// b: string;
////}
////
////interface HasAOrB extends Base {
//// a: string;
//// b: string;
////}
////
////interface Two {
//// common: HasAOrB;
////}
////
////var x : One | Two;
////
////x.common./*x*/a;
verify.baselineFindAllReferences('one', 'base', 'x')
| {
"end_byte": 431,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForUnionProperties.ts"
} |
TypeScript/tests/cases/fourslash/moduleIndent.ts_0_153 | /// <reference path="fourslash.ts"/>
////
goTo.bof();
edit.insert("module M {\n");
// indentation on newline after "module {"
verify.indentationIs(4);
| {
"end_byte": 153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleIndent.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc22.ts_0_476 | /// <reference path='fourslash.ts' />
// @strict: true
////
/////** @param {Object<string, boolean>} sb
//// * @param {Object<number, string>} ns */
////function f(sb, ns) {
//// sb; ns;
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 2,
newFileContent:
`
/** @param {Object<string, boolean>} sb
* @param {Object<number, string>} ns */
function f(sb: { [s: string]: boolean; }, ns: { [n: number]: string; }) {
sb; ns;
}`,
});
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc22.ts"
} |
TypeScript/tests/cases/fourslash/genericWithSpecializedProperties3.ts_0_451 | /// <reference path='fourslash.ts'/>
////interface Foo<T, U> {
//// x: Foo<T, U>;
//// y: Foo<U, U>;
////}
////var f: Foo<number, string>;
////var /*1*/xx = f.x;
////var /*2*/yy = f.y;
////var f2: Foo<string, number>;
////var /*3*/x2 = f2.x;
////var /*4*/y2 = f2.y;
verify.quickInfos({
1: "var xx: Foo<number, string>",
2: "var yy: Foo<string, string>",
3: "var x2: Foo<string, number>",
4: "var y2: Foo<number, number>"
});
| {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericWithSpecializedProperties3.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts_0_550 | /// <reference path='fourslash.ts' />
/////*1*/var /*2*/x = 0;
////var assignmentRightHandSide = /*3*/x;
////var assignmentRightHandSide2 = 1 + /*4*/x;
////
/////*5*/x = 1;
/////*6*/x = /*7*/x + /*8*/x;
////
/////*9*/x == 1;
/////*10*/x <= 1;
////
////var preIncrement = ++/*11*/x;
////var postIncrement = /*12*/x++;
////var preDecrement = --/*13*/x;
////var postDecrement = /*14*/x--;
////
/////*15*/x += 1;
/////*16*/x <<= 1;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16');
| {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTags16.ts_0_328 | ///<reference path="fourslash.ts" />
////class A {
//// /**
//// * Description text here.
//// *
//// * @virtual
//// */
//// foo() { }
////}
////
////class B extends A {
//// override /*1*/foo() { }
////}
////
////class C extends B {
//// override /*2*/foo() { }
////}
verify.baselineQuickInfo();
| {
"end_byte": 328,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags16.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral11.ts_0_218 | /// <reference path='fourslash.ts'/>
////type As = 'arf' | 'abacus' | 'abaddon';
////let a: As;
////switch (a) {
//// case '[|/**/|]
////}
verify.completions({ marker: "", exact: ["arf", "abacus", "abaddon" ] });
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsagePromise.ts_0_266 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function foo([|p |]) {
//// return p.then((x: string[]) => x[0])
//// }
verify.rangeAfterCodeFix("p: Promise<string[]>", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsagePromise.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts_0_142 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => typeof /*1*/
verify.completions({ marker: "1", includes: ["x", "p"] });
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsInheritedProperties3.ts_3_552 | / <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// [|/*0*/doStuff() { }|]
//// [|/*1*/propName: string;|]
//// }
//// interface interface1 extends interface1 {
//// [|/*2*/doStuff(): void;|]
//// [|/*3*/propName: string;|]
//// }
//// class class2 extends class1 implements interface1 {
//// [|/*4*/doStuff() { }|]
//// [|/*5*/propName: string;|]
//// }
////
//// var v: class2;
//// v./*6*/doStuff();
//// v./*7*/propName;
verify.baselineFindAllReferences('0', '1', '2', '3', '4', '6', '5', '7')
| {
"end_byte": 552,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInheritedProperties3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue6.ts_0_131 | /// <reference path='fourslash.ts' />
//// function Foo (): undefined {
//// undefined
//// }
verify.not.codeFixAvailable();
| {
"end_byte": 131,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue6.ts"
} |
TypeScript/tests/cases/fourslash/renameInheritedProperties2.ts_3_239 | / <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// [|[|{| "contextRangeIndex": 0 |}doStuff|]() { }|]
//// }
////
//// var v: class1;
//// v.[|doStuff|]();
verify.baselineRenameAtRangesWithText("doStuff");
| {
"end_byte": 239,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_InnerAsyncFunction2.ts_0_382 | /// <reference path='fourslash.ts' />
/////*a*/const fn = () =>
//// async function() { }/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent:
`function fn() {
return async function() { };
}`,
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_InnerAsyncFunction2.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentDoStatement.ts_0_455 | /// <reference path='fourslash.ts'/>
//// do /*1*/ {
//// } while (true)
////
//// do { /*2*/
//// } /*3*/while (true)/*4*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 0);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 0);
verifyIndentationAfterNewLine("4", 0);
| {
"end_byte": 455,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentDoStatement.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts_0_273 | /// <reference path='fourslash.ts' />
////class A {
//// A: typeof A;
////}
////class D implements A {[| |]}
verify.codeFix({
description: "Implement interface 'A'",
newFileContent:
`class A {
A: typeof A;
}
class D implements A {
A: typeof A;
}`,
});
| {
"end_byte": 273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts"
} |
TypeScript/tests/cases/fourslash/formattingMultilineCommentsWithTabs1.ts_0_1030 | /// <reference path='fourslash.ts'/>
////var f = function (j) {
////
//// switch (j) {
//// case 1:
/////*1*/ /* when current checkbox has focus, Firefox has changed check state already
/////*2*/ on SPACE bar press only
/////*3*/ IE does not have issue, use the CSS class
/////*4*/ input:focus[type=checkbox] (z-index = 31290)
/////*5*/ to determine whether checkbox has focus or not
//// */
//// break;
//// case 2:
//// break;
//// }
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs(" /* when current checkbox has focus, Firefox has changed check state already");
goTo.marker("2");
verify.currentLineContentIs(" on SPACE bar press only");
goTo.marker("3");
verify.currentLineContentIs(" IE does not have issue, use the CSS class");
goTo.marker("4");
verify.currentLineContentIs(" input:focus[type=checkbox] (z-index = 31290)");
goTo.marker("5");
verify.currentLineContentIs(" to determine whether checkbox has focus or not");
| {
"end_byte": 1030,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingMultilineCommentsWithTabs1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_1.ts_0_509 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
//// const A = {
//// /*a*/"a"/*b*/: 1
//// };
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: `const A = {
/*RENAME*/"_a": 1,
get "a"() {
return this["_a"];
},
set "a"(value) {
this["_a"] = value;
},
};`,
});
| {
"end_byte": 509,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_importType5.ts_0_379 | /// <reference path="fourslash.ts" />
// @module: es2015
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import type { SomeInterface, SomePig } from "./exports.js";
//// new SomePig/**/
goTo.marker("");
verify.importFixAtPosition([
`import { SomeInterface, SomePig } from "./exports.js";
new SomePig`]);
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType5.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_satisfiesKeyword.ts_0_223 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function satisfies() {}
// @Filename: /b.ts
////1 sat/*1*/
////sat/*2*/
verify.baselineCompletions({
includeCompletionsForModuleExports: true,
});
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_satisfiesKeyword.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoNestedGenericCalls.ts_0_785 | /// <reference path='fourslash.ts' />
// @strict: true
//// /*1*/m({ foo: /*2*/$("foo") });
//// m({ foo: /*3*/$("foo") });
//// declare const m: <S extends string>(s: { [_ in S]: { $: NoInfer<S> } }) => void
//// declare const $: <S, T extends S>(s: T) => { $: S }
//// type NoInfer<T> = [T][T extends any ? 0 : never];
verify.quickInfoAt("1", `const m: <"foo">(s: {
foo: {
$: "foo";
};
}) => void`);
// the exact generic type params are not important in this test (they could change with changes to the inference algorithm)
// it's important though that they both display the same types
verify.quickInfoAt("2", `const $: <unknown, string>(s: string) => {
$: unknown;
}`);
verify.quickInfoAt("3", `const $: <unknown, string>(s: string) => {
$: unknown;
}`);
| {
"end_byte": 785,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoNestedGenericCalls.ts"
} |
TypeScript/tests/cases/fourslash/completionsNamespaceName.ts_0_490 | /// <reference path='fourslash.ts'/>
////{ namespace /*0*/ }
////namespace N/*1*/ {}
////namespace N.M {}
////namespace N./*2*/
////
////namespace N1.M/*3*/ {}
////namespace N2.M {}
////namespace N2.M/*4*/
verify.completions(
{ marker: ["0", "1"], isNewIdentifierLocation: true },
{ marker: "2", exact: ["M"], isNewIdentifierLocation: true },
{ marker: "3", exact: undefined, isNewIdentifierLocation: true },
{ marker: "4", exact: "M", isNewIdentifierLocation: true },
);
| {
"end_byte": 490,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsNamespaceName.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsParameterNames.ts_0_1245 | /// <reference path="fourslash.ts" />
//// function foo1 (a: number, b: number) {}
//// foo1(1, 2);
//// function foo2 (a: number, { c }: any) {}
//// foo2(1, { c: 1 });
////function foo3(a: any, b: number) {}
////foo3({}, 1);
////const foo3 = (a = 1) => class { }
////const C1 = class extends foo3(1) { }
////class C2 extends foo3(1) { }
////function foo4(a: number, b: number, c: number, d: number) {}
////foo4(1, +1, -1, +"1");
////function foo5(
//// a: string,
//// b: undefined,
//// c: null,
//// d: boolean,
//// e: boolean,
//// f: number,
//// g: number,
//// h: number,
//// i: RegExp,
//// j: bigint,
////) {
////}
////foo5(
//// "hello",
//// undefined,
//// null,
//// true,
//// false,
//// Infinity,
//// -Infinity,
//// NaN,
//// /hello/g,
//// 123n,
////);
//// declare const unknownCall: any;
//// unknownCall();
////function trace(message: string) {}
////trace(`${1}`);
////trace(``);
////function func(
//// param1: number,
//// param2: string,
//// param3: boolean,
////) {}
////const param1 = 1;
////func(
//// param1,
//// 'foo',
//// true,
////)
verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "literals" });
| {
"end_byte": 1245,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsParameterNames.ts"
} |
TypeScript/tests/cases/fourslash/completionListOnSuper.ts_0_359 | /// <reference path='fourslash.ts'/>
////class TAB<T>{
//// foo<T>(x: T) {
//// }
//// bar(a: number, b: number) {
//// }
////}
////
////class TAD<T> extends TAB<T> {
//// constructor() {
//// super();
//// }
//// bar(f: number) {
//// super./**/
//// }
////}
verify.completions({ marker: "", exact: ["bar", "foo"] });
| {
"end_byte": 359,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnSuper.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts_0_998 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////** @template T Parameter doc comment */
////function f() {}
////
/////**
//// * Doc
//// * @template T Comment
//// */
////function g() {}
////
/////**
//// * Doc
//// * @template T Comment
//// * @template U Comment
//// */
////function h() {}
////
/////**
//// * Doc
//// * @template T,U Comment
//// */
////function h2() {}
////
/////** @template T Comment @return {void} */
////function i() {}
////
/////**
////Doc
////@template T comment
////@template U comment
////@param {number} x
////*/
////function j(x) { return x; }
verify.codeFixAll({
fixId: "unusedIdentifier_delete",
fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message,
newFileContent:
`/** */
function f() {}
/**
* Doc
* */
function g() {}
/**
* Doc
* */
function h() {}
/**
* Doc
* */
function h2() {}
/** @return {void} */
function i() {}
/**
Doc
@param {number} x
*/
function j(x) { return x; }`,
});
| {
"end_byte": 998,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS1.ts_0_614 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} a
//// * @param {number} b
//// */
////function foo() {}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'a'" },
{ description: "Disable checking for this file" },
{ description: "Delete unused '@param' tag 'b'" },
{ description: "Disable checking for this file" },
]);
verify.codeFix({
description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "a"],
index: 0,
newFileContent:
`/**
* @param {number} b
*/
function foo() {}`,
});
| {
"end_byte": 614,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SemicolonNotSelected.ts_0_394 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////let x = /*a*/a && a.b && a.b.c/*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:
`let a = { b: { c: 0 } };
let x = a?.b?.c;`
}); | {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SemicolonNotSelected.ts"
} |
TypeScript/tests/cases/fourslash/convertLiteralTypeToMappedType1.ts_0_303 | /// <reference path='fourslash.ts' />
////type K = number | string;
////type T = {
//// [K]: number;
////}
verify.codeFix({
description: [ts.Diagnostics.Convert_0_to_1_in_0.message, "K", "P"],
index: 0,
newFileContent:
`type K = number | string;
type T = {
[P in K]: number;
}`
});
| {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertLiteralTypeToMappedType1.ts"
} |
TypeScript/tests/cases/fourslash/gotoDefinitionThrowsTag.ts_0_197 | ///<reference path="fourslash.ts" />
////class [|/*def*/E|] extends Error {}
////
/////**
//// * @throws {/*use*/[|E|]}
//// */
////function f() {}
verify.baselineGetDefinitionAtPosition("use");
| {
"end_byte": 197,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionThrowsTag.ts"
} |
TypeScript/tests/cases/fourslash/completionsOptionalKindModifier.ts_0_335 | /// <reference path="fourslash.ts" />
////interface A { a?: number; method?(): number; };
////function f(x: A) {
////x./*a*/;
////}
verify.completions({
marker: "a",
exact: [
{ name: "a", kind: "property", kindModifiers: "optional" },
{ name: "method", kind: "method", kindModifiers: "optional" },
],
});
| {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOptionalKindModifier.ts"
} |
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature2.ts_0_435 | /// <reference path='fourslash.ts'/>
// @noPropertyAccessFromIndexSignature: true
//// interface C {
//// foo: string
//// [k: string]: string
//// }
//// declare const c: C;
//// c.foo;
//// c.bar;
verify.codeFix({
description: [ts.Diagnostics.Use_element_access_for_0.message, 'bar'],
index: 0,
newFileContent:
`interface C {
foo: string
[k: string]: string
}
declare const c: C;
c.foo;
c["bar"];`,
});
| {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature2.ts"
} |
TypeScript/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath.ts_0_254 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////// leading trivia
////import * as foo from ""; // trailing trivia
verify.codeFix({
description: "Remove import from ''",
newFileContent:
`// leading trivia
// trailing trivia`,
});
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard5.ts_0_1186 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /node_modules/foo/package.json
//// {
//// "types": "index.d.ts",
//// "typesVersions": {
//// "*": {
//// "*": ["dist/*"],
//// "foo/*": ["dist/*"],
//// "bar/*": ["dist/*"],
//// "exact-match": ["dist/index.d.ts"]
//// }
//// }
//// }
// @Filename: /node_modules/foo/nope.d.ts
//// export const nope = 0;
// @Filename: /node_modules/foo/dist/index.d.ts
//// export const index = 0;
// @Filename: /node_modules/foo/dist/blah.d.ts
//// export const blah = 0;
// @Filename: /node_modules/foo/dist/foo/onlyInFooFolder.d.ts
//// export const foo = 0;
// @Filename: /node_modules/foo/dist/subfolder/one.d.ts
//// export const one = 0;
// @Filename: /a.ts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["blah", "index", "foo", "subfolder", "bar", "exact-match"],
});
edit.insert("foo/");
verify.completions({
isNewIdentifierLocation: true,
exact: ["blah", "index", "foo", "subfolder"],
});
edit.insert("foo/");
verify.completions({
isNewIdentifierLocation: true,
exact: ["onlyInFooFolder"],
});
| {
"end_byte": 1186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUseDefaultImport_all.ts_0_438 | /// <reference path='fourslash.ts' />
// @allowSyntheticDefaultImports: true
// @Filename: /a.d.ts
////declare const x: number;
////export = x;
// @Filename: /b.ts
////import * as [|a1|] from "./a";
////import [|a2|] = require("./a");
goTo.file("/b.ts");
verify.codeFixAll({
fixId: "useDefaultImport",
fixAllDescription: "Convert all to default imports",
newFileContent:
`import a1 from "./a";
import a2 from "./a";`,
});
| {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUseDefaultImport_all.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts_0_1041 | /// <reference path='fourslash.ts' />
// Should give completions for ambiently declared modules
// @Filename: test0.ts
//// /// <reference path="./ambientModules.d.ts" />
//// /// <reference path="./ambientModules2.d.ts" />
//// import * as foo1 from "/*import_as0*/
//// import * as foo2 from "a/*import_as1*/
//// import foo3 = require("/*import_equals0*/
//// import foo4 = require("a/*import_equals1*/
//// var foo5 = require("/*require0*/
//// var foo6 = require("a/*require1*/
// @Filename: ambientModules.d.ts
//// declare module "ambientModule" {}
//// declare module "otherAmbientModule" {}
// @Filename: ambientModules2.d.ts
//// declare module "otherOtherAmbientModule" {}
verify.completions({
marker: test.markerNames().filter(k => k.endsWith("0")),
exact: ["ambientModule", "otherAmbientModule", "otherOtherAmbientModule"],
isNewIdentifierLocation: true,
});
verify.completions({
marker: test.markerNames().filter(k => !k.endsWith("0")),
exact: "ambientModule",
isNewIdentifierLocation: true,
});
| {
"end_byte": 1041,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsUnicode1.ts_0_617 | /// <reference path="fourslash.ts" />
//// import {
//// Ab,
//// _aB,
//// aB,
//// _Ab,
//// } from './foo';
////
//// console.log(_aB, _Ab, aB, Ab);
verify.organizeImports(
`import {
Ab,
_Ab,
_aB,
aB,
} from './foo';
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "ordinal",
});
verify.organizeImports(
`import {
_aB,
_Ab,
aB,
Ab,
} from './foo';
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
});
| {
"end_byte": 617,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsUnicode1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsVar.ts_0_420 | /// <reference path='fourslash.ts'/>
////var /*1*/a = 10;
////function foo() {
//// var /*2*/b = /*3*/a;
////}
////module m {
//// var /*4*/c = 10;
//// export var /*5*/d = 10;
////}
////var /*6*/f: () => number;
////var /*7*/g = /*8*/f;
/////*9*/f();
////var /*10*/h: { (a: string): number; (a: number): string; };
////var /*11*/i = /*12*/h;
/////*13*/h(10);
/////*14*/h("hello");
verify.baselineQuickInfo(); | {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsVar.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked1.ts_0_406 | /// <reference path='fourslash.ts' />
//// export function fn(){
//// console.log('Hello')/*a*//*b*/
//// }
//// fn();
goTo.select("a", "b");
verify.refactorAvailableForTriggerReason("invoked", "Move to a new file",
/*actionName*/ undefined,
/*actionDescription*/ undefined,
/*kind*/ undefined,
{
allowTextChangesInNewFiles: true
},
/*includeInteractiveActions*/ true);
| {
"end_byte": 406,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked1.ts"
} |
TypeScript/tests/cases/fourslash/specialIntersectionsOrderIndependent.ts_0_253 | /// <reference path="fourslash.ts" />
//
//// declare function a(arg: 'test' | (string & {})): void
//// a('/*1*/')
//// declare function b(arg: 'test' | ({} & string)): void
//// b('/*2*/')
verify.completions({ marker: ["1", "2"], exact: ["test"] });
| {
"end_byte": 253,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/specialIntersectionsOrderIndependent.ts"
} |
TypeScript/tests/cases/fourslash/semicolonFormattingNestedStatements.ts_0_606 | /// <reference path='fourslash.ts' />
////if (true)
////if (true)/*parentOutsideBlock*/
////if (true) {
////if (true)/*directParent*/
////var x = 0/*innermost*/
////}
goTo.marker("innermost");
edit.insert(";");
// Adding semicolon should format the innermost statement
verify.currentLineContentIs(' var x = 0;');
// Also should format any parent statement that is terminated by the semicolon
goTo.marker("directParent");
verify.currentLineContentIs(' if (true)');
// But not parents that are not terminated by it
goTo.marker("parentOutsideBlock");
verify.currentLineContentIs('if (true)');
| {
"end_byte": 606,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormattingNestedStatements.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements5.ts_0_339 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////[|function f({
//// a,
//// b,
//// c,
////}: any)|] {
//// b;
//// c;
////}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'a'",
newRangeContent:
`function f({
b,
c,
}: any)`
});
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements5.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.