diff --git a/src/jsTyping/types.ts b/src/jsTyping/types.ts index a9991a2f086c7..8d84a0d3bfdfb 100644 --- a/src/jsTyping/types.ts +++ b/src/jsTyping/types.ts @@ -51,6 +51,7 @@ export interface InstallPackageRequest extends TypingInstallerRequestWithProject readonly fileName: Path; readonly packageName: string; readonly projectRootPath: Path; + readonly id: number; } /** @internal */ @@ -61,6 +62,7 @@ export interface TypesRegistryResponse extends TypingInstallerResponse { export interface PackageInstalledResponse extends ProjectResponse { readonly kind: ActionPackageInstalled; + readonly id: number; readonly success: boolean; readonly message: string; } diff --git a/src/server/typingInstallerAdapter.ts b/src/server/typingInstallerAdapter.ts index 71f7b9e636e1f..9470a17c0496e 100644 --- a/src/server/typingInstallerAdapter.ts +++ b/src/server/typingInstallerAdapter.ts @@ -46,6 +46,11 @@ export interface TypingsInstallerWorkerProcess { send(rq: T): void; } +interface PackageInstallPromise { + resolve(value: ApplyCodeActionCommandResult): void; + reject(reason: unknown): void; +} + /** @internal */ export abstract class TypingsInstallerAdapter implements ITypingsInstaller { protected installer!: TypingsInstallerWorkerProcess; @@ -63,10 +68,8 @@ export abstract class TypingsInstallerAdapter implements ITypingsInstaller { // It would be preferable to base our limit on the amount of space left in the // buffer, but we have yet to find a way to retrieve that value. private static readonly requestDelayMillis = 100; - private packageInstalledPromise: { - resolve(value: ApplyCodeActionCommandResult): void; - reject(reason: unknown): void; - } | undefined; + private packageInstalledPromise: Map | undefined; + private packageInstallId = 0; constructor( protected readonly telemetryEnabled: boolean, @@ -92,11 +95,13 @@ export abstract class TypingsInstallerAdapter implements ITypingsInstaller { } installPackage(options: InstallPackageOptionsWithProject): Promise { - this.installer.send({ kind: "installPackage", ...options }); - Debug.assert(this.packageInstalledPromise === undefined); - return new Promise((resolve, reject) => { - this.packageInstalledPromise = { resolve, reject }; + this.packageInstallId++; + const request: InstallPackageRequest = { kind: "installPackage", ...options, id: this.packageInstallId }; + const promise = new Promise((resolve, reject) => { + (this.packageInstalledPromise ??= new Map()).set(this.packageInstallId, { resolve, reject }); }); + this.installer.send(request); + return promise; } attach(projectService: ProjectService) { @@ -136,15 +141,15 @@ export abstract class TypingsInstallerAdapter implements ITypingsInstaller { this.typesRegistryCache = new Map(Object.entries(response.typesRegistry)); break; case ActionPackageInstalled: { - const { success, message } = response; - if (success) { - this.packageInstalledPromise!.resolve({ successMessage: message }); + const promise = this.packageInstalledPromise?.get(response.id); + Debug.assertIsDefined(promise, "Should find the promise for package install"); + this.packageInstalledPromise?.delete(response.id); + if (response.success) { + promise.resolve({ successMessage: response.message }); } else { - this.packageInstalledPromise!.reject(message); + promise.reject(response.message); } - this.packageInstalledPromise = undefined; - this.projectService.updateTypingsForProject(response); // The behavior is the same as for setTypings, so send the same event. diff --git a/src/testRunner/tests.ts b/src/testRunner/tests.ts index 2a5d2de2b383e..01d5ddea11d4d 100644 --- a/src/testRunner/tests.ts +++ b/src/testRunner/tests.ts @@ -140,6 +140,7 @@ import "./unittests/tsserver/autoImportProvider"; import "./unittests/tsserver/auxiliaryProject"; import "./unittests/tsserver/cachingFileSystemInformation"; import "./unittests/tsserver/cancellationToken"; +import "./unittests/tsserver/codeFix"; import "./unittests/tsserver/compileOnSave"; import "./unittests/tsserver/completions"; import "./unittests/tsserver/completionsIncomplete"; diff --git a/src/testRunner/unittests/tsserver/codeFix.ts b/src/testRunner/unittests/tsserver/codeFix.ts new file mode 100644 index 0000000000000..97ff4c4058c9b --- /dev/null +++ b/src/testRunner/unittests/tsserver/codeFix.ts @@ -0,0 +1,65 @@ +import * as ts from "../../_namespaces/ts"; +import { + dedent, +} from "../../_namespaces/Utils"; +import { + baselineTsserverLogs, + openFilesForSession, + TestSession, +} from "../helpers/tsserver"; +import { + createServerHost, + libFile, +} from "../helpers/virtualFileSystemWithWatch"; + +describe("unittests:: tsserver:: codeFix::", () => { + function setup() { + const host = createServerHost({ + "/home/src/projects/project/src/file.ts": dedent` + import * as os from "os"; + import * as https from "https"; + import * as vscode from "vscode"; + `, + "/home/src/projects/project/tsconfig.json": "{ }", + "/home/src/projects/project/node_modules/vscode/index.js": "export const x = 10;", + [libFile.path]: libFile.content, + }); + const session = new TestSession({ host, typesRegistry: ["vscode"] }); + openFilesForSession(["/home/src/projects/project/src/file.ts"], session); + const actions = session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.GetCombinedCodeFix, + arguments: { + scope: { type: "file", args: { file: "/home/src/projects/project/src/file.ts" } }, + fixId: "installTypesPackage", + }, + }).response as ts.server.protocol.CombinedCodeActions; + return { host, session, actions }; + } + it("install package", () => { + const { host, session, actions } = setup(); + actions.commands?.forEach(command => + session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.ApplyCodeActionCommand, + arguments: { + command, + }, + }) + ); + host.runPendingInstalls(); + baselineTsserverLogs("codeFix", "install package", session); + }); + + it("install package when serialized", () => { + const { host, session, actions } = setup(); + actions.commands?.forEach(command => { + session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.ApplyCodeActionCommand, + arguments: { + command, + }, + }); + host.runPendingInstalls(); + }); + baselineTsserverLogs("codeFix", "install package when serialized", session); + }); +}); diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index e0821418813bb..96a7d169d0cfc 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -233,7 +233,7 @@ export abstract class TypingsInstaller { /** @internal */ installPackage(req: InstallPackageRequest) { - const { fileName, packageName, projectName, projectRootPath } = req; + const { fileName, packageName, projectName, projectRootPath, id } = req; const cwd = forEachAncestorDirectory(getDirectoryPath(fileName), directory => { if (this.installTypingHost.fileExists(combinePaths(directory, "package.json"))) { return directory; @@ -247,6 +247,7 @@ export abstract class TypingsInstaller { const response: PackageInstalledResponse = { kind: ActionPackageInstalled, projectName, + id, success, message, }; @@ -257,6 +258,7 @@ export abstract class TypingsInstaller { const response: PackageInstalledResponse = { kind: ActionPackageInstalled, projectName, + id, success: false, message: "Could not determine a project root path.", }; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index eddf759a20b84..7135bb7863324 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -49,9 +49,11 @@ declare namespace ts { readonly fileName: Path; readonly packageName: string; readonly projectRootPath: Path; + readonly id: number; } interface PackageInstalledResponse extends ProjectResponse { readonly kind: ActionPackageInstalled; + readonly id: number; readonly success: boolean; readonly message: string; } diff --git a/tests/baselines/reference/tsserver/codeFix/install-package-when-serialized.js b/tests/baselines/reference/tsserver/codeFix/install-package-when-serialized.js new file mode 100644 index 0000000000000..9faded93a5159 --- /dev/null +++ b/tests/baselines/reference/tsserver/codeFix/install-package-when-serialized.js @@ -0,0 +1,461 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist +Before request +//// [/home/src/projects/project/src/file.ts] +import * as os from "os"; +import * as https from "https"; +import * as vscode from "vscode"; + + +//// [/home/src/projects/project/tsconfig.json] +{ } + +//// [/home/src/projects/project/node_modules/vscode/index.js] +export const x = 10; + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +Info seq [hh:mm:ss:mss] request: + { + "command": "open", + "arguments": { + "file": "/home/src/projects/project/src/file.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /home/src/projects/project/src +Info seq [hh:mm:ss:mss] For info: /home/src/projects/project/src/file.ts :: Config file name: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/project/tsconfig.json 2000 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingStart", + "body": { + "projectName": "/home/src/projects/project/tsconfig.json", + "reason": "Creating possible configured project for /home/src/projects/project/src/file.ts to open" + } + } +Info seq [hh:mm:ss:mss] Config: /home/src/projects/project/tsconfig.json : { + "rootNames": [ + "/home/src/projects/project/src/file.ts" + ], + "options": { + "configFilePath": "/home/src/projects/project/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 1 undefined Config: /home/src/projects/project/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 1 undefined Config: /home/src/projects/project/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/src 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/src 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /home/src/projects/project/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/home/src/projects/project/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (2) + /a/lib/lib.d.ts Text-1 "/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }" + /home/src/projects/project/src/file.ts SVC-1-0 "import * as os from \"os\";\nimport * as https from \"https\";\nimport * as vscode from \"vscode\";\n" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + src/file.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingFinish", + "body": { + "projectName": "/home/src/projects/project/tsconfig.json" + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "telemetry", + "body": { + "telemetryEventName": "projectInfo", + "payload": { + "projectId": "1097a5f82e8323ba7aba7567ec06402f7ad4ea74abce44ec5efd223ac77ff169", + "fileStats": { + "js": 0, + "jsSize": 0, + "jsx": 0, + "jsxSize": 0, + "ts": 1, + "tsSize": 92, + "tsx": 0, + "tsxSize": 0, + "dts": 1, + "dtsSize": 334, + "deferred": 0, + "deferredSize": 0 + }, + "compilerOptions": {}, + "typeAcquisition": { + "enable": false, + "include": false, + "exclude": false + }, + "extends": false, + "files": false, + "include": false, + "exclude": false, + "compileOnSave": false, + "configFileName": "tsconfig.json", + "projectType": "configured", + "languageServiceEnabled": true, + "version": "FakeVersion" + } + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "configFileDiag", + "body": { + "triggerFile": "/home/src/projects/project/src/file.ts", + "configFile": "/home/src/projects/project/tsconfig.json", + "diagnostics": [] + } + } +Info seq [hh:mm:ss:mss] Project '/home/src/projects/project/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (2) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /home/src/projects/project/src/file.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +PolledWatches:: +/home/src/projects/node_modules: *new* + {"pollingInterval":500} +/home/src/projects/node_modules/@types: *new* + {"pollingInterval":500} +/home/src/projects/project/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: *new* + {} +/home/src/projects/project/tsconfig.json: *new* + {} + +FsWatchesRecursive:: +/home/src/projects/project: *new* + {} +/home/src/projects/project/node_modules: *new* + {} +/home/src/projects/project/src: *new* + {} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "getCombinedCodeFix", + "arguments": { + "scope": { + "type": "file", + "args": { + "file": "/home/src/projects/project/src/file.ts" + } + }, + "fixId": "installTypesPackage" + }, + "seq": 2, + "type": "request" + } +TI:: Creating typing installer + +TI:: [hh:mm:ss:mss] Global cache location '/a/data', safe file path '/safeList.json', types map path /typesMap.json +TI:: [hh:mm:ss:mss] Processing cache location '/a/data' +TI:: [hh:mm:ss:mss] Trying to find '/a/data/package.json'... +TI:: [hh:mm:ss:mss] Finished processing cache location '/a/data' +TI:: [hh:mm:ss:mss] Npm config file: /a/data/package.json +TI:: [hh:mm:ss:mss] Npm config file: '/a/data/package.json' is missing, creating new one... +TI:: [hh:mm:ss:mss] Updating types-registry npm package... +TI:: [hh:mm:ss:mss] npm install --ignore-scripts types-registry@latest +TI:: [hh:mm:ss:mss] Updated types-registry npm package +TI:: typing installer creation complete +//// [/a/data/package.json] +{ "private": true } + +//// [/a/data/node_modules/types-registry/index.json] +{ + "entries": { + "vscode": { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + } + } +} + + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "event::typesRegistry", + "typesRegistry": { + "vscode": { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + } + } + } +Info seq [hh:mm:ss:mss] response: + { + "response": { + "changes": [], + "commands": [ + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + }, + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + }, + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/vscode" + } + ] + }, + "responseRequired": true + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + } + }, + "seq": 3, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/node" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 1 +1: #-1 with arguments:: [ + "@types/node" +] *new* + +Before running PendingInstalls callback:: count: 1 +1: #-1 with arguments:: [ + "@types/node" +] + +TI:: Installation #-1 with arguments:: [ + "@types/node" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 1, + "success": true, + "message": "Package @types/node installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 1, + "success": true, + "message": "Package @types/node installed." + } + } +After running PendingInstalls callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + } + }, + "seq": 4, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/node" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 1 +2: #-1 with arguments:: [ + "@types/node" +] *new* + +Before running PendingInstalls callback:: count: 1 +2: #-1 with arguments:: [ + "@types/node" +] + +TI:: Installation #-1 with arguments:: [ + "@types/node" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 2, + "success": true, + "message": "Package @types/node installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 2, + "success": true, + "message": "Package @types/node installed." + } + } +After running PendingInstalls callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/vscode" + } + }, + "seq": 5, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/vscode" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 1 +3: #-1 with arguments:: [ + "@types/vscode" +] *new* + +Before running PendingInstalls callback:: count: 1 +3: #-1 with arguments:: [ + "@types/vscode" +] + +TI:: Installation #-1 with arguments:: [ + "@types/vscode" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 3, + "success": true, + "message": "Package @types/vscode installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 3, + "success": true, + "message": "Package @types/vscode installed." + } + } +After running PendingInstalls callback:: count: 0 diff --git a/tests/baselines/reference/tsserver/codeFix/install-package.js b/tests/baselines/reference/tsserver/codeFix/install-package.js new file mode 100644 index 0000000000000..397bc5c63a8c0 --- /dev/null +++ b/tests/baselines/reference/tsserver/codeFix/install-package.js @@ -0,0 +1,462 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist +Before request +//// [/home/src/projects/project/src/file.ts] +import * as os from "os"; +import * as https from "https"; +import * as vscode from "vscode"; + + +//// [/home/src/projects/project/tsconfig.json] +{ } + +//// [/home/src/projects/project/node_modules/vscode/index.js] +export const x = 10; + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +Info seq [hh:mm:ss:mss] request: + { + "command": "open", + "arguments": { + "file": "/home/src/projects/project/src/file.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /home/src/projects/project/src +Info seq [hh:mm:ss:mss] For info: /home/src/projects/project/src/file.ts :: Config file name: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/project/tsconfig.json 2000 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingStart", + "body": { + "projectName": "/home/src/projects/project/tsconfig.json", + "reason": "Creating possible configured project for /home/src/projects/project/src/file.ts to open" + } + } +Info seq [hh:mm:ss:mss] Config: /home/src/projects/project/tsconfig.json : { + "rootNames": [ + "/home/src/projects/project/src/file.ts" + ], + "options": { + "configFilePath": "/home/src/projects/project/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 1 undefined Config: /home/src/projects/project/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project 1 undefined Config: /home/src/projects/project/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/src 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/src 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules/@types 1 undefined Project: /home/src/projects/project/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /home/src/projects/project/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/home/src/projects/project/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (2) + /a/lib/lib.d.ts Text-1 "/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }" + /home/src/projects/project/src/file.ts SVC-1-0 "import * as os from \"os\";\nimport * as https from \"https\";\nimport * as vscode from \"vscode\";\n" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + src/file.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingFinish", + "body": { + "projectName": "/home/src/projects/project/tsconfig.json" + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "telemetry", + "body": { + "telemetryEventName": "projectInfo", + "payload": { + "projectId": "1097a5f82e8323ba7aba7567ec06402f7ad4ea74abce44ec5efd223ac77ff169", + "fileStats": { + "js": 0, + "jsSize": 0, + "jsx": 0, + "jsxSize": 0, + "ts": 1, + "tsSize": 92, + "tsx": 0, + "tsxSize": 0, + "dts": 1, + "dtsSize": 334, + "deferred": 0, + "deferredSize": 0 + }, + "compilerOptions": {}, + "typeAcquisition": { + "enable": false, + "include": false, + "exclude": false + }, + "extends": false, + "files": false, + "include": false, + "exclude": false, + "compileOnSave": false, + "configFileName": "tsconfig.json", + "projectType": "configured", + "languageServiceEnabled": true, + "version": "FakeVersion" + } + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "configFileDiag", + "body": { + "triggerFile": "/home/src/projects/project/src/file.ts", + "configFile": "/home/src/projects/project/tsconfig.json", + "diagnostics": [] + } + } +Info seq [hh:mm:ss:mss] Project '/home/src/projects/project/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (2) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /home/src/projects/project/src/file.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /home/src/projects/project/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +PolledWatches:: +/home/src/projects/node_modules: *new* + {"pollingInterval":500} +/home/src/projects/node_modules/@types: *new* + {"pollingInterval":500} +/home/src/projects/project/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: *new* + {} +/home/src/projects/project/tsconfig.json: *new* + {} + +FsWatchesRecursive:: +/home/src/projects/project: *new* + {} +/home/src/projects/project/node_modules: *new* + {} +/home/src/projects/project/src: *new* + {} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "getCombinedCodeFix", + "arguments": { + "scope": { + "type": "file", + "args": { + "file": "/home/src/projects/project/src/file.ts" + } + }, + "fixId": "installTypesPackage" + }, + "seq": 2, + "type": "request" + } +TI:: Creating typing installer + +TI:: [hh:mm:ss:mss] Global cache location '/a/data', safe file path '/safeList.json', types map path /typesMap.json +TI:: [hh:mm:ss:mss] Processing cache location '/a/data' +TI:: [hh:mm:ss:mss] Trying to find '/a/data/package.json'... +TI:: [hh:mm:ss:mss] Finished processing cache location '/a/data' +TI:: [hh:mm:ss:mss] Npm config file: /a/data/package.json +TI:: [hh:mm:ss:mss] Npm config file: '/a/data/package.json' is missing, creating new one... +TI:: [hh:mm:ss:mss] Updating types-registry npm package... +TI:: [hh:mm:ss:mss] npm install --ignore-scripts types-registry@latest +TI:: [hh:mm:ss:mss] Updated types-registry npm package +TI:: typing installer creation complete +//// [/a/data/package.json] +{ "private": true } + +//// [/a/data/node_modules/types-registry/index.json] +{ + "entries": { + "vscode": { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + } + } +} + + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "event::typesRegistry", + "typesRegistry": { + "vscode": { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + } + } + } +Info seq [hh:mm:ss:mss] response: + { + "response": { + "changes": [], + "commands": [ + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + }, + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + }, + { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/vscode" + } + ] + }, + "responseRequired": true + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + } + }, + "seq": 3, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/node" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 1 +1: #-1 with arguments:: [ + "@types/node" +] *new* + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/node" + } + }, + "seq": 4, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/node" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 2 +1: #-1 with arguments:: [ + "@types/node" +] +2: #-1 with arguments:: [ + "@types/node" +] *new* + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "applyCodeActionCommand", + "arguments": { + "command": { + "type": "install package", + "file": "/home/src/projects/project/src/file.ts", + "packageName": "@types/vscode" + } + }, + "seq": 5, + "type": "request" + } +TI:: [hh:mm:ss:mss] #-1 with cwd: /home/src/projects/project arguments: [ + "@types/vscode" +] +Info seq [hh:mm:ss:mss] response: + { + "response": {}, + "responseRequired": true + } +After request + +PendingInstalls callback:: count: 3 +1: #-1 with arguments:: [ + "@types/node" +] +2: #-1 with arguments:: [ + "@types/node" +] +3: #-1 with arguments:: [ + "@types/vscode" +] *new* + +Before running PendingInstalls callback:: count: 3 +1: #-1 with arguments:: [ + "@types/node" +] +2: #-1 with arguments:: [ + "@types/node" +] +3: #-1 with arguments:: [ + "@types/vscode" +] + +TI:: Installation #-1 with arguments:: [ + "@types/node" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 1, + "success": true, + "message": "Package @types/node installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 1, + "success": true, + "message": "Package @types/node installed." + } + } +TI:: Installation #-1 with arguments:: [ + "@types/node" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 2, + "success": true, + "message": "Package @types/node installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 2, + "success": true, + "message": "Package @types/node installed." + } + } +TI:: Installation #-1 with arguments:: [ + "@types/vscode" +] complete with success::true + +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 3, + "success": true, + "message": "Package @types/vscode installed." + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "kind": "action::packageInstalled", + "projectName": "/home/src/projects/project/tsconfig.json", + "id": 3, + "success": true, + "message": "Package @types/vscode installed." + } + } +After running PendingInstalls callback:: count: 0