_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember11.ts_0_466
/// <reference path="./fourslash.ts"/> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitOverride: true // @filename: a.js ////class Foo { //// /*Foo_m*/m() {} ////} ////class Bar extends Foo { //// /** @[|over{|"name": "1"|}ride|][| se{|"name": "2"|}e {@li{|"name": "3"|}nk https://test.c{|"name": "4"|}om} {|"name": "5"|}description |]*/ //// m() {} ////} verify.baselineGoToDefinition( "1", "2", "3", "4", "5", );
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember11.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnVarInArrowExpression.ts_0_426
/// <reference path='fourslash.ts' /> ////interface IMap<T> { //// [key: string]: T; ////} ////var map: IMap<string[]>; ////var categories: string[]; ////each(categories, category => { //// var /*1*/changes = map[category]; //// return each(changes, change => { //// }); ////}); ////function each<T>(items: T[], handler: (item: T) => void) { } verify.quickInfoAt("1", "(local var) changes: string[]", undefined);
{ "end_byte": 426, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnVarInArrowExpression.ts" }
TypeScript/tests/cases/fourslash/javaScriptClass4.ts_0_512
///<reference path="fourslash.ts" /> // Classes have their shape inferred from assignments // to properties of 'this' in the constructor // @allowNonTsExtensions: true // @Filename: Foo.js //// class Foo { //// constructor() { //// /** //// * @type {string} //// */ //// this.baz = null; //// } //// } //// var x = new Foo(); //// x/**/ goTo.marker(); edit.insert('.baz.'); verify.completions({ includes: { name: "substring", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptClass4.ts" }
TypeScript/tests/cases/fourslash/completionImportMetaWithGlobalDeclaration.ts_0_562
/// <reference path='fourslash.ts' /> // Module: esnext // @Filename: a.ts ////import./*1*/ // @Filename: b.ts ////declare global { //// interface ImportMeta { //// url: string; //// } ////} ////import.meta./*2*/ // @Filename: c.ts ////import.meta./*3*/url // @Filename: d.ts ////import./*4*/meta verify.completions( { marker: "1", exact: "meta" }, { marker: "2", includes: ["url"], excludes: ["meta"] }, { marker: "3", includes: ["url"], excludes: ["meta"] }, { marker: "4", exact: "meta" } );
{ "end_byte": 562, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportMetaWithGlobalDeclaration.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesLinkTag1.ts_0_1392
/// <reference path="fourslash.ts" /> //// class C/*7*/ { //// m/*1*/() { } //// n/*2*/ = 1 //// static s/*3*/() { } //// /** //// * {@link m} //// * @see {m} //// * {@link C.m} //// * @see {C.m} //// * {@link C#m} //// * @see {C#m} //// * {@link C.prototype.m} //// * @see {C.prototype.m} //// */ //// p() { } //// /** //// * {@link n} //// * @see {n} //// * {@link C.n} //// * @see {C.n} //// * {@link C#n} //// * @see {C#n} //// * {@link C.prototype.n} //// * @see {C.prototype.n} //// */ //// q() { } //// /** //// * {@link s} //// * @see {s} //// * {@link C.s} //// * @see {C.s} //// */ //// r() { } //// } //// //// interface I/*8*/ { //// a/*4*/() //// b/*5*/: 1 //// /** //// * {@link a} //// * @see {a} //// * {@link I.a} //// * @see {I.a} //// * {@link I#a} //// * @see {I#a} //// */ //// c() //// /** //// * {@link b} //// * @see {b} //// * {@link I.b} //// * @see {I.b} //// */ //// d() //// } //// //// function nestor() { //// /** {@link r2} */ //// function ref() { } //// /** @see {r2} */ //// function d3() { } //// function r2/*6*/() { } //// } verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8')
{ "end_byte": 1392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesLinkTag1.ts" }
TypeScript/tests/cases/fourslash/formattingSpaceBeforeFunctionParen.ts_0_947
/// <reference path='fourslash.ts' /> /////*1*/function foo() { } /////*2*/function boo () { } /////*3*/var bar = function foo() { }; /////*4*/var foo = { bar() { } }; /////*5*/function tmpl <T> () { } /////*6*/var f = function*() { }; /////*7*/function* g () { } format.setOption("insertSpaceBeforeFunctionParenthesis", true); format.setOption("insertSpaceAfterFunctionKeywordForAnonymousFunctions", false); format.document(); goTo.marker('1'); verify.currentLineContentIs('function foo () { }'); goTo.marker('2'); verify.currentLineContentIs('function boo () { }'); goTo.marker('3'); verify.currentLineContentIs('var bar = function foo () { };'); goTo.marker('4'); verify.currentLineContentIs('var foo = { bar () { } };'); goTo.marker('5'); verify.currentLineContentIs('function tmpl<T> () { }'); goTo.marker('6'); verify.currentLineContentIs('var f = function*() { };'); goTo.marker('7'); verify.currentLineContentIs('function* g () { }');
{ "end_byte": 947, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingSpaceBeforeFunctionParen.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsInterfaceMembers.ts_0_353
/// <reference path='fourslash.ts'/> ////interface I { //// /*1*/property: string; //// /*2*/method(): string; //// (): string; //// new (): I; ////} ////var iInstance: I; /////*3*/iInstance./*4*/property = /*5*/iInstance./*6*/method(); /////*7*/iInstance(); ////var /*8*/anotherInstance = new /*9*/iInstance(); verify.baselineQuickInfo();
{ "end_byte": 353, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsInterfaceMembers.ts" }
TypeScript/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts_0_664
/// <reference path="fourslash.ts" /> // @module: esnext // @Filename: /b.d.ts ////declare namespace N { //// export const foo: number; ////} ////declare module "n" { //// export = N; ////} // @Filename: /c.d.ts ////declare namespace N {} // @Filename: /a.ts ////fo/**/ verify.completions({ marker: "", includes: { name: "foo", source: "n", sourceDisplay: "n", text: "const N.foo: number", kind: "const", kindModifiers: "export,declare", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, });
{ "end_byte": 664, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport17.ts_0_543
/// <reference path='fourslash.ts' /> // Should give completions for modules referenced via baseUrl and paths compiler options with explicit name mappings // @Filename: tsconfig.json //// { //// "compilerOptions": { //// "paths": { //// "module1/*": ["some/path/*"], //// } //// } //// } // @Filename: test0.ts //// import * as foo1 from "module1/w/*first*/ // @Filename: some/path/whatever.ts //// export {} verify.completions({ marker: ["first"], exact: "whatever", isNewIdentifierLocation: true });
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport17.ts" }
TypeScript/tests/cases/fourslash/genericMapTyping1.ts_0_1213
/// <reference path="fourslash.ts" /> ////interface Iterator_<T, U> { //// (value: T, index: any, list: any): U; ////} ////interface WrappedArray<T> { //// map<U>(iterator: Iterator_<T, U>, context?: any): U[]; ////} ////interface Underscore { //// <T>(list: T[]): WrappedArray<T>; //// map<T, U>(list: T[], iterator: Iterator_<T, U>, context?: any): U[]; ////} ////declare var _: Underscore; ////var aa: string[]; ////var b/*1*/b = _.map(aa, x/*7*/x => xx.length); // should be number[] ////var c/*2*/c = _(aa).map(x/*8*/x => xx.length); // should be number[] ////var d/*3*/d = aa.map(xx => x/*9*/x.length); // should be number[] ////var aaa: any[]; ////var b/*4*/bb = _.map(aaa, xx => xx.length); // should be any[] ////var c/*5*/cc = _(aaa).map(xx => xx.length); // Should not error, should be any[] ////var d/*6*/dd = aaa.map(xx => xx.length); // should not error, should be any[] verify.noErrors(); verify.quickInfos({ 1: "var bb: number[]", 2: "var cc: number[]", 3: "var dd: number[]", 4: "var bbb: any[]", 5: "var ccc: any[]", 6: "var ddd: any[]", 7: "(parameter) xx: string", 8: "(parameter) xx: string", 9: "(parameter) xx: string" });
{ "end_byte": 1213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericMapTyping1.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts_0_539
/// <reference path='fourslash.ts' /> ////abstract class C1 { } ////abstract class C2 { //// abstract fA<T extends number>(): T; ////} ////interface I1 extends C1, C2 { } ////class C3 implements I1 {[| |]} verify.codeFix({ description: "Implement interface 'I1'", newFileContent: `abstract class C1 { } abstract class C2 { abstract fA<T extends number>(): T; } interface I1 extends C1, C2 { } class C3 implements I1 { fA<T extends number>(): T { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization13.ts_0_273
/// <reference path='fourslash.ts' /> // @strict: true //// class TT { } //// //// class T { //// a: TT; //// } verify.codeFix({ description: `Add initializer to property 'a'`, newFileContent: `class TT { } class T { a: TT = new TT; }`, index: 2 })
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization13.ts" }
TypeScript/tests/cases/fourslash/javaScriptPrototype2.ts_0_1029
///<reference path="fourslash.ts" /> // Assignments to 'this' in the constructorish body create // properties with those names // @allowNonTsExtensions: true // @Filename: myMod.js //// function myCtor(x) { //// this.qua = 10; //// } //// myCtor.prototype.foo = function() { return 32 }; //// myCtor.prototype.bar = function() { return '' }; //// //// var m = new myCtor(10); //// m/*1*/ //// var x = m.qua; //// x/*2*/ //// myCtor/*3*/ // Verify the instance property exists goTo.marker('1'); edit.insert('.'); verify.completions({ includes: { name: "qua", kind: "property" } }); edit.backspace(); // Verify the type of the instance property goTo.marker('2'); edit.insert('.'); verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } }); goTo.marker('3'); edit.insert('.'); // Make sure symbols don't leak out into the constructor verify.completions({ includes: ["qua", "foo", "bar"].map(name => ({ name, kind: "warning", sortText: completion.SortText.JavascriptIdentifiers })) });
{ "end_byte": 1029, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptPrototype2.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts_0_239
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithSemanticErrors2.baseline // @declaration: true // @Filename: inputFile.ts // @emitThisFile: true //// var x:number = "hello world"; verify.baselineGetEmitOutput();
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts" }
TypeScript/tests/cases/fourslash/toggleMultilineComment1.ts_0_594
// Simple multiline comment and uncomment. //// let var1[| = 1; //// let var2 = 2; //// let var3 |]= 3; //// //// let var4/* = 1; //// let var5 [||]= 2; //// let var6 */= 3; //// //// [|/*let var7 = 1; //// let var8 = 2; //// let var9 = 3;*/|] //// //// let var10[||] = 10; //// //// [|let var11 = 11; //// let var12 = 12; //// |]let var13 = 13; verify.toggleMultilineComment( `let var1/* = 1; let var2 = 2; let var3 */= 3; let var4 = 1; let var5 = 2; let var6 = 3; let var7 = 1; let var8 = 2; let var9 = 3; let var10/**/ = 10; /*let var11 = 11; let var12 = 12; */let var13 = 13;`);
{ "end_byte": 594, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember11.ts_0_386
/// <reference path='fourslash.ts' /> ////enum E { //// a, //// b = 1, //// c = "123" ////} ////enum A { //// a = E.c ////} ////enum B { //// b = A.a ////} ////B.c verify.codeFix({ description: "Add missing enum member 'c'", newFileContent: `enum E { a, b = 1, c = "123" } enum A { a = E.c } enum B { b = A.a, c = "c" } B.c` });
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember11.ts" }
TypeScript/tests/cases/fourslash/completionListInClosedFunction02.ts_3_271
/ <reference path="fourslash.ts" /> ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string, c: typeof /*1*/) { //// } ////} verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"], });
{ "end_byte": 271, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedFunction02.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts_0_1300
/// <reference path="fourslash.ts"/> /////** //// * This is my function. //// * There are many like it, but this one is mine. //// */ ////function myFunction(/* x */ x: any) { //// var y = x ? x++ : ++x; ////} ////// end of file var firstCommentText = "\ /**\n\ * This is my function.\n\ * There are many like it, but this one is mine.\n\ */"; const c = classification("original"); verify.syntacticClassificationsAre( c.comment(firstCommentText), c.keyword("function"), c.identifier("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"), c.keyword("var"), c.identifier("y"), c.operator("="), c.identifier("x"), c.operator("?"), c.identifier("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.identifier("x"), c.punctuation(";"), c.punctuation("}"), c.comment("// end of file")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("function.declaration", "myFunction"), c2.semanticToken("parameter.declaration", "x"), c2.semanticToken("variable.declaration.local", "y"), c2.semanticToken("parameter", "x"), c2.semanticToken("parameter", "x"), c2.semanticToken("parameter", "x"), );
{ "end_byte": 1300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportPaths_withLeadingDotSlash.ts_0_403
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////[|foo|] // @Filename: /thisHasPathMapping.ts ////export function foo() {}; // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "baseUrl": ".", //// "paths": { //// "foo": ["././thisHasPathMapping"] //// } //// } ////} verify.importFixAtPosition([ `import { foo } from "foo"; foo` ]);
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportPaths_withLeadingDotSlash.ts" }
TypeScript/tests/cases/fourslash/switchIndenting.ts_0_165
/// <reference path='fourslash.ts' /> ////switch (null) { //// case 0: //// /**/ ////} goTo.marker(); edit.insert('case 1:\n'); verify.indentationIs(8);
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/switchIndenting.ts" }
TypeScript/tests/cases/fourslash/getCompletionEntryDetails.ts_0_616
/// <reference path="fourslash.ts" /> ////var ccc: number; ////var ddd: string; ////var aaa: number; ////var bbb: string; /////*1*/ const check = () => verify.completions({ includes: [ { name: "aaa", text: "var aaa: number" }, { name: "bbb", text: "var bbb: string" }, { name: "ccc", text: "var ccc: number" }, { name: "ddd", text: "var ddd: string" }, ], }); goTo.marker("1"); // Checking for completion details before edit should work check(); // Make an edit edit.insert("a"); edit.backspace(); // Checking for completion details after edit should work too check();
{ "end_byte": 616, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getCompletionEntryDetails.ts" }
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts_0_253
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @Filename: a.js ////[|// @ts-check|] ////var x = ""; ////x = 1; verify.rangeAfterCodeFix("// @ts-nocheck", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts" }
TypeScript/tests/cases/fourslash/signatureHelpWithInvalidArgumentList1.ts_0_158
/// <reference path='fourslash.ts' /> ////function foo(a) { } ////foo(hello my name /**/is verify.signatureHelp({ marker: "", text: "foo(a: any): void" });
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpWithInvalidArgumentList1.ts" }
TypeScript/tests/cases/fourslash/gotoDefinitionLinkTag4.ts_0_246
/// <reference path="fourslash.ts" /> // @filename: a.ts ////interface [|/*2*/Foo|] { //// foo: E.Foo; ////} // @Filename: b.ts ////enum E { //// /** {@link /*1*/[|Foo|]} */ //// Foo ////} verify.baselineGetDefinitionAtPosition("1");
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionLinkTag4.ts" }
TypeScript/tests/cases/fourslash/completionListOnVarBetweenModules.ts_0_271
/// <reference path='fourslash.ts' /> ////module M1 { //// export class C1 { //// } //// export class C2 { //// } ////} ////var x: M1./**/ ////module M2 { //// export class Test3 { //// } ////} verify.completions({ marker: "", exact: ["C1", "C2"] });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnVarBetweenModules.ts" }
TypeScript/tests/cases/fourslash/codeFixCannotFindModule_suggestion_falsePositive.ts_0_321
/// <reference path='fourslash.ts' /> // @moduleResolution: node // @resolveJsonModule: true // @strict: true // @Filename: /node_modules/foo/bar.json ////{ "a": 0 } // @Filename: /a.ts ////import abs = require([|"foo/bar.json"|]); ////abs; verify.noErrors(); goTo.file("/a.ts"); verify.getSuggestionDiagnostics([]);
{ "end_byte": 321, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModule_suggestion_falsePositive.ts" }
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns9.ts_0_955
/// <reference path="fourslash.ts" /> // @Filename: /src/vs/workbench/test.ts //// import { Parts } from './parts'; //// export class /**/EditorParts implements Parts { } // @Filename: /src/vs/event/event.ts //// export interface Event { //// (): string; //// } // @Filename: /src/vs/workbench/parts.ts //// import { Event } from '../event/event'; //// export interface Parts { //// readonly options: Event; //// } // @Filename: /src/vs/workbench/workbench.ts //// import { Event } from '../event/event'; //// export { Event }; // @Filename: /src/vs/test.ts //// import { Event } from './event/event'; //// export { Event }; verify.codeFix({ description: "Implement interface 'Parts'", newFileContent: `import { Event } from '../test'; import { Parts } from './parts'; export class EditorParts implements Parts { options: Event; }`, preferences: { autoImportFileExcludePatterns: ["src/vs/workbench/workbench*"], } });
{ "end_byte": 955, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns9.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts_0_192
/// <reference path='fourslash.ts' /> ////var x; ////var y = function* gen(p) { yield /*1*/ verify.completions({ marker: "1", includes: ["x", "y", "gen", "p", ...completion.globalsVars] });
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports40-extract-other-to-variable.ts_0_816
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @lib: es2019 // @Filename: /code.ts ////let c: string[] = []; ////export let o = { //// p: Math.random() ? []: [ //// ...c //// ] ////} verify.codeFix({ description: `Extract to variable and replace with 'newLocal as typeof newLocal'`, applyChanges: true, index: 2, newFileContent: `let c: string[] = []; const newLocal = Math.random() ? [] : [ ...c ]; export let o = { p: newLocal as typeof newLocal }` }); verify.codeFix({ description: `Add annotation of type 'string[]'`, applyChanges: true, index: 0, newFileContent: `let c: string[] = []; const newLocal: string[] = Math.random() ? [] : [ ...c ]; export let o = { p: newLocal as typeof newLocal }` });
{ "end_byte": 816, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports40-extract-other-to-variable.ts" }
TypeScript/tests/cases/fourslash/partialUnionPropertyCacheInconsistentErrors.ts_0_1032
/// <reference path="fourslash.ts" /> // @strict: true // @lib: esnext //// interface ComponentOptions<Props> { //// setup?: (props: Props) => void; //// name?: string; //// } //// //// interface FunctionalComponent<P> { //// (props: P): void; //// } //// //// type ConcreteComponent<Props> = //// | ComponentOptions<Props> //// | FunctionalComponent<Props>; //// //// type Component<Props = {}> = ConcreteComponent<Props>; //// //// type WithInstallPlugin = { _prefix?: string }; //// //// //// /**/ //// export function withInstall<C extends Component, T extends WithInstallPlugin>( //// component: C | C[], //// target?: T, //// ): string { //// const componentWithInstall = (target ?? component) as T; //// const components = Array.isArray(component) ? component : [component]; //// //// const { name } = components[0]; //// if (name) { //// return name; //// } //// //// return ""; //// } verify.noErrors(); goTo.marker(); edit.insert("type C = Component['name']"); verify.noErrors();
{ "end_byte": 1032, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/partialUnionPropertyCacheInconsistentErrors.ts" }
TypeScript/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts_0_190
/// <reference path='fourslash.ts'/> //// module Foo { var testing = ""; test/**/ } verify.completions({ marker: "", includes: { name: "testing", text: "var testing: string" } });
{ "end_byte": 190, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts" }
TypeScript/tests/cases/fourslash/quickInfoInheritedLinkTag.ts_0_462
///<reference path="fourslash.ts" /> //// export class C { //// /** //// * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. //// */ //// m() { } //// } //// export class D extends C { //// m() { } // crashes here //// } //// new C().m/**/ // and here (with a different thing trying to access undefined) verify.noErrors() verify.baselineQuickInfo();
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInheritedLinkTag.ts" }
TypeScript/tests/cases/fourslash/indentAfterFunctionClosingBraces.ts_0_288
/// <reference path="fourslash.ts"/> ////class foo { //// public f() { //// return 0; //// /*1*/}/*2*/ ////} goTo.marker('2'); edit.insertLine(""); goTo.marker('1'); // Verify indentation level is correct after Format-on-Enter is called verify.currentLineContentIs(" }");
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentAfterFunctionClosingBraces.ts" }
TypeScript/tests/cases/fourslash/unusedFunctionInNamespaceWithTrivia.ts_0_291
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| namespace greeter { //// // Do not remove //// /** //// * JSDoc Comment //// */ //// function function1() { //// }/*1*/ //// } |] verify.rangeAfterCodeFix(`namespace greeter { // Do not remove }`);
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedFunctionInNamespaceWithTrivia.ts" }
TypeScript/tests/cases/fourslash/referencesForObjectLiteralProperties.ts_0_246
/// <reference path='fourslash.ts'/> // References to an object literal property ////var x = { /*1*/add: 0, b: "string" }; ////x["/*2*/add"]; ////x./*3*/add; ////var y = x; ////y./*4*/add; verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForObjectLiteralProperties.ts" }
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations3.ts_0_515
/// <reference path='fourslash.ts'/> // class and uninstantiated module ////[|class /*class*/[|testClass|] { //// static staticMethod() { } //// method() { } ////}|] //// ////[|module /*module*/[|testClass|] { //// export interface Bar { //// //// } ////}|] //// ////var c1: [|testClass|]; ////var c2: [|testClass|].Bar; ////[|testClass|].staticMethod(); ////[|testClass|].prototype.method(); ////[|testClass|].bind(this); ////new [|testClass|](); verify.baselineFindAllReferences('module', 'class')
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations3.ts" }
TypeScript/tests/cases/fourslash/jsdocImplementsTagCompletion.ts_0_169
///<reference path="fourslash.ts" /> /////** @implements {/**/} */ ////class A {} verify.completions( { marker: "", exact: completion.globalTypesPlus(["A"]) }, );
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocImplementsTagCompletion.ts" }
TypeScript/tests/cases/fourslash/refactorKind_rewriteExport.ts_0_201
/// <reference path='fourslash.ts' /> //// /*a*/export function f() {}/*b*/ goTo.select("a", "b"); verify.refactorKindAvailable("refactor.rewrite.export", [ "refactor.rewrite.export.default" ]);
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteExport.ts" }
TypeScript/tests/cases/fourslash/moveToFile_requireImport.ts_0_753
/// <reference path='fourslash.ts' /> // @module: commonjs // @allowJs: true //@Filename: /bar.js ////const x = 0; //@Filename: /a.js ////const { a, b } = require("./other"); ////const p = 0; ////[|const y = p; ////const z = 0; ////exports.z = 0;|] ////a; y; z; //@Filename: /other.js ////const a = 1; ////exports.a = a; //@Filename: /user.ts ////const { x, y } = require("./a"); verify.moveToFile({ newFileContents: { "/a.js": `const { y, z } = require("./bar"); const { a, b } = require("./other"); const p = 0; exports.p = p; a; y; z;`, "/bar.js": `const { p } = require("./a"); const x = 0; const y = p; exports.y = y; const z = 0; exports.z = 0; `, }, interactiveRefactorArguments: { targetFile: "/bar.js" } });
{ "end_byte": 753, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_requireImport.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember3.ts_0_317
/// <reference path='fourslash.ts' /> ////class C { //// static method() { //// this.foo = 10; //// } ////} verify.codeFix({ description: "Declare static property 'foo'", index: 0, newFileContent: `class C { static foo: number; static method() { this.foo = 10; } }` });
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember3.ts" }
TypeScript/tests/cases/fourslash/codeFixNegativeReplaceQualifiedNameWithIndexedAccessType01.ts_0_216
/// <reference path='fourslash.ts' /> //// namespace Container { //// export interface Foo { //// bar: string; //// } //// } //// const x: [|Container.Foo.bar|] = "" verify.not.codeFixAvailable();
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNegativeReplaceQualifiedNameWithIndexedAccessType01.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses17.ts_0_460
/// <reference path='fourslash.ts'/> // @strictNullChecks: true ////function foo(fn: () => boolean) { //// 1 && fn/**/ && 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(fn: () => boolean) { 1 && fn() && console.log('test'); }`, });
{ "end_byte": 460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses17.ts" }
TypeScript/tests/cases/fourslash/unusedLocalsInMethodFS1.ts_0_324
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////class greeter { //// public function1() { //// [| var /*0*/x,/*1*/ y = 10; |] //// use(y); //// } ////} verify.rangeAfterCodeFix("var y = 10;", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
{ "end_byte": 324, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedLocalsInMethodFS1.ts" }
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag1.ts_0_1488
/// <reference path="fourslash.ts" /> // @strict: true // @filename: /foobar.ts //// /** @deprecated */ //// export function foobar() {} // @filename: /foo.ts //// import { foobar/*4*/ } from "./foobar"; //// //// /** @deprecated */ //// interface Foo { //// /** @deprecated */ //// bar(): void //// /** @deprecated */ //// prop: number //// } //// declare const foo: Foo; //// declare const foooo: Fo/*1*/; //// foo.ba/*2*/; //// foo.pro/*3*/; //// //// fooba/*5*/; verify.completions({ marker: "1", includes: [ { name: "Foo", kind: "interface", kindModifiers: "deprecated", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) } ] }, { marker: "2", includes: [ { name: "bar", kind: "method", kindModifiers: "deprecated", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) } ] }, { marker: "3", includes: [ { name: "prop", kind: "property", kindModifiers: "deprecated", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) } ] }, { marker: "4", includes: [ { name: "foobar", kind: "function", kindModifiers: "export,deprecated", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) } ] }, { marker: "5", includes: [ { name: "foobar", kind: "alias", kindModifiers: "export,deprecated", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) } ] });
{ "end_byte": 1488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag1.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocGetterSetterNoCrash1.ts_0_412
/// <reference path="fourslash.ts" /> // https://github.com/microsoft/TypeScript/issues/60024 //// class A implements A { //// get x(): string { return "" } //// } //// const e = new A() //// e.x/*1*/ //// //// class B implements B { //// set x(v: string) {} //// } //// const f = new B() //// f.x/*2*/ verify.quickInfoAt("1", "(property) A.x: string"); verify.quickInfoAt("2", "(property) B.x: string");
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocGetterSetterNoCrash1.ts" }
TypeScript/tests/cases/fourslash/formattingTemplatesWithNewline.ts_0_138
/// <reference path="fourslash.ts" /> ////`${1}`; ////` ////`;/**/1 goTo.marker(); edit.insert('\n'); verify.currentLineContentIs("1");
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingTemplatesWithNewline.ts" }
TypeScript/tests/cases/fourslash/uncommentSelection1.ts_0_755
// Simple comment selection cases. //// //let var1[| = 1; //// //let var2 = 2; //// //let var3 |]= 3; //// //// //let var4[| = 4; //// /*let var5 = 5;*/ //// //let var6 = 6; //// //// let var7 |]= 7; //// //// let var8/* = 1; //// let var9 [||]= 2; //// let var10 */= 3; //// //// let var11[||]/* = 1; //// let var12 = 2; //// let var13 */= 3; //// //// ////let var14 [||]= 14; //// //// [|//let var15 = 15; //// //let var16 = 16; //// |]//let var17 = 17; verify.uncommentSelection( `let var1 = 1; let var2 = 2; let var3 = 3; let var4 = 4; let var5 = 5; let var6 = 6; let var7 = 7; let var8 = 1; let var9 = 2; let var10 = 3; let var11 = 1; let var12 = 2; let var13 = 3; //let var14 = 14; let var15 = 15; let var16 = 16; //let var17 = 17;`);
{ "end_byte": 755, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/uncommentSelection1.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingCaseSensitive1.ts_0_153
/// <reference path='fourslash.ts' /> ////export let Console = 1; ////export let console = 1; ////[|conole|] = 1; verify.rangeAfterCodeFix('console');
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingCaseSensitive1.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics2.ts_0_132
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////export = b; verify.baselineSyntacticDiagnostics();
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics2.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsDocComment4.ts_0_777
/// <reference path="fourslash.ts"/> //// /** @param {number} p1 */ //// function foo(p1) {} const c = classification("original"); verify.syntacticClassificationsAre( c.comment("/** "), c.punctuation("@"), c.docCommentTagName("param"), c.comment(" "), c.punctuation("{"), c.keyword("number"), c.punctuation("}"), c.comment(" "), c.parameterName("p1"), c.comment(" */"), c.keyword("function"), c.identifier("foo"), c.punctuation("("), c.parameterName("p1"), c.punctuation(")"), c.punctuation("{"), c.punctuation("}")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("function.declaration", "foo"), c2.semanticToken("parameter.declaration", "p1"), );
{ "end_byte": 777, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsDocComment4.ts" }
TypeScript/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts_0_336
/// <reference path="fourslash.ts" /> // @module: CommonJS // @declaration: true //// export function /*1*/foo/*2*/() { //// interface privateInterface {} //// class Bar implements privateInterface { private a; } //// return Bar; //// } verify.errorExistsBetweenMarkers("1", "2"); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts" }
TypeScript/tests/cases/fourslash/completionsImport_ofAlias.ts_0_1169
/// <reference path="fourslash.ts" /> // Tests that we don't filter out a completion for an alias, // so long as it's not an alias to a different module. // @module: esnext // @Filename: /a.ts ////const foo = 0; ////export { foo }; // @Filename: /a_reexport.ts // Should not show up in completions ////export { foo } from "./a"; // @Filename: /a_reexport_2.ts ////export * from "./a"; // @Filename: /a_reexport_3.ts ////export { foo } from "./a_reexport"; // @Filename: /b.ts ////fo/**/ verify.completions({ marker: "", includes: [ completion.undefinedVarEntry, { name: "foo", source: "/a", sourceDisplay: "./a", text: "(alias) const foo: 0\nexport foo", kind: "alias", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, ...completion.statementKeywordsWithTypes, ], preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Add import from "./a"`, newFileContent: `import { foo } from "./a"; fo`, });
{ "end_byte": 1169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_ofAlias.ts" }
TypeScript/tests/cases/fourslash/satisfiesOperatorCompletion.ts_0_155
/// <reference path="fourslash.ts" /> //// type T = number; //// var x; //// var y = x satisfies /**/ verify.completions({ marker: "", includes: "T" });
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/satisfiesOperatorCompletion.ts" }
TypeScript/tests/cases/fourslash/smartIndentObjectLiteralOpenBracketNewLine.ts_0_476
/// <reference path='fourslash.ts'/> //// var a =/*1*/ //// {/*2*/} //// //// var b = { //// outer:/*3*/ //// {/*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", 4); verifyIndentationAfterNewLine("4", 8);
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentObjectLiteralOpenBracketNewLine.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess6.ts_0_505
/// <reference path='fourslash.ts' /> ////class A { //// /*a*/public _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 _a: string; public get /*RENAME*/a(): string { return this._a; } public set a(value: string) { this._a = value; } }`, });
{ "end_byte": 505, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess6.ts" }
TypeScript/tests/cases/fourslash/functionTypeFormatting.ts_0_204
/// <reference path='fourslash.ts' /> //// var x: () => string/**/ goTo.marker(); edit.insert(';'); // formatting on function return type verify.currentLineContentIs('var x: () => string;');
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionTypeFormatting.ts" }
TypeScript/tests/cases/fourslash/moduleRenamingErrorRecovery.ts_0_280
/// <reference path="fourslash.ts" /> ////module Alpha/*1*//*2*/ { class Foo { public bar() { } } } goTo.marker("1"); edit.backspace(5); edit.insert("Pizza"); verify.currentLineContentIs("module Pizza { class Foo { public bar() { } } }"); verify.not.errorExistsAfterMarker("2");
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleRenamingErrorRecovery.ts" }
TypeScript/tests/cases/fourslash/callHierarchyExportEqualsFunction.ts_0_393
/// <reference path="fourslash.ts" /> // @filename: main.ts //// import bar = require("./other"); //// //// function foo() { //// bar(); //// } // @filename: other.ts //// export = /**/function () { //// baz(); //// } //// //// function baz() { //// } // NOTE: exported function is unnamed, so we expand the item to the entire file... goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 393, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyExportEqualsFunction.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType6.ts_0_356
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface Foo { } //// interface SomeType extends Foo { //// [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; interface Foo { } type SomeType = Foo & { [prop in K]: any; };` })
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType6.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_shortenRelativePaths.ts_0_309
/// <reference path='fourslash.ts' /> // @Filename: /src/foo/x.ts //// // @Filename: /src/old.ts ////import { x } from "./foo/x"; verify.getEditsForFileRename({ oldPath: "/src/old.ts", newPath: "/src/foo/new.ts", newFileContents: { "/src/old.ts": `import { x } from "./x";`, }, });
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_shortenRelativePaths.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_module_blankCompilerOptionsInTsConfig.ts_0_327
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; ////export {}; // @filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// } ////} // Cannot fix module when default module option is `commonjs`... verify.not.codeFixAvailable("fixModuleOption");
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_module_blankCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/completionTypeofExpressions.ts_0_286
/// <reference path="fourslash.ts" /> //// const x = "str"; //// function test(arg: typeof x./*1*/) {} //// function test1(arg: typeof (x./*2*/)) {} verify.completions({ marker: "1", includes: ['length'] }); verify.completions({ marker: "2", includes: ['length'] });
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionTypeofExpressions.ts" }
TypeScript/tests/cases/fourslash/unusedImports6FS.ts_0_335
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @Filename: file2.ts //// [| import d from "./file1" |] // @Filename: file1.ts //// export class Calculator { //// handleChar() { } //// } //// export function test() { //// //// } //// export default function test2() { //// //// } verify.rangeAfterCodeFix('');
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports6FS.ts" }
TypeScript/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral3.ts_0_211
/// <reference path="fourslash.ts"/> //// const foo = 1; //// const bar = 2; //// const obj = { //// foo b/*1*/ verify.completions({ marker: ["1"], exact: completion.globalsPlus(["bar", "foo"]), });
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral3.ts" }
TypeScript/tests/cases/fourslash/intellisenseInObjectLiteral.ts_0_206
/// <reference path="fourslash.ts"/> //// var x = 3; //// //// class Foo { //// static something() { //// return { "prop": /**/x }; //// } //// } verify.quickInfoAt("", "var x: number");
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/intellisenseInObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription5.ts_0_340
///<reference path="fourslash.ts" /> //// interface Multiple1Example { //// /** Something generic */ //// [key: number | symbol | `data-${string}` | `data-${number}`]: string; //// } //// function multiple1Example(e: Multiple1Example) { //// console.log(e./*multiple1*/anything); //// } verify.quickInfoAt("multiple1", "any");
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription5.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_fileNameBasedOnExportedName.ts_0_636
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////[|type Props = { //// a: number; ////} ////class Foo { //// readonly a: number; //// constructor({ a }: Props) { //// this.a = a; //// } ////}|] //// ////export default function f() { //// return new Foo({ a: 1 }); ////} verify.moveToNewFile({ newFileContents: { "/a.ts": `import { Foo } from "./Foo"; export default function f() { return new Foo({ a: 1 }); }`, "/Foo.ts": `type Props = { a: number; }; export class Foo { readonly a: number; constructor({ a }: Props) { this.a = a; } } `, }, });
{ "end_byte": 636, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_fileNameBasedOnExportedName.ts" }
TypeScript/tests/cases/fourslash/findAllRefsOfConstructor2.ts_0_450
/// <reference path="fourslash.ts" /> ////class A { //// /*a*/constructor(s: string) {} ////} ////class B extends A { //// /*b*/constructor() { super(""); } ////} ////class C extends B { //// /*c*/constructor() { //// super(); //// } ////} ////class D extends B { } ////const a = new A("a"); ////const b = new B(); ////const c = new C(); ////const d = new D(); verify.noErrors(); verify.baselineFindAllReferences('a', 'b', 'c')
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOfConstructor2.ts" }
TypeScript/tests/cases/fourslash/tsxCompletionsGenericComponent.ts_0_659
/// <reference path="fourslash.ts" /> // @jsx: preserve // @skipLibCheck: true // @Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// ////class Table<P> { //// constructor(public props: P) {} ////} //// ////type Props = { widthInCol: number; text: string; }; //// /////** //// * @param width {number} Table width in px //// */ ////function createTable(width) { //// return <Table<Props> /*1*/ /> ////} //// ////createTable(800); verify.completions({ marker: "1", includes: ["widthInCol", "text"] });
{ "end_byte": 659, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionsGenericComponent.ts" }
TypeScript/tests/cases/fourslash/completionsJsxExpression.ts_0_749
/// <reference path="fourslash.ts" /> // @Filename: /a.tsx // @jsx: react //// declare namespace JSX { //// interface IntrinsicElements { //// div: { a: string, b: string } //// } //// } //// const value = "test"; //// <div a={v/**/} /> verify.completions( { marker: "", isNewIdentifierLocation: false, preferences: { includeCompletionsWithSnippetText: true, includeCompletionsWithInsertText: true, jsxAttributeCompletionStyle: "auto", }, includes: { name: "value", kind: "const", kindModifiers: "", sortText: completion.SortText.LocationPriority, insertText: undefined, }, }, );
{ "end_byte": 749, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsxExpression.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember.ts_0_289
/// <reference path='fourslash.ts' /> ////class C { //// method() { //// this.foo = 10; //// } ////} verify.codeFix({ description: "Declare property 'foo'", index: 0, newFileContent: `class C { foo: number; method() { this.foo = 10; } }` });
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts_0_567
/// <reference path='fourslash.ts'/> ////enum /*1*/E { //// /*2*/e1, //// /*3*/e2 = 10, //// /*4*/e3 ////} ////var /*5*/eInstance: /*6*/E; /////*7*/eInstance = /*8*/E./*9*/e1; /////*10*/eInstance = /*11*/E./*12*/e2; /////*13*/eInstance = /*14*/E./*15*/e3; ////const enum /*16*/constE { //// /*17*/e1, //// /*18*/e2 = 10, //// /*19*/e3 ////} ////var /*20*/eInstance1: /*21*/constE; /////*22*/eInstance1 = /*23*/constE./*24*/e1; /////*25*/eInstance1 = /*26*/constE./*27*/e2; /////*28*/eInstance1 = /*29*/constE./*30*/e3; verify.baselineQuickInfo();
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedLabel_all.ts_0_329
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////label1: while (1) {} //// ////function f() { ////label2: //// while (1) {} ////} verify.codeFixAll({ fixId: "fixUnusedLabel", fixAllDescription: "Remove all unused labels", newFileContent: `while (1) {} function f() { while (1) {} }`, });
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedLabel_all.ts" }
TypeScript/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts_0_1223
/// <reference path="fourslash.ts"/> ////module /*0*/M { //// export interface /*1*/I { //// } //// var x = 10; ////} //// ////var /*2*/M = { //// foo: 10, //// bar: 20 ////} //// ////var v: /*3*/M./*4*/I; //// ////var x = /*5*/M; const c = classification("original"); verify.semanticClassificationsAre("original", c.moduleName("M", test.marker("0").position), c.interfaceName("I", test.marker("1").position), c.moduleName("M", test.marker("3").position), c.interfaceName("I", test.marker("4").position), c.moduleName("M", test.marker("5").position)); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("namespace.declaration", "M"), c2.semanticToken("interface.declaration", "I"), c2.semanticToken("variable.declaration.local", "x"), c2.semanticToken("variable.declaration", "M"), c2.semanticToken("property.declaration", "foo"), c2.semanticToken("property.declaration", "bar"), c2.semanticToken("variable.declaration", "v"), c2.semanticToken("namespace", "M"), c2.semanticToken("interface", "I"), c2.semanticToken("variable.declaration", "x"), c2.semanticToken("namespace", "M"), );
{ "end_byte": 1223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts" }
TypeScript/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts_0_534
/// <reference path='fourslash.ts'/> ////class C { //// static m() { } ////} //// ////class D extends C {} ////namespace D { //// export type T = number; ////} //// ////let x: D./*type*/; ////D./*value*/ verify.completions( { marker: "type", exact: "T" }, { marker: "value", exact: completion.functionMembersPlus([ { name: "m", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]) }, );
{ "end_byte": 534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc24.ts_0_674
/// <reference path="fourslash.ts" /> // @strict: true ////class C { //// /** //// * @private //// * @param {number} foo //// * @param {Object} [bar] //// * @param {String} bar.a //// * @param {Number} [bar.b] //// * @param bar.c //// */ //// m(foo, bar) { } ////} verify.codeFix({ description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message, index: 2, newFileContent: `class C { /** * @private * @param {number} foo * @param {Object} [bar] * @param {String} bar.a * @param {Number} [bar.b] * @param bar.c */ m(foo: number, bar: { a: string; b?: number; c: any; }) { } }`, });
{ "end_byte": 674, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc24.ts" }
TypeScript/tests/cases/fourslash/commentsInterfaceFourslash.ts_0_5316
/// <reference path='fourslash.ts' /> /////** this is interface 1*/ ////interface i/*1*/1 { ////} ////var i1/*2*/_i: i1; ////interface nc_/*3*/i1 { ////} ////var nc_/*4*/i1_i: nc_i1; /////** this is interface 2 with members*/ ////interface i/*5*/2 { //// /** this is x*/ //// x: number; //// /** this is foo*/ //// foo: (/**param help*/b: number) => string; //// /** this is indexer*/ //// [/**string param*/i: string]: number; //// /**new method*/ //// new (/** param*/i: i1); //// nc_x: number; //// nc_foo: (b: number) => string; //// [i: number]: number; //// /** this is call signature*/ //// (/**paramhelp a*/a: number,/**paramhelp b*/ b: number) : number; //// /** this is fnfoo*/ //// fnfoo(/**param help*/b: number): string; //// nc_fnfoo(b: number): string; ////} ////var i2/*6*/_i: /*34i*/i2; ////var i2_i/*7*/_x = i2_i./*8*/x; ////var i2_i/*9*/_foo = i2_i.f/*10*/oo; ////var i2_i_f/*11*/oo_r = i2_i.f/*12q*/oo(/*12*/30); ////var i2_i_i2_/*13*/si = i2/*13q*/_i["hello"]; ////var i2_i_i2/*14*/_ii = i2/*14q*/_i[30]; ////var i2_/*15*/i_n = new i2/*16q*/_i(/*16*/i1_i); ////var i2_i/*17*/_nc_x = i2_i.n/*18*/c_x; ////var i2_i_/*19*/nc_foo = i2_i.n/*20*/c_foo; ////var i2_i_nc_f/*21*/oo_r = i2_i.nc/*22q*/_foo(/*22*/30); ////var i2/*23*/_i_r = i2/*24q*/_i(/*24*/10, /*25*/20); ////var i2_i/*26*/_fnfoo = i2_i.fn/*27*/foo; ////var i2_i_/*28*/fnfoo_r = i2_i.fn/*29q*/foo(/*29*/10); ////var i2_i/*30*/_nc_fnfoo = i2_i.nc_fn/*31*/foo; ////var i2_i_nc_/*32*/fnfoo_r = i2_i.nc/*33q*/_fnfoo(/*33*/10); /////*34*/ ////interface i3 { //// /** Comment i3 x*/ //// x: number; //// /** Function i3 f*/ //// f(/**number parameter*/a: number): string; //// /** i3 l*/ //// l: (/**comment i3 l b*/b: number) => string; //// nc_x: number; //// nc_f(a: number): string; //// nc_l: (b: number) => string; ////} ////var i3_i: i3; ////i3_i = { //// /*35*/f: /**own f*/ (/**i3_i a*/a: number) => "Hello" + /*36*/a, //// l: this./*37*/f, //// /** own x*/ //// x: this.f(/*38*/10), //// nc_x: this.l(/*39*/this.x), //// nc_f: this.f, //// nc_l: this.l ////}; /////*40*/i/*40q*/3_i./*41*/f(/*42*/10); ////i3_i./*43q*/l(/*43*/10); ////i3_i.nc_/*44q*/f(/*44*/10); ////i3_i.nc/*45q*/_l(/*45*/10); verify.quickInfos({ 1: ["interface i1", "this is interface 1"], 2: "var i1_i: i1", 3: "interface nc_i1", 4: "var nc_i1_i: nc_i1", 5: ["interface i2", "this is interface 2 with members"], 6: "var i2_i: i2", 7: "var i2_i_x: number" }); verify.quickInfoAt("8", "(property) i2.x: number", "this is x"); verify.completions({ marker: "8", exact: completion.functionMembersWithPrototypePlus([ { name: "x", text: "(property) i2.x: number", documentation: "this is x" }, { name: "foo", text: "(property) i2.foo: (b: number) => string", documentation: "this is foo" }, { name: "nc_x", text: "(property) i2.nc_x: number" }, { name: "nc_foo", text: "(property) i2.nc_foo: (b: number) => string" }, { name: "fnfoo", text: "(method) i2.fnfoo(b: number): string", documentation: "this is fnfoo" }, { name: "nc_fnfoo", text: "(method) i2.nc_fnfoo(b: number): string" }, ]), isNewIdentifierLocation: true, }); verify.quickInfos({ 9: "var i2_i_foo: (b: number) => string", 10: ["(property) i2.foo: (b: number) => string", "this is foo"], 11: "var i2_i_foo_r: string" }); verify.signatureHelp({ marker: "12", docComment: "", parameterDocComment: "param help" }); verify.quickInfos({ "12q": ["(property) i2.foo: (b: number) => string", "this is foo"], 13: "var i2_i_i2_si: number", "13q": "var i2_i: i2", 14: "var i2_i_i2_ii: number", "14q": "var i2_i: i2", 15: "var i2_i_n: any" }); verify.signatureHelp({ marker: "16", docComment: "new method", parameterDocComment: "param" }); verify.quickInfos({ "16q": ["var i2_i: i2\nnew (i: i1) => any", "new method"], 17: "var i2_i_nc_x: number", 18: "(property) i2.nc_x: number", 19: "var i2_i_nc_foo: (b: number) => string", 20: "(property) i2.nc_foo: (b: number) => string", 21: "var i2_i_nc_foo_r: string" }); verify.signatureHelp({ marker: "22", docComment: "" }); verify.quickInfos({ "22q": "(property) i2.nc_foo: (b: number) => string", 23: "var i2_i_r: number" }); verify.signatureHelp({ marker: "24", docComment: "this is call signature", parameterDocComment: "paramhelp a" }); verify.quickInfoAt("24q", "var i2_i: i2\n(a: number, b: number) => number", "this is call signature"); verify.signatureHelp({ marker: "25", docComment: "this is call signature", parameterDocComment: "paramhelp b" }); verify.quickInfos({ 26: "var i2_i_fnfoo: (b: number) => string", 27: ["(method) i2.fnfoo(b: number): string", "this is fnfoo"], 28: "var i2_i_fnfoo_r: string" }); verify.signatureHelp({ marker: "29", docComment: "this is fnfoo", parameterDocComment: "param help" }); verify.quickInfos({ "29q": ["(method) i2.fnfoo(b: number): string", "this is fnfoo"], 30: "var i2_i_nc_fnfoo: (b: number) => string", 31: "(method) i2.nc_fnfoo(b: number): string", 32: "var i2_i_nc_fnfoo_r: string" }); verify.signatureHelp({ marker: "33", docComment: "" }); verify.quickInfoAt("33q", "(method) i2.nc_fnfoo(b: number): string");
{ "end_byte": 5316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsInterfaceFourslash.ts" }
TypeScript/tests/cases/fourslash/commentsInterfaceFourslash.ts_5318_8393
verify.completions( { marker: "34", includes: [ { name: "i1_i", text: "var i1_i: i1" }, { name: "nc_i1_i", text: "var nc_i1_i: nc_i1", documentation: "" }, { name: "i2_i", text: "var i2_i: i2" }, { name: "i2_i_x", text: "var i2_i_x: number" }, { name: "i2_i_foo", text: "var i2_i_foo: (b: number) => string" }, { name: "i2_i_foo_r", text: "var i2_i_foo_r: string" }, { name: "i2_i_i2_si", text: "var i2_i_i2_si: number" }, { name: "i2_i_i2_ii", text: "var i2_i_i2_ii: number" }, { name: "i2_i_n", text: "var i2_i_n: any" }, { name: "i2_i_nc_x", text: "var i2_i_nc_x: number" }, { name: "i2_i_nc_foo", text: "var i2_i_nc_foo: (b: number) => string" }, { name: "i2_i_nc_foo_r", text: "var i2_i_nc_foo_r: string" }, { name: "i2_i_r", text: "var i2_i_r: number" }, { name: "i2_i_fnfoo", text: "var i2_i_fnfoo: (b: number) => string" }, { name: "i2_i_fnfoo_r", text: "var i2_i_fnfoo_r: string" }, { name: "i2_i_nc_fnfoo", text: "var i2_i_nc_fnfoo: (b: number) => string" }, { name: "i2_i_nc_fnfoo_r", text: "var i2_i_nc_fnfoo_r: string" }, ], excludes: ["i1", "nc_i1", "i2"], }, { marker: "34i", includes: [ { name: "i1", text: "interface i1", documentation: "this is interface 1" }, { name: "nc_i1", text: "interface nc_i1" }, { name: "i2", text: "interface i2", documentation: "this is interface 2 with members" }, ], }, { marker: "36", includes: { name: "a", text: "(parameter) a: number", documentation: "i3_i a" }, } ); verify.quickInfoAt("40q", "var i3_i: i3"); verify.completions({ marker: "40", includes: { name: "i3_i", text: "var i3_i: i3" }, excludes: "i3" }); goTo.marker('41'); verify.quickInfoIs("(method) i3.f(a: number): string", "Function i3 f"); verify.completions({ marker: "41", exact: [ { name: "f", text: "(method) i3.f(a: number): string", documentation: "Function i3 f" }, { name: "l", text: "(property) i3.l: (b: number) => string", documentation: "i3 l" }, { name: "nc_f", text: "(method) i3.nc_f(a: number): string" }, { name: "nc_l", text: "(property) i3.nc_l: (b: number) => string" }, { name: "nc_x", text: "(property) i3.nc_x: number" }, { name: "x", text: "(property) i3.x: number", documentation: "Comment i3 x" }, ], }); verify.signatureHelp({ marker: "42", docComment: "Function i3 f", parameterDocComment: "number parameter" }); verify.signatureHelp({ marker: "43", docComment: "", parameterDocComment: "comment i3 l b" }); verify.quickInfoAt("43q", "(property) i3.l: (b: number) => string", "i3 l"); verify.signatureHelp({ marker: "44", docComment: "" }); verify.quickInfoAt("44q", "(method) i3.nc_f(a: number): string"); verify.signatureHelp({ marker: "45", docComment: "" }); verify.quickInfoAt("45q", "(property) i3.nc_l: (b: number) => string");
{ "end_byte": 8393, "start_byte": 5318, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsInterfaceFourslash.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionPropertyAssignment.ts_0_337
/// <reference path='fourslash.ts' /> //// export const /*FunctionResult*/Component = () => { return "OK"} //// Component./*PropertyResult*/displayName = 'Component' //// //// [|/*FunctionClick*/Component|] //// //// Component.[|/*PropertyClick*/displayName|] verify.baselineGoToDefinition( "FunctionClick", "PropertyClick", );
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionPropertyAssignment.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags10.ts_0_270
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags10.js /////** //// * @param {T1} a //// * @param {T2} a //// * @template T1,T2 Comment Text //// */ ////const /**/foo = (a, b) => {}; verify.baselineQuickInfo();
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags10.ts" }
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyFunctionNonEmptyClass.ts_0_539
/// <reference path='fourslash.ts' /> //// [|class A { //// y: number; //// constructor(public a: number) { //// this.x = function(x: number, y?: A){ //// return x > 0 ? x : y; //// } //// } //// }|] verify.rangeAfterCodeFix(` class A { y: number; x: (x: number, y?: A) => number | A; constructor(public a: number) { this.x = function(x: number, y?: A){ return x > 0 ? x : y; } } } `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyFunctionNonEmptyClass.ts" }
TypeScript/tests/cases/fourslash/findAllRefsInheritedProperties5.ts_3_314
/ <reference path='fourslash.ts'/> //// class C extends D { //// /*0*/prop0: string; //// /*1*/prop1: number; //// } //// //// class D extends C { //// /*2*/prop0: string; //// } //// //// var d: D; //// d./*3*/prop0; //// d./*4*/prop1; verify.baselineFindAllReferences('0', '1', '2', '3', '4')
{ "end_byte": 314, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInheritedProperties5.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction_fixAll.ts_0_1542
/// <reference path='fourslash.ts' /> // @target: es2015 ////declare class Thenable { then(): void; } ////interface Foo<T> {} ////type Bar = "a" | "b"; //// ////async function f1(): number {} ////async function f2(): boolean {} ////async function f3(): string {} ////async function f4(): void {} ////async function f5(): null {} ////async function f6(): undefined {} ////async function f7(): any {} ////async function f8(): symbol {} //// ////async function f9(): Foo<number> {} ////async function f10(): Bar {} ////async function f11(): PromiseLike<string> {} ////async function f12(): PromiseLike<void> {} ////async function f13(): Thenable {} //// ////async function f14(): string | symbol {} verify.codeFixAll({ fixId: "fixReturnTypeInAsyncFunction", fixAllDescription: ts.Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions.message, newFileContent: `declare class Thenable { then(): void; } interface Foo<T> {} type Bar = "a" | "b"; async function f1(): Promise<number> {} async function f2(): Promise<boolean> {} async function f3(): Promise<string> {} async function f4(): Promise<void> {} async function f5(): Promise<null> {} async function f6(): Promise<undefined> {} async function f7(): Promise<any> {} async function f8(): Promise<symbol> {} async function f9(): Promise<Foo<number>> {} async function f10(): Promise<Bar> {} async function f11(): Promise<string> {} async function f12(): Promise<void> {} async function f13(): Promise<void> {} async function f14(): Promise<string | symbol> {}` });
{ "end_byte": 1542, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction_fixAll.ts" }
TypeScript/tests/cases/fourslash/signatureHelpForNonlocalTypeDoesNotUseImportType.ts_0_325
/// <reference path="fourslash.ts" /> // @Filename: exporter.ts ////export interface Thing {} ////export const Foo: () => Thing = null as any; // @Filename: usage.ts ////import {Foo} from "./exporter" ////function f(p = Foo()): void {} ////f(/*1*/ verify.signatureHelp({ marker: "1", text: "f(p?: Thing): void" });
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpForNonlocalTypeDoesNotUseImportType.ts" }
TypeScript/tests/cases/fourslash/renameInheritedProperties4.ts_3_260
/ <reference path='fourslash.ts'/> //// interface interface1 extends interface1 { //// [|[|{| "contextRangeIndex": 0 |}doStuff|](): string;|] //// } //// //// var v: interface1; //// v.[|doStuff|](); verify.baselineRenameAtRangesWithText("doStuff");
{ "end_byte": 260, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties4.ts" }
TypeScript/tests/cases/fourslash/findAllRefsUnresolvedSymbols1.ts_0_329
/// <reference path='fourslash.ts'/> ////let a: /*a0*/Bar; ////let b: /*a1*/Bar<string>; ////let c: /*a2*/Bar<string, number>; ////let d: /*b0*/Bar./*c0*/X; ////let e: /*b1*/Bar./*c1*/X<string>; ////let f: /*b2*/Bar./*d0*/X./*e0*/Y; verify.baselineFindAllReferences('a0', 'a1', 'a2', 'b0', 'b1', 'b2', 'c0', 'c1', 'd0', 'e0');
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsUnresolvedSymbols1.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts_0_523
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles.baseline // @declaration: true // @Filename: inputFile1.ts // @emitThisFile: true //// // File to emit, does not contain semantic errors //// // expected to be emitted correctelly regardless of the semantic errors in the other file //// var noErrors = true; // @Filename: inputFile2.ts //// // File not emitted, and contains semantic errors //// var semanticError: boolean = "string"; verify.baselineGetEmitOutput();
{ "end_byte": 523, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPatternDefaultValues.ts_0_935
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////type Robot = [number, string, string]; ////var robotA: Robot = [1, "mower", "mowing"]; ////function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { //// console.log(nameA); ////} ////function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { //// console.log(numberB); ////} ////function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, "name", "skill"]) { //// console.log(nameA2); ////} ////function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { //// console.log(robotAInfo); ////} ////foo1(robotA); ////foo1([2, "trimmer", "trimming"]); ////foo2(robotA); ////foo2([2, "trimmer", "trimming"]); ////foo3(robotA); ////foo3([2, "trimmer", "trimming"]); ////foo4(robotA); ////foo4([2, "trimmer", "trimming"]); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 935, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPatternDefaultValues.ts" }
TypeScript/tests/cases/fourslash/moveToFile_alias.ts_1_627
/// <reference path='fourslash.ts' /> // @filename: /producer.ts //// export function doit() {} // @filename: /test.ts //// import { doit as doit2 } from "./producer"; //// //// class Another {} //// //// [|class Consumer { //// constructor() { //// doit2(); //// } //// }|] // @filename: /consumer.ts //// verify.moveToFile({ newFileContents: { "/test.ts": ` class Another {} `, "/consumer.ts": `import { doit as doit2 } from "./producer"; class Consumer { constructor() { doit2(); } } ` }, interactiveRefactorArguments: { targetFile: "/consumer.ts" }, });
{ "end_byte": 627, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_alias.ts" }
TypeScript/tests/cases/fourslash/semanticModernClassificationObjectProperties.ts_0_474
//// let x = 1, y = 1; //// const a1 = { e: 1 }; //// var a2 = { x }; const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("variable.declaration", "x"), c2.semanticToken("variable.declaration", "y"), c2.semanticToken("variable.declaration.readonly", "a1"), c2.semanticToken("property.declaration", "e"), c2.semanticToken("variable.declaration", "a2"), c2.semanticToken("property.declaration", "x"), );;
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticModernClassificationObjectProperties.ts" }
TypeScript/tests/cases/fourslash/completionListAtThisType.ts_0_342
/// <reference path='fourslash.ts'/> ////class Test { //// foo() {} //// //// bar() { //// this.baz(this, "/*1*/"); //// //// const t = new Test() //// this.baz(t, "/*2*/"); //// } //// //// baz<T>(a: T, k: keyof T) {} ////} verify.completions({ marker: ["1", "2"], exact: ["foo", "bar", "baz"] });
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtThisType.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType3.ts_0_411
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports.ts //// class SomeClass {} //// export type { SomeClass }; // @Filename: /a.ts //// import {} from "./exports.js"; //// function takeSomeClass(c: SomeClass/**/) goTo.marker(""); verify.importFixAtPosition([ `import { type SomeClass } from "./exports.js"; function takeSomeClass(c: SomeClass)`]);
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType3.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_7.ts_0_528
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// const A = { //// _a: 2, //// /*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 = { _a: 2, /*RENAME*/_a_1: 1, get a() { return this._a_1; }, set a(value) { this._a_1 = value; }, };`, });
{ "end_byte": 528, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_7.ts" }
TypeScript/tests/cases/fourslash/quickInfoMappedSpreadTypes.ts_0_639
/// <reference path="./fourslash.ts"/> ////interface Foo { //// /** Doc */ //// bar: number; ////} //// ////const f: Foo = { bar: 0 }; ////f./*f*/bar; //// ////const f2: { [TKey in keyof Foo]: string } = { bar: "0" }; ////f2./*f2*/bar; //// ////const f3 = { ...f }; ////f3./*f3*/bar; //// ////const f4 = { ...f2 }; ////f4./*f4*/bar; goTo.marker("f"); verify.quickInfoIs("(property) Foo.bar: number", "Doc"); goTo.marker("f2"); verify.quickInfoIs("(property) bar: string", "Doc"); goTo.marker("f3"); verify.quickInfoIs("(property) Foo.bar: number", "Doc"); goTo.marker("f4"); verify.quickInfoIs("(property) bar: string", "Doc");
{ "end_byte": 639, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoMappedSpreadTypes.ts" }
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature4.ts_0_348
/// <reference path='fourslash.ts'/> // @noPropertyAccessFromIndexSignature: true //// declare let x: { y: { [x: string]: string } }; //// x.y.yadda; verify.codeFix({ description: [ts.Diagnostics.Use_element_access_for_0.message, 'yadda'], index: 0, newFileContent: `declare let x: { y: { [x: string]: string } }; x.y["yadda"];`, });
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature4.ts" }
TypeScript/tests/cases/fourslash/smartSelection_functionParams2.ts_0_118
/// <reference path="fourslash.ts" /> ////function f( //// a, //// /**/b ////) {} verify.baselineSmartSelection();
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_functionParams2.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard3.ts_0_958
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/foo/package.json //// { //// "types": "index.d.ts", //// "typesVersions": { //// ">=4.3.5": { //// "browser/*": ["dist/*"] //// } //// } //// } // @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/subfolder/one.d.ts //// export const one = 0; // @Filename: /a.ts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["browser", "nope", "dist"], }); edit.insert("browser/"); verify.completions({ isNewIdentifierLocation: true, exact: ["blah", "index", "subfolder"], }); edit.insert("subfolder/"); verify.completions({ isNewIdentifierLocation: true, exact: ["one"], });
{ "end_byte": 958, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard3.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts_0_1034
/// <reference path='fourslash.ts' /> // Should give completions for js files in node modules when allowJs is set to true // @allowJs: true // @Filename: tests/test0.ts //// import * as foo1 from "fake-module//*import_as0*/ //// import foo2 = require("fake-module//*import_equals0*/ //// var foo3 = require("fake-module//*require0*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } // @Filename: node_modules/fake-module/ts.ts //// /*ts*/ // @Filename: node_modules/fake-module/tsx.tsx //// /*tsx*/ // @Filename: node_modules/fake-module/dts.d.ts //// /*dts*/ // @Filename: node_modules/fake-module/js.js //// /*js*/ // @Filename: node_modules/fake-module/jsx.jsx //// /*jsx*/ // @Filename: node_modules/fake-module/repeated.js //// /*repeatedjs*/ // @Filename: node_modules/fake-module/repeated.jsx //// /*repeatedjsx*/ verify.completions({ marker: ["import_as0", "import_equals0", "require0"], exact: ["dts", "js", "jsx", "repeated", "ts", "tsx"], isNewIdentifierLocation: true, });
{ "end_byte": 1034, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts" }
TypeScript/tests/cases/fourslash/navigateItemsLet.ts_0_377
/// <reference path="fourslash.ts" /> // @noLib: true ////let [|c = 10|]; ////function foo() { //// let [|d = 10|]; ////} const [r0, r1] = test.ranges(); verify.navigateTo( { pattern: "c", expected: [{ name: "c", kind: "let", range: r0 }] }, { pattern: "d", expected: [{ name: "d", kind: "let", range: r1, containerName: "foo", containerKind: "function" }] }, );
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigateItemsLet.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements3.ts_0_344
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|function f({ //// a, b, //// //// //// c, ////}: any)|] { //// a; //// c; ////} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'b'", newRangeContent: `function f({ a, c, }: any)` });
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements3.ts" }