_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/server/goToImplementation_inDifferentFiles.ts_0_389 | /// <reference path='../fourslash.ts'/>
// @Filename: /home/src/workspaces/project/bar.ts
////import {Foo} from './foo'
////
////class [|A|] implements Foo {
//// func() {}
////}
////
////class [|B|] implements Foo {
//// func() {}
////}
// @Filename: /home/src/workspaces/project/foo.ts
////export interface /**/Foo {
//// func();
////}
verify.baselineGoToImplementation("");
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToImplementation_inDifferentFiles.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocCallbackTagNavigateTo.ts_0_667 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsDocCallback.js
//// /**
//// * @callback FooCallback
//// * @param {string} eventName - What even is the navigation bar?
//// */
//// /** @type {FooCallback} */
//// var t;
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "FooCallback",
"kind": "type"
},
{
"text": "t",
"kind": "var"
}
]
},
{
"text": "FooCallback",
"kind": "type",
"indent": 1
}
])
| {
"end_byte": 667,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocCallbackTagNavigateTo.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider7.ts_0_2040 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @Filename: /home/src/workspaces/project/package.json
//// { "dependencies": { "mylib": "file:packages/mylib" } }
// @Filename: /home/src/workspaces/project/packages/mylib/package.json
//// { "name": "mylib", "version": "1.0.0", "main": "index.js", "types": "index" }
// @Filename: /home/src/workspaces/project/packages/mylib/index.ts
//// export * from "./mySubDir";
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/index.ts
//// export * from "./myClass";
//// export * from "./myClass2";
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/myClass.ts
//// export class MyClass {}
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/myClass2.ts
//// export class MyClass2 {}
// @link: /home/src/workspaces/project/packages/mylib -> /home/src/workspaces/project/node_modules/mylib
// @Filename: /home/src/workspaces/project/src/index.ts
////
//// const a = new MyClass/*1*/();
//// const b = new MyClass2/*2*/();
goTo.marker("1");
format.setOption("newLineCharacter", "\n");
verify.completions({
marker: "1",
includes: [{
name: "MyClass",
source: "mylib",
sourceDisplay: "mylib",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
}
});
verify.applyCodeActionFromCompletion("1", {
name: "MyClass",
source: "mylib",
description: `Add import from "mylib"`,
data: {
exportName: "MyClass",
fileName: "/home/src/workspaces/project/packages/mylib/index.ts",
},
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsWithInsertText: true,
allowIncompleteCompletions: true,
},
newFileContent: `import { MyClass } from "mylib";
const a = new MyClass();
const b = new MyClass2();`,
});
| {
"end_byte": 2040,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider7.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts_0_789 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/c.ts
////[||]
// @Filename: /home/src/workspaces/project/a.ts
//// export const abc = 10;
// @Filename: /home/src/workspaces/project/b.ts
//// import { abc } from "./a";
////
//// [|console.log(abc);
////
//// |]
//// console.log("abc");
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["c.ts", "a.ts", "b.ts"] }
const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [`console.log(abc);`],
pasteLocations: [ranges[0]],
copiedFrom: { file: "/home/src/workspaces/project/b.ts", range: [ranges[1]] },
},
newFileContents: {
"/home/src/workspaces/project/c.ts":
`import { abc } from "./a";
console.log(abc);`
}
});
| {
"end_byte": 789,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts"
} |
TypeScript/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts_0_703 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: a.js
//// /**
//// * Modify the parameter
//// * @param {string} p1
//// */
//// var foo = function (p1) { }
//// exports.foo = foo;
//// fo/*1*/
// @Filename: b.ts
//// import a = require("./a");
//// a.fo/*2*/
const entry = (text: string): FourSlashInterface.ExpectedCompletionEntry => ({
name: "foo",
text,
documentation: "Modify the parameter",
tags: [{
name: "param",
text: "p1",
}]
});
verify.completions(
{ marker: "1", includes: entry("var foo: (p1: string) => void") },
{ marker: "2", exact: entry("(alias) var foo: (p1: string) => void\nimport a.foo") },
);
| {
"end_byte": 703,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts"
} |
TypeScript/tests/cases/fourslash/server/isDefinitionAcrossModuleProjects.ts_0_2951 | /// <reference path="../fourslash.ts"/>
// @Filename: /home/src/workspaces/project/a/index.ts
////import { NS } from "../b";
////import { I } from "../c";
////
////declare module "../b" {
//// export namespace NS {
//// export function /*1*/FA();
//// }
////}
////
////declare module "../c" {
//// export interface /*2*/I {
//// /*3*/FA();
//// }
////}
////
////const ia: I = {
//// FA: NS.FA,
//// FC() { },
////};
// @Filename: /home/src/workspaces/project/a/tsconfig.json
////{
//// "extends": "../tsconfig.settings.json",
//// "references": [
//// { "path": "../b" },
//// { "path": "../c" },
//// ],
//// "files": [
//// "index.ts",
//// ],
////}
// @Filename: /home/src/workspaces/project/a2/index.ts
////import { NS } from "../b";
////import { I } from "../c";
////
////declare module "../b" {
//// export namespace NS {
//// export function /*4*/FA();
//// }
////}
////
////declare module "../c" {
//// export interface /*5*/I {
//// /*6*/FA();
//// }
////}
////
////const ia: I = {
//// FA: NS.FA,
//// FC() { },
////};
// @Filename: /home/src/workspaces/project/a2/tsconfig.json
////{
//// "extends": "../tsconfig.settings.json",
//// "references": [
//// { "path": "../b" },
//// { "path": "../c" },
//// ],
//// "files": [
//// "index.ts",
//// ],
////}
// @Filename: /home/src/workspaces/project/b/index.ts
////export namespace NS {
//// export function /*7*/FB() {}
////}
////
////export interface /*8*/I {
//// /*9*/FB();
////}
////
////const ib: I = { FB() {} };
// @Filename: /home/src/workspaces/project/b/other.ts
////export const Other = 1;
// @Filename: /home/src/workspaces/project/b/tsconfig.json
////{
//// "extends": "../tsconfig.settings.json",
//// "files": [
//// "index.ts",
//// "other.ts",
//// ],
////}
// @Filename: /home/src/workspaces/project/c/index.ts
////export namespace NS {
//// export function /*10*/FC() {}
////}
////
////export interface /*11*/I {
//// /*12*/FC();
////}
////
////const ic: I = { FC() {} };
// @Filename: /home/src/workspaces/project/c/tsconfig.json
////{
//// "extends": "../tsconfig.settings.json",
//// "files": [
//// "index.ts",
//// ],
////}
// @Filename: /home/src/workspaces/project/tsconfig.json
////{
//// "compilerOptions": {
//// "composite": true,
//// },
//// "references": [
//// { "path": "a" },
//// { "path": "a2" },
//// ],
//// "files": []
////}
// @Filename: /home/src/workspaces/project/tsconfig.settings.json
////{
//// "compilerOptions": {
//// "composite": true,
//// "skipLibCheck": true,
//// "declarationMap": true,
//// "module": "CommonJS",
//// "emitDeclarationOnly": true,
//// }
////}
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
| {
"end_byte": 2951,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/isDefinitionAcrossModuleProjects.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocTypedefTag2.ts_0_533 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsdocCompletion_typedef.js
//// /**
//// * @typedef {Object} A.B.MyType
//// * @property {string} yes
//// */
//// function foo() {}
//// /**
//// * @param {A.B.MyType} my2
//// */
//// function a(my2) {
//// my2.yes./*1*/
//// }
//// /**
//// * @param {MyType} my2
//// */
//// function b(my2) {
//// my2.yes./*2*/
//// }
verify.completions(
{ marker: "1", includes: "charAt" },
{ marker: "2", excludes: "charAt" },
);
| {
"end_byte": 533,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocTypedefTag2.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_wildcardExports1.ts_0_2480 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json
//// {
//// "name": "pkg",
//// "version": "1.0.0",
//// "exports": {
//// "./*": "./a/*.js",
//// "./b/*.js": "./b/*.js",
//// "./c/*": "./c/*",
//// "./d/*": {
//// "import": "./d/*.mjs"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/pkg/a/a1.d.ts
//// export const a1: number;
// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b1.d.ts
//// export const b1: number;
// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b2.d.mts
//// export const NOT_REACHABLE: number;
// @Filename: /home/src/workspaces/project/node_modules/pkg/c/c1.d.ts
//// export const c1: number;
// @Filename: /home/src/workspaces/project/node_modules/pkg/c/subfolder/c2.d.mts
//// export const c2: number;
// @Filename: /home/src/workspaces/project/node_modules/pkg/d/d1.d.mts
//// export const d1: number;
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "pkg": "1.0.0"
//// }
//// }
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }
// @Filename: /home/src/workspaces/project/main.ts
//// /**/
verify.completions({
marker: "",
includes: [
{
name: "a1",
source: "pkg/a1",
sourceDisplay: "pkg/a1",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "b1",
source: "pkg/b/b1.js",
sourceDisplay: "pkg/b/b1.js",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "c1",
source: "pkg/c/c1.js",
sourceDisplay: "pkg/c/c1.js",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "c2",
source: "pkg/c/subfolder/c2.mjs",
sourceDisplay: "pkg/c/subfolder/c2.mjs",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "d1",
source: "pkg/d/d1",
sourceDisplay: "pkg/d/d1",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
}
],
excludes: ["NOT_REACHABLE"],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true
}
});
| {
"end_byte": 2480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_wildcardExports1.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_importsMap4.ts_0_714 | /// <reference path="../fourslash.ts"/>
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext",
//// "rootDir": "src",
//// "outDir": "dist"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "imports": {
//// "#is-browser": {
//// "types": "./dist/env/browser.d.ts",
//// "default": "./dist/env/browser.js"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/src/env/browser.ts
//// export const isBrowser = true;
// @Filename: /home/src/workspaces/project/src/a.ts
//// isBrowser/**/
verify.importFixModuleSpecifiers("", ["#is-browser"]); | {
"end_byte": 714,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_importsMap4.ts"
} |
TypeScript/tests/cases/fourslash/server/completions01.ts_0_399 | /// <reference path="../fourslash.ts"/>
////var x: string[] = [];
////x.forEach(function (y) { y/*1*/
////x.forEach(y => y/*2*/
goTo.marker('1');
edit.insert('.');
verify.completions({ includes: "trim" });
edit.insert('});'); // need the following lines to not have parse errors in order for completion list to appear
goTo.marker('2');
edit.insert('.');
verify.completions({ includes: "trim" });
| {
"end_byte": 399,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/completions01.ts"
} |
TypeScript/tests/cases/fourslash/server/configurePlugin.ts_0_754 | /// <reference path="../fourslash.ts"/>
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "plugins": [
//// { "name": "configurable-diagnostic-adder" , "message": "configured error" }
//// ]
//// },
//// "files": ["a.ts"]
//// }
// @Filename: a.ts
//// let x = [1, 2];
//// /**/
////
// Test that plugin adds an error message which is able to be configured
goTo.marker();
verify.getSemanticDiagnostics([{ message: "configured error", code: 9999, range: { pos: 0, end: 3, fileName: "a.ts" } }]);
config.configurePlugin("configurable-diagnostic-adder", { message: "new error" });
verify.getSemanticDiagnostics([{ message: "new error", code: 9999, range: { pos: 0, end: 3, fileName: "a.ts" } }]);
| {
"end_byte": 754,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/configurePlugin.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_exportMap7.ts_0_1736 | /// <reference path="../fourslash.ts"/>
// Some exports are already in the main program while some are not.
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "dependency": "^1.0.0"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json
//// {
//// "type": "module",
//// "name": "dependency",
//// "version": "1.0.0",
//// "exports": {
//// ".": {
//// "types": "./lib/index.d.ts"
//// },
//// "./lol": {
//// "types": "./lib/lol.d.ts"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts
//// export function fooFromIndex(): void;
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts
//// export function fooFromLol(): void;
// @Filename: /home/src/workspaces/project/src/bar.ts
//// import { fooFromIndex } from "dependency";
// @Filename: /home/src/workspaces/project/src/foo.ts
//// fooFrom/**/
goTo.marker("");
verify.completions({
marker: "",
includes: [{
name: "fooFromIndex",
source: "dependency",
sourceDisplay: "dependency",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}, {
name: "fooFromLol",
source: "dependency/lol",
sourceDisplay: "dependency/lol",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
},
}); | {
"end_byte": 1736,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_exportMap7.ts"
} |
TypeScript/tests/cases/fourslash/server/getOutliningSpansForComments.ts_0_474 | /// <reference path="../fourslash.ts"/>
////[|/*
//// Block comment at the beginning of the file before module:
//// line one of the comment
//// line two of the comment
//// line three
//// line four
//// line five
////*/|]
////declare module "m";
////[|// Single line comments at the start of the file
////// line 2
////// line 3
////// line 4|]
////declare module "n";
verify.outliningSpansInCurrentFile(test.ranges(), "comment");
| {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/getOutliningSpansForComments.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource9_mapFromAtTypes2.ts_0_3012 | /// <reference path="../fourslash.ts" />
// @moduleResolution: node
// @Filename: /home/src/workspaces/project/node_modules/lodash/package.json
//// { "name": "lodash", "version": "4.17.15", "main": "./lodash.js" }
// @Filename: /home/src/workspaces/project/node_modules/lodash/lodash.js
//// ;(function() {
//// /**
//// * Adds two numbers.
//// *
//// * @static
//// * @memberOf _
//// * @since 3.4.0
//// * @category Math
//// * @param {number} augend The first number in an addition.
//// * @param {number} addend The second number in an addition.
//// * @returns {number} Returns the total.
//// * @example
//// *
//// * _.add(6, 4);
//// * // => 10
//// */
//// var [|/*variable*/add|] = createMathOperation(function(augend, addend) {
//// return augend + addend;
//// }, 0);
////
//// function lodash(value) {}
//// lodash.[|/*property*/add|] = add;
////
//// /** Detect free variable `global` from Node.js. */
//// var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
//// /** Detect free variable `self`. */
//// var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
//// /** Used as a reference to the global object. */
//// var root = freeGlobal || freeSelf || Function('return this')();
//// /** Detect free variable `exports`. */
//// var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;////
//// /** Detect free variable `module`. */
//// var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
//// if (freeModule) {
//// // Export for Node.js.
//// (freeModule.exports = _)._ = _;
//// // Export for CommonJS support.
//// freeExports._ = _;
//// }
//// else {
//// // Export to the global object.
//// root._ = _;
//// }
//// }.call(this));
// @Filename: /home/src/workspaces/project/node_modules/@types/lodash/package.json
//// { "name": "@types/lodash", "version": "4.14.97", "types": "index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/@types/lodash/index.d.ts
//// /// <reference path="./common/math.d.ts" />
//// export = _;
//// export as namespace _;
//// declare const _: _.LoDashStatic;
//// declare namespace _ {
//// interface LoDashStatic {}
//// }
// @Filename: /home/src/workspaces/project/node_modules/@types/lodash/common/math.d.ts
//// import _ = require("../index");
//// declare module "../index" {
//// interface LoDashStatic {
//// add(augend: number, addend: number): number;
//// }
//// }
// @Filename: /home/src/workspaces/project/index.ts
//// import [|/*defaultImport*/_|], { [|/*unresolvableNamedImport*/foo|] } from [|/*moduleSpecifier*/'lodash'|];
//// _.[|/*propertyAccess*/add|]
verify.baselineGoToSourceDefinition("defaultImport", "unresolvableNamedImport", "moduleSpecifier");
| {
"end_byte": 3012,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource9_mapFromAtTypes2.ts"
} |
TypeScript/tests/cases/fourslash/server/renameNamedImport.ts_0_745 | /// <reference path='../fourslash.ts' />
// @Filename: /home/src/workspaces/project/lib/tsconfig.json
//// {}
// @Filename: /home/src/workspaces/project/lib/index.ts
//// const unrelatedLocalVariable = 123;
//// export const someExportedVariable = unrelatedLocalVariable;
// @Filename: /home/src/workspaces/project/src/tsconfig.json
//// {}
// @Filename: /home/src/workspaces/project/src/index.ts
//// import { /*i*/someExportedVariable } from '../lib/index';
//// someExportedVariable;
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {}
goTo.file("/home/src/workspaces/project/lib/index.ts");
goTo.file("/home/src/workspaces/project/src/index.ts");
verify.baselineRename("i", { providePrefixAndSuffixTextForRename: true });
| {
"end_byte": 745,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/renameNamedImport.ts"
} |
TypeScript/tests/cases/fourslash/server/declarationMapsGoToDefinitionRelativeSourceRoot.ts_0_1262 | /// <reference path="../fourslash.ts" />
// @Filename: index.ts
////export class Foo {
//// member: string;
//// /*2*/methodName(propName: SomeType): void {}
//// otherMethod() {
//// if (Math.random() > 0.5) {
//// return {x: 42};
//// }
//// return {y: "yes"};
//// }
////}
////
////export interface SomeType {
//// member: number;
////}
// @Filename: out/indexdef.d.ts.map
////{"version":3,"file":"indexdef.d.ts","sourceRoot":"../","sources":["index.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}
// @Filename: out/indexdef.d.ts
////export declare class Foo {
//// member: string;
//// methodName(propName: SomeType): void;
//// otherMethod(): {
//// x: number;
//// y?: undefined;
//// } | {
//// y: string;
//// x?: undefined;
//// };
////}
////export interface SomeType {
//// member: number;
////}
//////# sourceMappingURL=out/indexdef.d.ts.map
// @Filename: mymodule.ts
////import * as mod from "./out/indexdef";
////const instance = new mod.Foo();
////instance.[|/*1*/methodName|]({member: 12});
verify.baselineGoToDefinition("1");
| {
"end_byte": 1262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/declarationMapsGoToDefinitionRelativeSourceRoot.ts"
} |
TypeScript/tests/cases/fourslash/server/getOutliningSpansForRegionsNoSingleLineFolds.ts_0_278 | ////[|//#region
////function foo()[| {
////
////}|]
////[|//these
//////should|]
//////#endregion not you|]
////[|// be
////// together|]
////
////[|//#region bla bla bla
////
////function bar()[| { }|]
////
//////#endregion|]
verify.outliningSpansInCurrentFile(test.ranges()); | {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/getOutliningSpansForRegionsNoSingleLineFolds.ts"
} |
TypeScript/tests/cases/fourslash/server/documentHighlights01.ts_0_164 | /// <reference path="../fourslash.ts"/>
// @Filename: a.ts
////function [|f|](x: typeof [|f|]) {
//// [|f|]([|f|]);
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/documentHighlights01.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource12_callbackParam.ts_0_1803 | /// <reference path="../fourslash.ts" />
// @moduleResolution: node
// Actual yargs doesn't work like this because the implementation package's
// main entry exports a small function wrapper function whose return value
// is derived from something imported from another file where all the
// important code lives, and it's not quite clear on what grounds we can
// make the jump from the main entry to that other file. But this test
// demonstrates the need to do some filename-based jumping: regular go-to-def
// on `yargs` goes to the type definition `Yargs`, but a JS-only go-to-def
// simply stops on the callback parameter. So we have to start at the type
// definition and say "well, maybe I can find a JS counterpart to this .d.ts
// and just look for declarations called 'positional' in there."
// @Filename: /home/src/workspaces/project/node_modules/@types/yargs/package.json
//// {
//// "name": "@types/yargs",
//// "version": "1.0.0",
//// "types": "./index.d.ts"
//// }
// @Filename: /home/src/workspaces/project/node_modules/@types/yargs/index.d.ts
//// export interface Yargs { positional(): Yargs; }
//// export declare function command(command: string, cb: (yargs: Yargs) => void): void;
// @Filename: /home/src/workspaces/project/node_modules/yargs/package.json
//// {
//// "name": "yargs",
//// "version": "1.0.0",
//// "main": "index.js"
//// }
// @Filename: /home/src/workspaces/project/node_modules/yargs/index.js
//// export function command(cmd, cb) { cb({ /*end*/positional: "This is obviously not even close to realistic" }); }
// @Filename: /home/src/workspaces/project/index.ts
//// import { command } from "yargs";
//// command("foo", yargs => {
//// yargs.[|/*start*/positional|]();
//// });
verify.baselineGoToSourceDefinition("start");
| {
"end_byte": 1803,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource12_callbackParam.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocCallbackTag.ts_0_1169 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsdocCallbackTag.js
//// /**
//// * @callback FooHandler - A kind of magic
//// * @param {string} eventName - So many words
//// * @param eventName2 {number | string} - Silence is golden
//// * @param eventName3 - Osterreich mos def
//// * @return {number} - DIVEKICK
//// */
//// /**
//// * @type {FooHa/*8*/ndler} callback
//// */
//// var t/*1*/;
////
//// /**
//// * @callback FooHandler2 - What, another one?
//// * @param {string=} eventName - it keeps happening
//// * @param {string} [eventName2] - i WARNED you dog
//// */
//// /**
//// * @type {FooH/*3*/andler2} callback
//// */
//// var t2/*2*/;
//// t(/*4*/"!", /*5*/12, /*6*/false);
goTo.marker("1");
verify.quickInfoIs("var t: FooHandler");
goTo.marker("2");
verify.quickInfoIs("var t2: FooHandler2");
goTo.marker("3");
verify.quickInfoIs("type FooHandler2 = (eventName?: string | undefined, eventName2?: string) => any", "- What, another one?");
goTo.marker("8");
verify.quickInfoIs("type FooHandler = (eventName: string, eventName2: number | string, eventName3: any) => number", "- A kind of magic");
| {
"end_byte": 1169,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocCallbackTag.ts"
} |
TypeScript/tests/cases/fourslash/server/importNameCodeFix_pnpm1.ts_0_658 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @Filename: /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react/index.d.ts
//// export declare function Component(): void;
// @Filename: /home/src/workspaces/project/index.ts
//// Component/**/
// @link: /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react -> /home/src/workspaces/project/node_modules/@types/react
goTo.marker("");
verify.importFixAtPosition([`import { Component } from "react";\r\n\r\nComponent`]);
| {
"end_byte": 658,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/importNameCodeFix_pnpm1.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider8.ts_0_2002 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @Filename: /home/src/workspaces/project/package.json
//// { "dependencies": { "mylib": "file:packages/mylib" } }
// @Filename: /home/src/workspaces/project/packages/mylib/package.json
//// { "name": "mylib", "version": "1.0.0" }
// @Filename: /home/src/workspaces/project/packages/mylib/index.ts
//// export * from "./mySubDir";
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/index.ts
//// export * from "./myClass";
//// export * from "./myClass2";
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/myClass.ts
//// export class MyClass {}
// @Filename: /home/src/workspaces/project/packages/mylib/mySubDir/myClass2.ts
//// export class MyClass2 {}
// @link: /home/src/workspaces/project/packages/mylib -> /home/src/workspaces/project/node_modules/mylib
// @Filename: /home/src/workspaces/project/src/index.ts
////
//// const a = new MyClass/*1*/();
//// const b = new MyClass2/*2*/();
goTo.marker("1");
format.setOption("newLineCharacter", "\n");
verify.completions({
marker: "1",
includes: [{
name: "MyClass",
source: "mylib",
sourceDisplay: "mylib",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
}
});
verify.applyCodeActionFromCompletion("1", {
name: "MyClass",
source: "mylib",
description: `Add import from "mylib"`,
data: {
exportName: "MyClass",
fileName: "/home/src/workspaces/project/packages/mylib/index.ts",
},
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsWithInsertText: true,
allowIncompleteCompletions: true,
},
newFileContent: `import { MyClass } from "mylib";
const a = new MyClass();
const b = new MyClass2();`,
});
| {
"end_byte": 2002,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider8.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportCrossProject_paths_toDist.ts_0_1561 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/packages/app/package.json
//// { "name": "app", "dependencies": { "dep": "*" } }
// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "outDir": "dist",
//// "rootDir": "src",
//// "baseUrl": ".",
//// "paths": {
//// "dep": ["../dep/src/main"],
//// "dep/dist/*": ["../dep/src/*"]
//// }
//// }
//// "references": [{ "path": "../dep" }]
//// }
// @Filename: /home/src/workspaces/project/packages/app/src/index.ts
//// dep1/*1*/;
// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts
//// dep2/*2*/;
// @Filename: /home/src/workspaces/project/packages/app/src/a.ts
//// import "dep";
// @Filename: /home/src/workspaces/project/packages/dep/package.json
//// { "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" }
// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json
//// {
//// "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" }
//// }
// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts
//// import "./sub/folder";
//// export const dep1 = 0;
// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts
//// export const dep2 = 0;
goTo.marker("1");
verify.importFixAtPosition([`import { dep1 } from "dep";\r
\r
dep1;`]);
goTo.marker("2");
verify.importFixAtPosition([`import { dep2 } from "dep/dist/sub/folder";\r
\r
dep2;`]);
| {
"end_byte": 1561,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportCrossProject_paths_toDist.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportCrossProject_symlinks_toDist.ts_0_1343 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/packages/app/package.json
//// { "name": "app", "dependencies": { "dep": "*" } }
// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "outDir": "dist",
//// "rootDir": "src",
//// "baseUrl": ".",
//// "paths": {
//// "dep/dist/*": ["../dep/src/*"]
//// }
//// }
//// "references": [{ "path": "../dep" }]
//// }
// @Filename: /home/src/workspaces/project/packages/app/src/index.ts
//// dep/**/
// @Filename: /home/src/workspaces/project/packages/dep/package.json
//// { "name": "dep", "main": "dist/index.js", "types": "dist/index.d.ts" }
// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json
//// {
//// "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" }
//// }
// @Filename: /home/src/workspaces/project/packages/dep/src/index.ts
//// import "./sub/folder";
// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts
//// export const dep = 0;
// @link: /home/src/workspaces/project/packages/dep -> /home/src/workspaces/project/packages/app/node_modules/dep
goTo.marker("");
verify.importFixAtPosition([`import { dep } from "dep/dist/sub/folder";\r
\r
dep`]);
| {
"end_byte": 1343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportCrossProject_symlinks_toDist.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts_0_460 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsDocTypedef_form3.js
////
//// /**
//// * [|@typedef /*1*/[|{| "contextRangeIndex": 0 |}Person|]
//// * @type {Object}
//// * @property {number} age
//// * @property {string} name
//// |]*/
////
//// /** @type {/*2*/[|Person|]} */
//// var person;
goTo.file('jsDocTypedef_form3.js')
verify.baselineRename(test.rangesByText().get("Person"), { findInComments: true });
| {
"end_byte": 460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_exportMap3.ts_0_1313 | /// <reference path="../fourslash.ts"/>
// String exports
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "dependency": "^1.0.0"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json
//// {
//// "name": "dependency",
//// "version": "1.0.0",
//// "main": "./lib/index.js",
//// "exports": "./lib/lol.d.ts"
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts
//// export function fooFromIndex(): void;
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts
//// export function fooFromLol(): void;
// @Filename: /home/src/workspaces/project/src/foo.ts
//// fooFrom/**/
goTo.marker("");
verify.completions({
marker: "",
includes: [{
name: "fooFromLol",
source: "dependency",
sourceDisplay: "dependency",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}],
excludes: "fooFromIndex",
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
},
});
| {
"end_byte": 1313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_exportMap3.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource1_localJsBesideDts.ts_0_413 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/a.js
//// export const /*end*/a = "a";
// @Filename: /home/src/workspaces/project/a.d.ts
//// export declare const a: string;
// @Filename: /home/src/workspaces/project/index.ts
//// import { a } from [|"./a"/*moduleSpecifier*/|];
//// [|a/*identifier*/|]
verify.baselineGoToSourceDefinition("identifier", "moduleSpecifier"); | {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource1_localJsBesideDts.ts"
} |
TypeScript/tests/cases/fourslash/server/ngProxy2.ts_0_408 | /// <reference path="../fourslash.ts"/>
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "plugins": [
//// { "name": "invalidmodulename" }
//// ]
//// },
//// "files": ["a.ts"]
//// }
// @Filename: a.ts
//// let x = [1, 2];
//// x/**/
////
// LS shouldn't crash/fail if a plugin fails to load
goTo.marker();
verify.quickInfoIs('let x: number[]');
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/ngProxy2.ts"
} |
TypeScript/tests/cases/fourslash/server/occurrences01.ts_0_270 | /// <reference path="../fourslash.ts"/>
////foo: [|switch|] (10) {
//// [|case|] 1:
//// [|case|] 2:
//// [|case|] 3:
//// [|break|];
//// [|break|] foo;
//// continue;
//// continue foo;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/occurrences01.ts"
} |
TypeScript/tests/cases/fourslash/server/rename01.ts_0_375 | /// <reference path="../fourslash.ts"/>
///////<reference path="./Bar.ts" />
////[|function [|{| "contextRangeIndex": 0 |}Bar|]() {
//// // This is a reference to [|Bar|] in a comment.
//// "this is a reference to [|Bar|] in a string"
////}|]
const [rDef, ...ranges] = test.ranges();
verify.baselineRename(ranges[0], { findInStrings: true, findInComments: true, });
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/rename01.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts_0_1484 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/target.ts
//// import { r } from "./file1";
//// const a = r;
//// [|const b = 2;|]
//// const c = 3;
//// [||]
//// const d = 4;
// @Filename: /home/src/workspaces/project/file1.ts
//// import { aa, bb } from "./other";
//// export const r = 10;
//// const s = 12;
//// export const m = 10;
//// [|export const t = aa + bb + r + s;
//// const u = 1;|]
//// [|export const k = r + m;|]
// @Filename: /home/src/workspaces/project/other.ts
//// export const aa = 1;
//// export const bb = 2;
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["file1.ts", "target.ts", "other.ts"] }
const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `export const t = aa + bb + r + s;
const u = 1;`, `export const k = r + m;`],
pasteLocations: [ranges[0], ranges[1]],
copiedFrom: { file: "/home/src/workspaces/project/file1.ts", range: [ranges[2], ranges[3]] },
},
newFileContents: {
"/home/src/workspaces/project/file1.ts":`import { aa, bb } from "./other";
export const r = 10;
export const s = 12;
export const m = 10;
export const t = aa + bb + r + s;
const u = 1;
export const k = r + m;`,
"/home/src/workspaces/project/target.ts":
`import { m, r, s } from "./file1";
import { aa, bb } from "./other";
const a = r;
export const t = aa + bb + r + s;
const u = 1;
const c = 3;
export const k = r + m;
const d = 4;`
}
}); | {
"end_byte": 1484,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts_0_429 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsDocCallback.js
////
//// /**
//// * [|@callback [|{| "contextRangeIndex": 0 |}FooCallback|]
//// * @param {string} eventName - Rename should work
//// |]*/
////
//// /** @type {/*1*/[|FooCallback|]} */
//// var t;
const [rDef, ...ranges] = test.ranges();
verify.baselineRename(ranges[0], { findInStrings: false, findInComments: true });
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts_0_535 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsdocCompletion_typedef.js
//// /**
//// * @typedef {Object} Person
//// * @property {string} /*1*/personName
//// * @property {number} personAge
//// */
////
//// /**
//// * @typedef {{ /*2*/animalName: string, animalAge: number }} Animal
//// */
////
//// /** @type {Person} */
//// var person; person.[|personName/*3*/|]
////
//// /** @type {Animal} */
//// var animal; animal.[|animalName/*4*/|]
verify.baselineGoToDefinition("3", "4");
| {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider9.ts_0_3116 | /// <reference path="../fourslash.ts" />
// @module: preserve
// @Filename: /home/src/workspaces/project/index.ts
//// Lib1/**/
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "dependencies": {
//// "lib1": "*",
//// "lib2": "*",
//// "lib3": "*",
//// "lib4": "*",
//// "lib5": "*",
//// "lib6": "*",
//// "lib7": "*",
//// "lib8": "*",
//// "lib9": "*",
//// "lib10": "*",
//// "lib11": "*"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/lib1/package.json
//// { "name": "lib1", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib1/index.d.ts
//// export class Lib1 {}
// @Filename: /home/src/workspaces/project/node_modules/lib2/package.json
//// { "name": "lib2", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib2/index.d.ts
//// export class Lib2 {}
// @Filename: /home/src/workspaces/project/node_modules/lib3/package.json
//// { "name": "lib3", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib3/index.d.ts
//// export class Lib3 {}
// @Filename: /home/src/workspaces/project/node_modules/lib4/package.json
//// { "name": "lib4", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib4/index.d.ts
//// export class Lib4 {}
// @Filename: /home/src/workspaces/project/node_modules/lib5/package.json
//// { "name": "lib5", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib5/index.d.ts
//// export class Lib5 {}
// @Filename: /home/src/workspaces/project/node_modules/lib6/package.json
//// { "name": "lib6", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib6/index.d.ts
//// export class Lib6 {}
// @Filename: /home/src/workspaces/project/node_modules/lib7/package.json
//// { "name": "lib7", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib7/index.d.ts
//// export class Lib7 {}
// @Filename: /home/src/workspaces/project/node_modules/lib8/package.json
//// { "name": "lib8", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib8/index.d.ts
//// export class Lib8 {}
// @Filename: /home/src/workspaces/project/node_modules/lib9/package.json
//// { "name": "lib9", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib9/index.d.ts
//// export class Lib9 {}
// @Filename: /home/src/workspaces/project/node_modules/lib10/package.json
//// { "name": "lib10", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib10/index.d.ts
//// export class Lib10 {}
// @Filename: /home/src/workspaces/project/node_modules/lib11/package.json
//// { "name": "lib11", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/lib11/index.d.ts
//// export class Lib11 {}
verify.importFixModuleSpecifiers("", []);
verify.importFixModuleSpecifiers("", []);
edit.insertLine("import {} from 'lib2';");
verify.importFixModuleSpecifiers("", ["lib1"]);
| {
"end_byte": 3116,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider9.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_importsMap1.ts_0_829 | /// <reference path="../fourslash.ts"/>
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext",
//// "rootDir": "src",
//// "outDir": "dist"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "imports": {
//// "#is-browser": {
//// "browser": "./dist/env/browser.js",
//// "default": "./dist/env/node.js"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/src/env/browser.ts
//// export const isBrowser = true;
// @Filename: /home/src/workspaces/project/src/env/node.ts
//// export const isBrowser = false;
// @Filename: /home/src/workspaces/project/src/a.ts
//// isBrowser/**/
verify.importFixModuleSpecifiers("", ["#is-browser", "./env/browser.js"]);
| {
"end_byte": 829,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_importsMap1.ts"
} |
TypeScript/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts_0_361 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsDocTypedef_form2.js
////
//// /** [|@typedef {(string | number)} [|{| "contextRangeIndex": 0 |}NumberLike|]|] */
////
//// /** @type {[|NumberLike|]} */
//// var numberLike;
const [rDef, ...ranges] = test.ranges();
verify.baselineRename(ranges, { findInComments: true });
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportCrossProject_paths_toSrc.ts_0_1551 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/packages/app/package.json
//// { "name": "app", "dependencies": { "dep": "*" } }
// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "outDir": "dist",
//// "rootDir": "src",
//// "baseUrl": ".",
//// "paths": {
//// "dep": ["../dep/src/main"],
//// "dep/*": ["../dep/*"]
//// }
//// }
//// "references": [{ "path": "../dep" }]
//// }
// @Filename: /home/src/workspaces/project/packages/app/src/index.ts
//// dep1/*1*/;
// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts
//// dep2/*2*/;
// @Filename: /home/src/workspaces/project/packages/app/src/a.ts
//// import "dep";
// @Filename: /home/src/workspaces/project/packages/dep/package.json
//// { "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" }
// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json
//// {
//// "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" }
//// }
// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts
//// import "./sub/folder";
//// export const dep1 = 0;
// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts
//// export const dep2 = 0;
goTo.marker("1");
verify.importFixAtPosition([`import { dep1 } from "dep";\r
\r
dep1;`]);
goTo.marker("2");
verify.importFixAtPosition([`import { dep2 } from "dep/src/sub/folder";\r
\r
dep2;`]);
| {
"end_byte": 1551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportCrossProject_paths_toSrc.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportCrossProject_paths_stripSrc.ts_0_1551 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/packages/app/package.json
//// { "name": "app", "dependencies": { "dep": "*" } }
// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "outDir": "dist",
//// "rootDir": "src",
//// "baseUrl": ".",
//// "paths": {
//// "dep": ["../dep/src/main"],
//// "dep/*": ["../dep/src/*"]
//// }
//// }
//// "references": [{ "path": "../dep" }]
//// }
// @Filename: /home/src/workspaces/project/packages/app/src/index.ts
//// dep1/*1*/;
// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts
//// dep2/*2*/;
// @Filename: /home/src/workspaces/project/packages/app/src/a.ts
//// import "dep";
// @Filename: /home/src/workspaces/project/packages/dep/package.json
//// { "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" }
// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json
//// {
//// "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" }
//// }
// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts
//// import "./sub/folder";
//// export const dep1 = 0;
// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts
//// export const dep2 = 0;
goTo.marker("1");
verify.importFixAtPosition([`import { dep1 } from "dep";\r
\r
dep1;`]);
goTo.marker("2");
verify.importFixAtPosition([`import { dep2 } from "dep/sub/folder";\r
\r
dep2;`]);
| {
"end_byte": 1551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportCrossProject_paths_stripSrc.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_exportMap2.ts_0_1517 | /// <reference path="../fourslash.ts"/>
// This one uses --module=commonjs, so the export map is not followed.
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "dependency": "^1.0.0"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json
//// {
//// "type": "module",
//// "name": "dependency",
//// "version": "1.0.0",
//// "types": "./lib/index.d.ts",
//// "exports": {
//// ".": {
//// "types": "./lib/index.d.ts"
//// },
//// "./lol": {
//// "types": "./lib/lol.d.ts"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts
//// export function fooFromIndex(): void;
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts
//// export function fooFromLol(): void;
// @Filename: /home/src/workspaces/project/src/foo.ts
//// fooFrom/**/
goTo.marker("");
verify.completions({
marker: "",
exact: completion.globalsPlus([{
name: "fooFromIndex",
source: "dependency",
sourceDisplay: "dependency",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}]),
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
},
}); | {
"end_byte": 1517,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_exportMap2.ts"
} |
TypeScript/tests/cases/fourslash/server/definition01.ts_0_212 | /// <reference path="../fourslash.ts"/>
// @Filename: b.ts
////import n = require([|'./a/*1*/'|]);
////var x = new n.Foo();
// @Filename: a.ts
//// /*2*/export class Foo {}
verify.baselineGoToDefinition("1");
| {
"end_byte": 212,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/definition01.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource15_bundler.ts_0_1284 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// { "compilerOptions": { "module": "esnext", "moduleResolution": "bundler" } }
// @Filename: /home/src/workspaces/project/node_modules/react/package.json
//// { "name": "react", "version": "16.8.6", "main": "index.js" }
// @Filename: /home/src/workspaces/project/node_modules/react/index.js
//// 'use strict';
////
//// if (process.env.NODE_ENV === 'production') {
//// module.exports = require('./cjs/react.production.min.js');
//// } else {
//// module.exports = require('./cjs/react.development.js');
//// }
// @Filename: /home/src/workspaces/project/node_modules/react/cjs/react.production.min.js
//// 'use strict';exports./*production*/useState=function(a){};exports.version='16.8.6';
// @Filename: /home/src/workspaces/project/node_modules/react/cjs/react.development.js
//// 'use strict';
//// if (process.env.NODE_ENV !== 'production') {
//// (function() {
//// function useState(initialState) {}
//// exports./*development*/useState = useState;
//// exports.version = '16.8.6';
//// }());
//// }
// @Filename: /home/src/workspaces/project/index.ts
//// import { [|/*start*/useState|] } from 'react';
verify.baselineGoToSourceDefinition("start");
| {
"end_byte": 1284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource15_bundler.ts"
} |
TypeScript/tests/cases/fourslash/server/ngProxy3.ts_0_415 | /// <reference path="../fourslash.ts"/>
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "plugins": [
//// { "name": "create-thrower" }
//// ]
//// },
//// "files": ["a.ts"]
//// }
// @Filename: a.ts
//// let x = [1, 2];
//// x/**/
////
// LS shouldn't crash/fail if a plugin fails to init correctly
goTo.marker();
verify.quickInfoIs('let x: number[]');
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/ngProxy3.ts"
} |
TypeScript/tests/cases/fourslash/server/referencesInStringLiteralValueWithMultipleProjects.ts_0_474 | /// <reference path="../fourslash.ts"/>
// @Filename: /home/src/workspaces/project/a/tsconfig.json
////{ "files": ["a.ts"] }
// @Filename: /home/src/workspaces/project/a/a.ts
/////// <reference path="../b/b.ts" />
////const str: string = "hello/*1*/";
// @Filename: /home/src/workspaces/project/b/tsconfig.json
////{ "files": ["b.ts"] }
// @Filename: /home/src/workspaces/project/b/b.ts
////const str2: string = "hello/*2*/";
verify.baselineFindAllReferences('1', '2')
| {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/referencesInStringLiteralValueWithMultipleProjects.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts_0_1163 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/target.ts
//// const a = 1;
//// [|const b = 2;|]
//// const c = 3;
//// [||]
//// const d = 4;
// @Filename: /home/src/workspaces/project/file1.ts
//// import { aa, bb } from "./other";
//// export const r = 10;
//// export const s = 12;
//// [|export const t = aa + bb + r + s;
//// const u = 1;|]
// @Filename: /home/src/workspaces/project/other.ts
//// export const aa = 1;
//// export const bb = 2;
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["file1.ts", "target.ts", "other.ts"] }
const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `export const t = aa + bb + r + s;
const u = 1;`,],
pasteLocations: [ranges[0], ranges[1]],
copiedFrom: { file: "/home/src/workspaces/project/file1.ts", range: [ranges[2]] },
},
newFileContents: {
"/home/src/workspaces/project/target.ts":
`import { r, s } from "./file1";
import { aa, bb } from "./other";
const a = 1;
export const t = aa + bb + r + s;
const u = 1;
const c = 3;
export const t = aa + bb + r + s;
const u = 1;
const d = 4;`
}
}); | {
"end_byte": 1163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts"
} |
TypeScript/tests/cases/fourslash/server/quickinfo01.ts_0_469 | /// <reference path="../fourslash.ts"/>
////interface One {
//// commonProperty: number;
//// commonFunction(): number;
////}
////
////interface Two {
//// commonProperty: string
//// commonFunction(): number;
////}
////
////var /*1*/x : One | Two;
////
////x./*2*/commonProperty;
////x./*3*/commonFunction;
verify.quickInfos({
1: "var x: One | Two",
2: "(property) commonProperty: string | number",
3: "(method) commonFunction(): number"
});
| {
"end_byte": 469,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/quickinfo01.ts"
} |
TypeScript/tests/cases/fourslash/server/projectInfo02.ts_0_426 | /// <reference path="../fourslash.ts"/>
// @Filename: a.ts
////export var test = "test String"
// @Filename: b.ts
////export var test2 = "test String"
// @Filename: tsconfig.json
////{ "files": ["a.ts", "b.ts"] }
goTo.file("a.ts")
verify.ProjectInfo(["/home/src/tslibs/TS/Lib/lib.d.ts", "/home/src/tslibs/TS/Lib/lib.decorators.d.ts", "/home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts", "a.ts", "b.ts", "tsconfig.json"])
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/projectInfo02.ts"
} |
TypeScript/tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts_0_141 | /// <reference path="../fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////var ===;
verify.baselineSyntacticAndSemanticDiagnostics() | {
"end_byte": 141,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts"
} |
TypeScript/tests/cases/fourslash/server/referenceToEmptyObject.ts_0_103 | /// <reference path='fourslash.ts'/>
////const obj = {}/*1*/;
verify.baselineFindAllReferences('1');
| {
"end_byte": 103,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/referenceToEmptyObject.ts"
} |
TypeScript/tests/cases/fourslash/server/nodeNextModuleKindCaching1.ts_0_876 | /// <reference path="../fourslash.ts"/>
// @Filename: tsconfig.json
////{
//// "compilerOptions": {
//// "rootDir": "src",
//// "outDir": "dist",
//// "target": "ES2020",
//// "module": "NodeNext",
//// "strict": true
//// },
//// "include": ["src\\**\\*.ts"]
////}
// @Filename: package.json
////{
//// "type": "module",
//// "private": true
////}
// @Filename: src/index.ts
////// The line below should show a "Relative import paths need explicit file
////// extensions..." error in VS Code, but it doesn't. The error is only picked up
////// by `tsc` which seems to properly infer the module type.
////import { helloWorld } from './example'
/////**/
////helloWorld()
// @Filename: src/example.ts
////export function helloWorld() {
//// console.log('Hello, world!')
////}
goTo.marker();
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 876,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/nodeNextModuleKindCaching1.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts_0_565 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/b.ts
////[||]
// @Filename: /home/src/workspaces/project/a.ts
//// export interface Foo { }
////
//// [|export|] const foo: Foo = {}
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["a.ts", "b.ts"] }
const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [`export`],
pasteLocations: [ranges[0]],
copiedFrom: { file: "/home/src/workspaces/project/a.ts", range: [ranges[1]] },
},
newFileContents: {}
});
| {
"end_byte": 565,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportRelativePathToMonorepoPackage.ts_0_887 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }
// @Filename: /home/src/workspaces/project/packages/app/dist/index.d.ts
//// import {} from "utils";
//// export const app: number;
// @Filename: /home/src/workspaces/project/packages/utils/package.json
//// { "name": "utils", "version": "1.0.0", "main": "dist/index.js" }
// @Filename: /home/src/workspaces/project/packages/utils/dist/index.d.ts
//// export const x: number;
// @link: /home/src/workspaces/project/packages/utils -> /home/src/workspaces/project/packages/app/node_modules/utils
// @Filename: /home/src/workspaces/project/script.ts
//// import {} from "./packages/app/dist/index.js";
//// x/**/
goTo.marker("");
verify.importFixModuleSpecifiers("", ["./packages/utils/dist/index.js"]);
| {
"end_byte": 887,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportRelativePathToMonorepoPackage.ts"
} |
TypeScript/tests/cases/fourslash/server/importSuggestionsCache_exportUndefined.ts_0_1104 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "compilerOptions": { "module": "esnext" } }
// @Filename: /home/src/workspaces/project/undefined.ts
////export = undefined;
// @Filename: /home/src/workspaces/project/undefinedAlias.ts
////const x = undefined;
////export = x;
// @Filename: /home/src/workspaces/project/index.ts
//// /**/
// Would throw error if undefined appears twice
goTo.marker("");
verify.completions({
includes: [{
name: "x",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
source: "/home/src/workspaces/project/undefinedAlias"
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
}
});
// Do it again for cache test
verify.completions({
includes: [{
name: "x",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
source: "/home/src/workspaces/project/undefinedAlias"
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
}
}); | {
"end_byte": 1104,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/importSuggestionsCache_exportUndefined.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts_0_981 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/file2.ts
//// const a = 10;
//// const b = 10;
//// [||]const c = 10;
// @Filename: /home/src/workspaces/project/file1.ts
//// export interface Test1 {}
//// export interface Test2 {}
//// export interface Test3 {}
//// export interface Test4 {}
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["file1.ts", "file2.ts"] }
verify.pasteEdits({
args: {
pastedText: [ `interface Testing {
test1: Test1;
test2: Test2;
test3: Test3;
test4: Test4;
}`],
pasteLocations: test.ranges(),
},
newFileContents: {
"/home/src/workspaces/project/file2.ts":
`import { Test1, Test2, Test3, Test4 } from "./file1";
const a = 10;
const b = 10;
interface Testing {
test1: Test1;
test2: Test2;
test3: Test3;
test4: Test4;
}const c = 10;`
},
}); | {
"end_byte": 981,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts"
} |
TypeScript/tests/cases/fourslash/server/getOutliningSpansForRegions.ts_0_1021 | /// <reference path="../fourslash.ts"/>
////// region without label
////[|// #region
////
////// #endregion|]
////
////// region without label with trailing spaces
////[|// #region
////
////// #endregion|]
////
////// region with label
////[|// #region label1
////
////// #endregion|]
////
////// region with extra whitespace in all valid locations
//// [|// #region label2 label3
////
//// // #endregion|]
////
////// No space before directive
////[|//#region label4
////
//////#endregion|]
////
////// Nested regions
////[|// #region outer
////
////[|// #region inner
////
////// #endregion inner|]
////
////// #endregion outer|]
////
////// region delimiters not valid when there is preceding text on line
//// test // #region invalid1
////
////test // #endregion
////
////// region delimiters not valid when in multiline comment
/////*
////// #region invalid2
////*/
////
/////*
////// #endregion
////*/
verify.outliningSpansInCurrentFile(test.ranges(), "region"); | {
"end_byte": 1021,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/getOutliningSpansForRegions.ts"
} |
TypeScript/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts_0_2794 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
////{
//// "compilerOptions": {
//// "outDir": "./dist",
//// "declaration": true,
//// "declarationMap": true,
//// "newLine": "lf",
//// },
//// "files": ["/home/src/workspaces/project/index.ts"],
////}
// @Filename: /home/src/workspaces/project/index.ts
// @emitThisFile: true
////export class Foo {
//// member: string;
//// /*2*/methodName(propName: SomeType): SomeType { return propName; }
//// otherMethod() {
//// if (Math.random() > 0.5) {
//// return {x: 42};
//// }
//// return {y: "yes"};
//// }
////}
////
////export interface /*SomeType*/SomeType {
//// member: number;
////}
// @Filename: /home/src/workspaces/project/mymodule.ts
////import * as mod from "/home/src/workspaces/project/dist/index";
////const instance = new mod.Foo();
////instance.[|/*1*/methodName|]({member: 12});
// @Filename: /home/src/workspaces/project/dist/index.js
////"use strict";
////Object.defineProperty(exports, "__esModule", { value: true });
////exports.Foo = void 0;
////var Foo = /** @class */ (function () {
//// function Foo() {
//// }
//// Foo.prototype.methodName = function (propName) { return propName; };
//// Foo.prototype.otherMethod = function () {
//// if (Math.random() > 0.5) {
//// return { x: 42 };
//// }
//// return { y: "yes" };
//// };
//// return Foo;
////}());
////exports.Foo = Foo;
////
// @Filename: /home/src/workspaces/project/dist/index.d.ts.map
////{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IACxC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}
// @Filename: /home/src/workspaces/project/dist/index.d.ts
////export declare class Foo {
//// member: string;
//// methodName(propName: SomeType): SomeType;
//// otherMethod(): {
//// x: number;
//// y?: undefined;
//// } | {
//// y: string;
//// x?: undefined;
//// };
////}
////export interface SomeType {
//// member: number;
////}
//////# sourceMappingURL=index.d.ts.map
goTo.file("/home/src/workspaces/project/index.ts");
verify.getEmitOutput([
"/home/src/workspaces/project/dist/index.js",
"/home/src/workspaces/project/dist/index.d.ts.map",
"/home/src/workspaces/project/dist/index.d.ts"
]);
verify.baselineGoToImplementation("1");// getImplementationAtPosition
verify.baselineGoToType("1");// getTypeDefinitionAtPosition
verify.baselineGoToDefinition("1");// getDefinitionAndBoundSpan
verify.baselineGetDefinitionAtPosition("1"); // getDefinitionAtPosition | {
"end_byte": 2794,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts"
} |
TypeScript/tests/cases/fourslash/server/importSuggestionsCache_ambient.ts_0_1452 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "compilerOptions": { "module": "esnext" } }
// @Filename: /home/src/workspaces/project/ambient.d.ts
////declare module 'ambient' {
//// export const ambient = 0;
////}
////a/**/
edit.disableFormatting();
// Ensure 'ambient' shows up
verifyIncludes("ambient");
// Delete it, ensure it doesn’t show up
edit.deleteLineRange(0, 2);
verifyExcludes("ambient");
// Add it back with changes, ensure it shows up
goTo.marker("");
edit.insertLines(`
declare module 'ambient' {
export const ambient2 = 0;
}`);
verifyIncludes("ambient2");
// Replace 'ambient2' with 'ambient3'
edit.replaceLine(2, " export const ambient3 = 0");
verifyExcludes("ambient2");
verifyIncludes("ambient3");
function verifyIncludes(name: string) {
goTo.marker("");
verify.completions({
includes: {
name,
source: "ambient",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
},
});
}
function verifyExcludes(name: string) {
goTo.marker("");
verify.completions({
excludes: name,
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
},
});
}
| {
"end_byte": 1452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/importSuggestionsCache_ambient.ts"
} |
TypeScript/tests/cases/fourslash/server/getFileReferences_server1.ts_0_521 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {}
// @Filename: /home/src/workspaces/project/a.ts
//// export const a = 0;
// @Filename: /home/src/workspaces/project/b.ts
//// import "./a";
// @Filename: /home/src/workspaces/project/c.ts
//// import {} from "./a";
// @Filename: /home/src/workspaces/project/d.ts
//// import { a } from "/project/a";
//// type T = typeof import("./a").a;
verify.baselineGetFileReferences("/home/src/workspaces/project/a.ts");
| {
"end_byte": 521,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/getFileReferences_server1.ts"
} |
TypeScript/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlySmallerInSize.ts_0_2100 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/a.ts
//// function foo() {
//// const p = 1;
//// function bar() {
//// console.log([|"Testing"|]);
//// }
//// console.log("yes");
//// }
//// class bar {
//// constructor() {
//// function a() {
//// function aa() {
//// con[|sole.log("have a good day");|]
//// }
////
//// }
//// a();
//// function b() {
//// function c() {
//// export const testing = 1;
//// const test = [|1 + testing + |]3;
//// }
//// }
//// b();
//// }
//// c() {
//// console.log("hello again");
//// [|function k() {
//// const happy = banana + avocados;
//// }|]
//// }
//// }
// @Filename: /home/src/workspaces/project/b.ts
//// export const juice = 1;
//// export const sauce = 2;
//// export const fig = 3;
//// export const tomato = 4;
// @Filename: /home/src/workspaces/project/tsconfig.json
////{ "files": ["a.ts", "b.ts"] }
verify.pasteEdits({
args: {
pastedText: [
`juice`,`sole.log(sauce + juice);`,
`fig + kiwi`,
`function k() {
const cherry =tomato + kiwi;
}`
],
pasteLocations: test.ranges(),
},
newFileContents: {
"/home/src/workspaces/project/a.ts":
`import { sauce, juice, fig, tomato } from "./b";
function foo() {
const p = 1;
function bar() {
console.log(juice);
}
console.log("yes");
}
class bar {
constructor() {
function a() {
function aa() {
console.log(sauce + juice);
}
}
a();
function b() {
function c() {
export const testing = 1;
const test = fig + kiwi3;
}
}
b();
}
c() {
console.log("hello again");
function k() {
const cherry =tomato + kiwi;
}
}
}`
}
});
| {
"end_byte": 2100,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlySmallerInSize.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_importsMap5.ts_0_767 | /// <reference path="../fourslash.ts"/>
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext",
//// "rootDir": "src",
//// "outDir": "dist",
//// "declarationDir": "types",
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "imports": {
//// "#is-browser": {
//// "types": "./types/env/browser.d.ts",
//// "default": "./not-dist-on-purpose/env/browser.js"
//// }
//// }
//// }
// @Filename: /home/src/workspaces/project/src/env/browser.ts
//// export const isBrowser = true;
// @Filename: /home/src/workspaces/project/src/a.ts
//// isBrowser/**/
verify.importFixModuleSpecifiers("", ["#is-browser"]); | {
"end_byte": 767,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_importsMap5.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource6_sameAsGoToDef2.ts_0_970 | /// <reference path="../fourslash.ts" />
// @Filename: /home/src/workspaces/project/node_modules/foo/package.json
//// { "name": "foo", "version": "1.2.3", "typesVersions": { "*": { "*": ["./types/*"] } } }
// @Filename: /home/src/workspaces/project/node_modules/foo/src/a.ts
//// export const /*end*/a = 'a';
// @Filename: /home/src/workspaces/project/node_modules/foo/types/a.d.ts
//// export declare const a: string;
//// //# sourceMappingURL=a.d.ts.map
// @Filename: /home/src/workspaces/project/node_modules/foo/types/a.d.ts.map
//// {"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE,OAAO,CAAC;;AACvB,wBAAsB"}
// @Filename: /home/src/workspaces/project/node_modules/foo/dist/a.js
//// export const a = 'a';
// @Filename: /home/src/workspaces/project/b.ts
//// import { a } from 'foo/a';
//// [|a/*start*/|]
verify.baselineGoToSourceDefinition("start");
verify.baselineGoToDefinition("start");
| {
"end_byte": 970,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource6_sameAsGoToDef2.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportFileExcludePatterns_windowsPaths.ts_0_885 | /// <reference path="../fourslash.ts"/>
// @module: commonjs
// @Filename: c:/workspaces/project/node_modules/aws-sdk/package.json
//// { "name": "aws-sdk", "version": "2.0.0", "main": "index.js" }
// @Filename: c:/workspaces/project/node_modules/aws-sdk/index.d.ts
//// export * from "./clients/s3";
// @Filename: c:/workspaces/project/node_modules/aws-sdk/clients/s3.d.ts
//// export declare class S3 {}
// @Filename: c:/workspaces/project/package.json
//// { "dependencies": { "aws-sdk": "*" } }
// @Filename: c:/workspaces/project/index.ts
//// S3/**/
const autoImportFileExcludePatterns = ["**\\node_modules\\aws-sdk"];
verify.completions({
marker: "",
excludes: "S3",
preferences: {
includeCompletionsForModuleExports: true,
autoImportFileExcludePatterns,
}
});
verify.importFixAtPosition([], /*errorCode*/ undefined, { autoImportFileExcludePatterns });
| {
"end_byte": 885,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportFileExcludePatterns_windowsPaths.ts"
} |
TypeScript/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts_0_2480 | /// <reference path="../fourslash.ts"/>
// @types package should be ignored because implementation package has types
// @Filename: /home/src/workspaces/project/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }
// @Filename: /home/src/workspaces/project/package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "dependency": "^1.0.0"
//// },
//// "devDependencies": {
//// "@types/dependency": "^1.0.0"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json
//// {
//// "type": "module",
//// "name": "dependency",
//// "version": "1.0.0",
//// "exports": {
//// ".": "./lib/index.js",
//// "./lol": "./lib/lol.js"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.js
//// export function fooFromIndex() {}
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts
//// export declare function fooFromIndex(): void
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.js
//// export function fooFromLol() {}
// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts
//// export declare function fooFromLol(): void
// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/package.json
//// {
//// "type": "module",
//// "name": "@types/dependency",
//// "version": "1.0.0",
//// "exports": {
//// ".": "./lib/index.d.ts",
//// "./lol": "./lib/lol.d.ts"
//// }
//// }
// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/index.d.ts
//// export declare function fooFromAtTypesIndex(): void;
// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/lol.d.ts
//// export declare function fooFromAtTypesLol(): void;
// @Filename: /home/src/workspaces/project/src/foo.ts
//// fooFrom/**/
goTo.marker("");
verify.completions({
marker: "",
includes: [{
name: "fooFromIndex",
source: "dependency",
sourceDisplay: "dependency",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}, {
name: "fooFromLol",
source: "dependency/lol",
sourceDisplay: "dependency/lol",
sortText: completion.SortText.AutoImportSuggestions,
hasAction: true,
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
},
});
| {
"end_byte": 2480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts"
} |
TypeScript/tests/cases/fourslash/server/goToSource18_reusedFromDifferentFolder.ts_0_1794 | /// <reference path="../fourslash.ts" />
// @moduleResolution: node
// This is just made up repro where the js file will be added to auxillary project because its not already part of the project
// Where in js file doesnt already have import to the corresponding js file hence will be added to project at later on stage
// @Filename: /home/src/workspaces/project/node_modules/@types/yargs/package.json
//// {
//// "name": "@types/yargs",
//// "version": "1.0.0",
//// "types": "./index.d.ts"
//// }
// @Filename: /home/src/workspaces/project/node_modules/@types/yargs/callback.d.ts
//// export declare class Yargs { positional(): Yargs; }
// @Filename: /home/src/workspaces/project/node_modules/@types/yargs/index.d.ts
//// import { Yargs } from "./callback";
//// export declare function command(command: string, cb: (yargs: Yargs) => void): void;
// @Filename: /home/src/workspaces/project/node_modules/yargs/package.json
//// {
//// "name": "yargs",
//// "version": "1.0.0",
//// "main": "index.js"
//// }
// @Filename: /home/src/workspaces/project/node_modules/yargs/callback.js
//// export class Yargs { positional() { } }
// @Filename: /home/src/workspaces/project/node_modules/yargs/index.js
//// // Specifically didnt have ./callback import to ensure that resolving module sepcifier adds the file to project at later stage
//// export function command(cmd, cb) { cb(Yargs) }
// @Filename: /home/src/workspaces/project/folder/random.ts
//// import { Yargs } from "yargs/callback";
// @Filename: /home/src/workspaces/project/some/index.ts
//// import { random } from "../folder/random";
//// import { command } from "yargs";
//// command("foo", yargs => {
//// yargs.[|/*start*/positional|]();
//// });
verify.baselineGoToSourceDefinition("start");
| {
"end_byte": 1794,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/goToSource18_reusedFromDifferentFolder.ts"
} |
TypeScript/tests/cases/fourslash/server/format01.ts_0_182 | /// <reference path="../fourslash.ts"/>
/////**/module Default{var x= ( { } ) ;}
format.document();
goTo.marker();
verify.currentLineContentIs('module Default { var x = ({}); }'); | {
"end_byte": 182,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/format01.ts"
} |
TypeScript/tests/cases/fourslash/server/signatureHelpJSDocCallbackTag.ts_0_759 | /// <reference path="../fourslash.ts"/>
// @allowNonTsExtensions: true
// @Filename: jsdocCallbackTag.js
//// /**
//// * @callback FooHandler - A kind of magic
//// * @param {string} eventName - So many words
//// * @param eventName2 {number | string} - Silence is golden
//// * @param eventName3 - Osterreich mos def
//// * @return {number} - DIVEKICK
//// */
//// /**
//// * @type {FooHandler} callback
//// */
//// var t;
////
//// /**
//// * @callback FooHandler2 - What, another one?
//// * @param {string=} eventName - it keeps happening
//// * @param {string} [eventName2] - i WARNED you dog
//// */
//// /**
//// * @type {FooHandler2} callback
//// */
//// var t2;
//// t(/*4*/"!", /*5*/12, /*6*/false);
verify.baselineSignatureHelp()
| {
"end_byte": 759,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/signatureHelpJSDocCallbackTag.ts"
} |
TypeScript/tests/cases/fourslash/server/navbar01.ts_0_7221 | /// <reference path="../fourslash.ts"/>
////// Interface
////interface IPoint {
//// getDist(): number;
//// new(): IPoint;
//// (): any;
//// [x:string]: number;
//// prop: string;
////}
////
/////// Module
////module Shapes {
//// // Class
//// export class Point implements IPoint {
//// constructor (public x: number, public y: number) { }
////
//// // Instance member
//// getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
////
//// // Getter
//// get value(): number { return 0; }
////
//// // Setter
//// set value(newValue: number) { return; }
////
//// // Static member
//// static origin = new Point(0, 0);
////
//// // Static method
//// private static getOrigin() { return Point.origin;}
//// }
////
//// enum Values { value1, value2, value3 }
////}
////
////// Local variables
////var p: IPoint = new Shapes.Point(3, 4);
////var dist = p.getDist();
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "dist",
"kind": "var"
},
{
"text": "IPoint",
"kind": "interface",
"childItems": [
{
"text": "()",
"kind": "call"
},
{
"text": "new()",
"kind": "construct"
},
{
"text": "[]",
"kind": "index"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "prop",
"kind": "property"
}
]
},
{
"text": "p",
"kind": "var"
},
{
"text": "Shapes",
"kind": "module",
"childItems": [
{
"text": "Point",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "getOrigin",
"kind": "method",
"kindModifiers": "private,static"
},
{
"text": "origin",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "value",
"kind": "getter"
},
{
"text": "value",
"kind": "setter"
},
{
"text": "x",
"kind": "property",
"kindModifiers": "public"
},
{
"text": "y",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "Values",
"kind": "enum",
"childItems": [
{
"text": "value1",
"kind": "enum member"
},
{
"text": "value2",
"kind": "enum member"
},
{
"text": "value3",
"kind": "enum member"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "dist",
"kind": "var"
},
{
"text": "IPoint",
"kind": "interface"
},
{
"text": "p",
"kind": "var"
},
{
"text": "Shapes",
"kind": "module"
}
]
},
{
"text": "IPoint",
"kind": "interface",
"childItems": [
{
"text": "()",
"kind": "call"
},
{
"text": "new()",
"kind": "construct"
},
{
"text": "[]",
"kind": "index"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "prop",
"kind": "property"
}
],
"indent": 1
},
{
"text": "Shapes",
"kind": "module",
"childItems": [
{
"text": "Point",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "Values",
"kind": "enum"
}
],
"indent": 1
},
{
"text": "Point",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "getOrigin",
"kind": "method",
"kindModifiers": "private,static"
},
{
"text": "origin",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "value",
"kind": "getter"
},
{
"text": "value",
"kind": "setter"
},
{
"text": "x",
"kind": "property",
"kindModifiers": "public"
},
{
"text": "y",
"kind": "property",
"kindModifiers": "public"
}
],
"indent": 2
},
{
"text": "Values",
"kind": "enum",
"childItems": [
{
"text": "value1",
"kind": "enum member"
},
{
"text": "value2",
"kind": "enum member"
},
{
"text": "value3",
"kind": "enum member"
}
],
"indent": 2
}
]);
| {
"end_byte": 7221,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/server/navbar01.ts"
} |
TypeScript/tests/cases/compiler/inlineSourceMap.ts_0_69 | // @target: ES5
// @inlinesourcemap: true
var x = 0;
console.log(x); | {
"end_byte": 69,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inlineSourceMap.ts"
} |
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts_0_75 | var v: any[];
function foo(a = (1 + 1)) { }
function bar(a = (1 + 1)) {
} | {
"end_byte": 75,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts"
} |
TypeScript/tests/cases/compiler/sourceMapValidationTryCatchFinally.ts_0_214 | // @sourcemap: true
var x = 10;
try {
x = x + 1;
} catch (e) {
x = x - 1;
} finally {
x = x * 10;
}
try
{
x = x + 1;
throw new Error();
}
catch (e)
{
x = x - 1;
}
finally
{
x = x * 10;
} | {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationTryCatchFinally.ts"
} |
TypeScript/tests/cases/compiler/decoratorMetadataGenericTypeVariable.ts_0_135 | // @experimentalDecorators: true
// @emitDecoratorMetadata: true
export class C<TypeVariable> {
@Decorate
member: TypeVariable;
}
| {
"end_byte": 135,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataGenericTypeVariable.ts"
} |
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts_3_62 | @sourcemap: true
var [x] = [1, 2];
var [y, z] = [1, 2]; | {
"end_byte": 62,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts_0_116 | // @declaration: true
// @lib: es6
const _data = Symbol('data');
export class User {
private [_data] : any;
};
| {
"end_byte": 116,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts"
} |
TypeScript/tests/cases/compiler/arrayAssignmentTest6.ts_0_472 | module Test {
interface IState {
}
interface IToken {
startIndex: number;
}
interface ILineTokens {
tokens: IToken[];
endState: IState;
}
interface IMode {
tokenize(line:string, state:IState, includeStates:boolean):ILineTokens;
}
export class Bug implements IMode {
public tokenize(line:string, tokens:IToken[], includeStates:boolean):ILineTokens {
return null;
}
}
}
| {
"end_byte": 472,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayAssignmentTest6.ts"
} |
TypeScript/tests/cases/compiler/functionDeclarationWithResolutionOfTypeNamedArguments01.ts_3_70 | terface arguments {
}
function f() {
<arguments>arguments;
} | {
"end_byte": 70,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionDeclarationWithResolutionOfTypeNamedArguments01.ts"
} |
TypeScript/tests/cases/compiler/propagateNonInferrableType.ts_0_165 | // @strict: true
declare function resolver<T>(): () => void;
declare function wrapResolver<T>(resolverFunction: () => void): void;
wrapResolver(resolver() || []);
| {
"end_byte": 165,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propagateNonInferrableType.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitRetainsJsdocyComments.ts_0_617 | // @declaration: true
/**
* comment1
* @param p
*/
export const foo = (p: string) => {
return {
/**
* comment2
* @param s
*/
bar: (s: number) => {},
/**
* comment3
* @param s
*/
bar2(s: number) {},
}
}
export class Foo {
/**
* comment4
* @param s
*/
bar(s: number) {
}
}
export let {
/**
* comment5
*/
someMethod
} = null as any;
declare global {
interface ExtFunc {
/**
* comment6
*/
someMethod(collection: any[]): boolean;
}
}
| {
"end_byte": 617,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitRetainsJsdocyComments.ts"
} |
TypeScript/tests/cases/compiler/conditionalTypeSubclassExtendsTypeParam.ts_0_189 | declare class Model<M extends MR, MR extends {}> {
public getField2<K extends keyof M>(): Field<M[K], [K] extends [keyof MR] ? MR[K] : M[K]>
}
declare class Field<T extends TR, TR> {
} | {
"end_byte": 189,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeSubclassExtendsTypeParam.ts"
} |
TypeScript/tests/cases/compiler/parseErrorDoubleCommaInCall.ts_0_25 | Boolean({
x: 0,,
});
| {
"end_byte": 25,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseErrorDoubleCommaInCall.ts"
} |
TypeScript/tests/cases/compiler/destructuringWithGenericParameter.ts_0_359 | class GenericClass<T> {
payload: T;
}
var genericObject = new GenericClass<{ greeting: string }>();
function genericFunction<T>(object: GenericClass<T>, callback: (payload: T) => void) {
callback(object.payload);
}
genericFunction(genericObject, ({greeting}) => {
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
});
| {
"end_byte": 359,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringWithGenericParameter.ts"
} |
TypeScript/tests/cases/compiler/es5-asyncFunctionNewExpressions.ts_0_1430 | // @lib: es5,es2015.promise
// @noEmitHelpers: true
// @target: ES5
declare var x, y, z, a, b, c;
async function newExpression0() {
await new x(y, z);
}
async function newExpression1() {
new (await x)(y, z);
}
async function newExpression2() {
new x(await y, z);
}
async function newExpression3() {
new x(y, await z);
}
async function newExpression4() {
await new x(...y, z);
}
async function newExpression5() {
new (await x)(...y, z);
}
async function newExpression6() {
new x(...(await y), z);
}
async function newExpression7() {
new x(...y, await z);
}
async function newExpression8() {
new x(await y, ...z);
}
async function newExpression9() {
new x(y, ...(await z));
}
async function newExpression10() {
await new x.a(y, z);
}
async function newExpression11() {
new (await x.a)(y, z);
}
async function newExpression12() {
new (await x).a(y, z);
}
async function newExpression13() {
new x.a(await y, z);
}
async function newExpression14() {
new x.a(y, await z);
}
async function newExpression15() {
await new x[a](y, z);
}
async function newExpression16() {
new (await x[a])(y, z);
}
async function newExpression17() {
new (await x)[a](y, z);
}
async function newExpression18() {
new x[await a](y, z);
}
async function newExpression19() {
new x[a](await y, z);
}
async function newExpression20() {
new x[a](y, await z);
} | {
"end_byte": 1430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionNewExpressions.ts"
} |
TypeScript/tests/cases/compiler/es5-asyncFunctionTryStatements.ts_0_1666 | // @lib: es5,es2015.promise
// @noEmitHelpers: true
// @target: ES5
declare var x: any, y: any, z: any, a: any, b: any, c: any;
async function tryCatch0() {
var x: any, y: any;
try {
x;
}
catch (e) {
y;
}
}
async function tryCatch1() {
var x: any, y: any;
try {
await x;
}
catch (e) {
y;
}
}
async function tryCatch2() {
var x: any, y: any;
try {
x;
}
catch (e) {
await y;
}
}
async function tryCatch3(): Promise<Function> {
var x: any, y: any;
try {
await x;
}
catch (e) {
return () => e;
}
}
async function tryFinally0() {
var x: any, y: any;
try {
x;
}
finally {
y;
}
}
async function tryFinally1() {
var x: any, y: any;
try {
await x;
}
finally {
y;
}
}
async function tryFinally2() {
var x: any, y: any;
try {
x;
}
finally {
await y;
}
}
async function tryCatchFinally0() {
var x: any, y: any, z: any;
try {
x;
}
catch (e) {
y;
}
finally {
z;
}
}
async function tryCatchFinally1() {
var x: any, y: any, z: any;
try {
await x;
}
catch (e) {
y;
}
finally {
z;
}
}
async function tryCatchFinally2() {
var x: any, y: any, z: any;
try {
x;
}
catch (e) {
await y;
}
finally {
z;
}
}
async function tryCatchFinally3() {
var x: any, y: any, z: any;
try {
x;
}
catch (e) {
y;
}
finally {
await z;
}
} | {
"end_byte": 1666,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionTryStatements.ts"
} |
TypeScript/tests/cases/compiler/moduleAndInterfaceSharingName4.ts_0_144 | declare module D3 {
var x: D3.Color.Color;
module Color {
export interface Color {
darker: Color;
}
}
} | {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAndInterfaceSharingName4.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitOptionalMethod.ts_0_167 | // @declaration: true
// @strictNullChecks: true
export const Foo = (opts: {
a?(): void,
b?: () => void,
}): {
c?(): void,
d?: () => void,
} => ({ }); | {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitOptionalMethod.ts"
} |
TypeScript/tests/cases/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.ts_0_56 | // @allowJs: true
// @filename: a.js
function F<T>() { } | {
"end_byte": 56,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.ts"
} |
TypeScript/tests/cases/compiler/exportAssignmentOfGenericType1.ts_0_330 | //@module: amd
// @Filename: exportAssignmentOfGenericType1_0.ts
export = T;
class T<X> { foo: X; }
// @Filename: exportAssignmentOfGenericType1_1.ts
///<reference path='exportAssignmentOfGenericType1_0.ts'/>
import q = require("exportAssignmentOfGenericType1_0");
class M extends q<string> { }
var m: M;
var r: string = m.foo;
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentOfGenericType1.ts"
} |
TypeScript/tests/cases/compiler/defaultIsNotVisibleInLocalScope.ts_0_210 | // @filename: a.ts
export default function () {
return true;
}
export type X = typeof default; // expect error
// @filename: b.ts
export default { a: true }
export type X = typeof default; // expect error | {
"end_byte": 210,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultIsNotVisibleInLocalScope.ts"
} |
TypeScript/tests/cases/compiler/recursiveResolveDeclaredMembers.ts_0_223 | // #23025
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: types.ts
export interface F {
(): E;
}
export interface D<T extends F = F> {}
// @Filename: other.js
/** @typedef {import("./types").D} E */
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveResolveDeclaredMembers.ts"
} |
TypeScript/tests/cases/compiler/typeAliasDeclarationEmit.ts_0_147 | // @target: ES5
// @module: AMD
// @declaration: true
export type callback<T> = () => T;
export type CallbackArray<T extends callback> = () => T; | {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasDeclarationEmit.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitAliasExportStar.ts_0_237 | // @declaration: true
// @filename: thingB.ts
export interface ThingB { }
// @filename: things.ts
export * from "./thingB";
// @filename: index.ts
import * as things from "./things";
export const thing2 = (param: things.ThingB) => null;
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitAliasExportStar.ts"
} |
TypeScript/tests/cases/compiler/commentOnAmbientEnum.ts_0_267 | //@filename: a.ts
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare enum C {
a,
b,
c
}
// Don't keep this comment.
declare enum D {
}
//@filename: b.ts
///<reference path="a.ts"/>
declare enum E {
} | {
"end_byte": 267,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnAmbientEnum.ts"
} |
TypeScript/tests/cases/compiler/collisionThisExpressionAndFunctionInGlobal.ts_0_63 | function _this() { //Error
return 10;
}
var f = () => this; | {
"end_byte": 63,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndFunctionInGlobal.ts"
} |
TypeScript/tests/cases/compiler/arrowFunctionWithObjectLiteralBody5.ts_0_242 | var a = () => <Error>{ name: "foo", message: "bar" };
var b = () => (<Error>{ name: "foo", message: "bar" });
var c = () => ({ name: "foo", message: "bar" });
var d = () => ((<Error>({ name: "foo", message: "bar" }))); | {
"end_byte": 242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionWithObjectLiteralBody5.ts"
} |
TypeScript/tests/cases/compiler/privacyTypeParametersOfClassDeclFile.ts_0_3693 | // @module: commonjs
// @declaration: true
class privateClass {
}
export class publicClass {
}
export class publicClassWithPrivateTypeParameters<T extends privateClass> { // Error
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParameters<T extends publicClass> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPrivateTypeParameters<T extends privateClass> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParameters<T extends publicClass> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithTypeParametersFromPrivateModule<T extends privateModule.publicClassInPrivateModule> { // Error
myMethod(val: T): T {
return val;
}
}
class privateClassWithTypeParametersFromPrivateModule<T extends privateModule.publicClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
export module publicModule {
class privateClassInPublicModule {
}
export class publicClassInPublicModule {
}
export class publicClassWithPrivateTypeParameters<T extends privateClassInPublicModule> { // Error
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParameters<T extends publicClassInPublicModule> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPrivateTypeParameters<T extends privateClassInPublicModule> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParameters<T extends publicClassInPublicModule> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithTypeParametersFromPrivateModule<T extends privateModule.publicClassInPrivateModule> { // Error
myMethod(val: T): T {
return val;
}
}
class privateClassWithTypeParametersFromPrivateModule<T extends privateModule.publicClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
}
module privateModule {
class privateClassInPrivateModule {
}
export class publicClassInPrivateModule {
}
export class publicClassWithPrivateTypeParameters<T extends privateClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParameters<T extends publicClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPrivateTypeParameters<T extends privateClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParameters<T extends publicClassInPrivateModule> {
myMethod(val: T): T {
return val;
}
}
export class publicClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
class privateClassWithPublicTypeParametersWithoutExtends<T> {
myMethod(val: T): T {
return val;
}
}
}
| {
"end_byte": 3693,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTypeParametersOfClassDeclFile.ts"
} |
TypeScript/tests/cases/compiler/modulePreserve4.ts_0_2942 | // @module: preserve
// @target: esnext
// @verbatimModuleSyntax: true
// @checkJs: true
// @outDir: dist
// @declaration: true
// @strict: true
// @Filename: /a.js
export const x = 0;
module.exports.y = 0; // Error
// @Filename: /b.ts
export default 0;
// @Filename: /c.ts
export = {
default: function() {}
};
// @Filename: /d.ts
export = function() {};
// @Filename: /e.mts
export = 0;
// @Filename: /f.cts
export default 0;
// @Filename: /g.js
exports.default = 0;
// @Filename: /main1.ts
import { x, y } from "./a"; // No y
import a1 = require("./a"); // { x: 0 }
const a2 = require("./a"); // Error in TS
const a3 = await import("./a"); // { x: 0 }
a3.x;
import b1 from "./b"; // 0
import b2 = require("./b"); // { default: 0 }
b2.default;
const b3 = await import("./b"); // { default: 0 }
b3.default;
import c1 from "./c"; // { default: [Function: default] }
import c2 = require("./c"); // { default: [Function: default] }
c2.default;
import d1 from "./d"; // [Function: default]
import d2 = require("./d"); // [Function: default]
d2();
d2.default(); // Error
const d3 = await import("./d"); // { default: [Function: default] }
d3.default();
import e1 from "./e.mjs"; // 0
import e2 = require("./e.mjs"); // 0
import f1 from "./f.cjs"; // 0
import f2 = require("./f.cjs"); // { default: 0 }
f2.default;
import g1 from "./g"; // { default: 0 }
g1.default;
import g2 = require("./g"); // { default: 0 }
g2.default;
// @Filename: /main2.mts
import { x, y } from "./a"; // No y
import a1 = require("./a"); // { x: 0 }
a1.x;
a1.default.x; // Arguably should exist but doesn't
const a2 = require("./a"); // Error in TS
import b1 from "./b"; // 0
import b2 = require("./b"); // { default: 0 }
import c1 from "./c"; // { default: [Function: default] }
import c2 = require("./c"); // { default: [Function: default] }
import d1 from "./d"; // [Function: default]
import d2 = require("./d"); // [Function: default]
import e1 from "./e.mjs"; // 0
import e2 = require("./e.mjs"); // 0
import f1 from "./f.cjs"; // 0
import f2 = require("./f.cjs"); // { default: 0 }
import g1 from "./g"; // { default: 0 }
import g2 = require("./g"); // { default: 0 }
// @Filename: /main3.cjs
import { x, y } from "./a"; // No y
import a1 = require("./a"); // Error in JS
const a2 = require("./a"); // { x: 0 }
import b1 from "./b"; // 0
const b2 = require("./b"); // { default: 0 }
import c1 from "./c"; // { default: [Function: default] }
const c2 = require("./c"); // { default: [Function: default] }
import d1 from "./d"; // [Function: default]
const d2 = require("./d"); // [Function: default]
import e1 from "./e.mjs"; // 0
const e2 = require("./e.mjs"); // 0
import f1 from "./f.cjs"; // 0
const f2 = require("./f.cjs"); // { default: 0 }
import g1 from "./g"; // { default: 0 }
const g2 = require("./g"); // { default: 0 }
// @Filename: /main4.cjs
exports.x = require("./g");
// @Filename: /dummy.ts
export {}; // Silly test harness
| {
"end_byte": 2942,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePreserve4.ts"
} |
TypeScript/tests/cases/compiler/interfacedeclWithIndexerErrors.ts_0_644 | interface a0 {
(): string;
(a, b, c?: string): number;
new (): string;
new (s: string);
[n: number]: ()=>string;
[s: string]: ()=>string;
p1;
p2: string;
p3?;
p4?: number;
p5: (s: number) =>string;
f1();
f2? ();
f3(a: string): number;
f4? (s: number): string;
}
interface a1 {
[n: number]: number;
}
interface a2 {
[s: string]: number;
}
interface a {
}
interface b extends a {
}
interface c extends a, b {
}
interface d extends a {
}
interface e extends number {
}
interface f {
prop: typeof string;
}
class c1 implements a {
}
var instance2 = new c1(); | {
"end_byte": 644,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfacedeclWithIndexerErrors.ts"
} |
TypeScript/tests/cases/compiler/pathsValidation1.ts_0_166 | // @filename: tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": "*"
}
}
}
// @filename: a.ts
let x = 1; | {
"end_byte": 166,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathsValidation1.ts"
} |
TypeScript/tests/cases/compiler/emptyExpr.ts_0_5 | [{},] | {
"end_byte": 5,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyExpr.ts"
} |
TypeScript/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts_0_279 | function f<T, U>(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(b, x => x.a, a); // type [A, A]
var d2 = f(b, x => x.a, null); // type [B, A]
var d3 = f(b, x => x.b, null); // type [B, any] | {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts"
} |
TypeScript/tests/cases/compiler/errorSupression1.ts_1_147 | class Foo { static bar() { return "x"; } }
var baz = Foo.b;
// Foo.b won't bind.
baz.concat("y");
// So we don't want an error on 'concat'. | {
"end_byte": 147,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorSupression1.ts"
} |
TypeScript/tests/cases/compiler/constEnumOnlyModuleMerging.ts_0_158 | module Outer {
export var x = 1;
}
module Outer {
export const enum A { X }
}
module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
} | {
"end_byte": 158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumOnlyModuleMerging.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.