diff --git a/src/server/project.ts b/src/server/project.ts index 315475a50b4..a4261b9abd4 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1534,6 +1534,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo scheduleUpdate: boolean, ): void { if (setTypings) { + if (!this.getTypeAcquisition().enable) return; this.typingsCache = { compilerOptions: setTypings.compilerOptions, typeAcquisition: setTypings.typeAcquisition, diff --git a/tests/baselines/reference/tsserver/typeAquisition/receives-update-of-typings-after-project-changes.js b/tests/baselines/reference/tsserver/typeAquisition/receives-update-of-typings-after-project-changes.js index f1a46073a70..213026ff5fe 100644 --- a/tests/baselines/reference/tsserver/typeAquisition/receives-update-of-typings-after-project-changes.js +++ b/tests/baselines/reference/tsserver/typeAquisition/receives-update-of-typings-after-project-changes.js @@ -775,6 +775,122 @@ Info seq [hh:mm:ss:mss] extractUnresolvedImportsFromSourceFile:: /home/src/tsli Info seq [hh:mm:ss:mss] extractUnresolvedImportsFromSourceFile:: /users/user/projects/project1/node_modules/bar/index.js:: [] Info seq [hh:mm:ss:mss] extractUnresolvedImportsFromSourceFile:: /users/user/projects/project1/app.js:: ["bar"] Info seq [hh:mm:ss:mss] getUnresolvedImports:: Files:: 3 Done: ["bar"] +TI:: [hh:mm:ss:mss] Got install request + { + "projectName": "/users/user/projects/project1/jsconfig.json", + "fileNames": [ + "/home/src/tslibs/TS/Lib/lib.d.ts", + "/users/user/projects/project1/app.js" + ], + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "unresolvedImports": [ + "bar" + ], + "projectRootPath": "/users/user/projects/project1", + "kind": "discover" + } +TI:: [hh:mm:ss:mss] Explicitly included types: [] +TI:: [hh:mm:ss:mss] Searching for typing names in /users/user/projects/project1/node_modules; all files: [] +TI:: [hh:mm:ss:mss] Found package names: [] +TI:: [hh:mm:ss:mss] Inferred typings from unresolved imports: ["bar"] +TI:: [hh:mm:ss:mss] Finished typings discovery: + { + "cachedTypingPaths": [ + "/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts" + ], + "newTypingNames": [], + "filesToWatch": [ + "/users/user/projects/project1/bower_components", + "/users/user/projects/project1/node_modules" + ] + } +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::watchTypingLocations", + "projectName": "/users/user/projects/project1/jsconfig.json", + "files": [ + "/users/user/projects/project1/bower_components", + "/users/user/projects/project1/node_modules" + ] + } +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /users/user/projects/project1/bower_components 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Directory location for typing installer +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /users/user/projects/project1/bower_components 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Directory location for typing installer +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /users/user/projects/project1/node_modules 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Directory location for typing installer +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /users/user/projects/project1/node_modules 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Directory location for typing installer +TI:: [hh:mm:ss:mss] Sending response: + { + "projectName": "/users/user/projects/project1/jsconfig.json", + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typings": [ + "/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts" + ], + "unresolvedImports": [ + "bar" + ], + "kind": "action::set" + } +Info seq [hh:mm:ss:mss] Scheduled: /users/user/projects/project1/jsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "projectName": "/users/user/projects/project1/jsconfig.json", + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typings": [ + "/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts" + ], + "unresolvedImports": [ + "bar" + ], + "kind": "action::set" + } + } +TI:: [hh:mm:ss:mss] No new typings were requested as a result of typings discovery Info seq [hh:mm:ss:mss] event: { "seq": 0, @@ -784,6 +900,184 @@ Info seq [hh:mm:ss:mss] event: "projectName": "/users/user/projects/project1/jsconfig.json" } } +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /users/user/projects/project1/jsconfig.json +Info seq [hh:mm:ss:mss] ======== Resolving module 'bar' from '/users/user/projects/project1/app.js'. ======== +Info seq [hh:mm:ss:mss] Module resolution kind is not specified, using 'Node10'. +Info seq [hh:mm:ss:mss] Loading module 'bar' from 'node_modules' folder, target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar.tsx' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/index.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/index.tsx' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/index.d.ts' does not exist. +Info seq [hh:mm:ss:mss] Directory '/users/user/projects/project1/node_modules/@types' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/users/user/projects/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/users/user/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/users/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Loading module 'bar' from 'node_modules' folder, target file types: JavaScript. +Info seq [hh:mm:ss:mss] Searching all ancestor node_modules directories for fallback extensions: JavaScript. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar.js' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar.jsx' does not exist. +Info seq [hh:mm:ss:mss] File '/users/user/projects/project1/node_modules/bar/index.js' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/users/user/projects/project1/node_modules/bar/index.js', result '/users/user/projects/project1/node_modules/bar/index.js'. +Info seq [hh:mm:ss:mss] ======== Module name 'bar' was successfully resolved to '/users/user/projects/project1/node_modules/bar/index.js'. ======== +Info seq [hh:mm:ss:mss] Auto discovery for typings is enabled in project '/users/user/projects/project1/jsconfig.json'. Running extra resolution pass for module 'bar' using cache location '/home/src/Library/Caches/typescript'. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/bar.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/bar/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/bar.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/bar/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/package.json' does not exist. +Info seq [hh:mm:ss:mss] Found 'package.json' at '/home/src/Library/Caches/typescript/package.json'. +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/node_modules 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/node_modules 1 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/node_modules/@types/bar/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/node_modules/@types/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/node_modules/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/Library/Caches/typescript/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /users/user/projects/project1/node_modules/bar/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /users/user/projects/project1/node_modules/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /users/user/projects/project1/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /users/user/projects/package.json 2000 undefined Project: /users/user/projects/project1/jsconfig.json WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /users/user/projects/project1/jsconfig.json projectStateVersion: 4 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/users/user/projects/project1/jsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /home/src/tslibs/TS/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; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" + /home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts Text-1 "export const x = 1;" + /users/user/projects/project1/app.js SVC-1-0 "var x = require('bar');" + + + ../../../../home/src/tslibs/TS/Lib/lib.d.ts + Default library for target 'es5' + ../../../../home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts + Imported via 'bar' from file 'app.js' + Matched by default include pattern '**/*' + app.js + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] getUnresolvedImports:: Files:: 3 +Info seq [hh:mm:ss:mss] extractUnresolvedImportsFromSourceFile:: /home/src/library/caches/typescript/node_modules/@types/bar/index.d.ts:: [] +Info seq [hh:mm:ss:mss] extractUnresolvedImportsFromSourceFile:: /users/user/projects/project1/app.js:: [] +Info seq [hh:mm:ss:mss] getUnresolvedImports:: Files:: 3 Done: [] +TI:: [hh:mm:ss:mss] Got install request + { + "projectName": "/users/user/projects/project1/jsconfig.json", + "fileNames": [ + "/home/src/tslibs/TS/Lib/lib.d.ts", + "/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts", + "/users/user/projects/project1/app.js" + ], + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "unresolvedImports": [], + "projectRootPath": "/users/user/projects/project1", + "kind": "discover" + } +TI:: [hh:mm:ss:mss] Explicitly included types: [] +TI:: [hh:mm:ss:mss] Searching for typing names in /users/user/projects/project1/node_modules; all files: [] +TI:: [hh:mm:ss:mss] Found package names: [] +TI:: [hh:mm:ss:mss] Inferred typings from unresolved imports: [] +TI:: [hh:mm:ss:mss] Finished typings discovery: + { + "cachedTypingPaths": [], + "newTypingNames": [], + "filesToWatch": [ + "/users/user/projects/project1/bower_components", + "/users/user/projects/project1/node_modules" + ] + } +TI:: [hh:mm:ss:mss] Sending response: + { + "kind": "action::watchTypingLocations", + "projectName": "/users/user/projects/project1/jsconfig.json" + } +TI:: [hh:mm:ss:mss] Sending response: + { + "projectName": "/users/user/projects/project1/jsconfig.json", + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typings": [], + "unresolvedImports": [], + "kind": "action::set" + } +Info seq [hh:mm:ss:mss] Scheduled: /users/user/projects/project1/jsconfig.json, Cancelled earlier one +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles*, Cancelled earlier one +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "setTypings", + "body": { + "projectName": "/users/user/projects/project1/jsconfig.json", + "typeAcquisition": { + "enable": true, + "include": [], + "exclude": [] + }, + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 2, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noEmit": true, + "traceResolution": true, + "configFilePath": "/users/user/projects/project1/jsconfig.json", + "allowNonTsExtensions": true + }, + "typings": [], + "unresolvedImports": [], + "kind": "action::set" + } + } +TI:: [hh:mm:ss:mss] No new typings were requested as a result of typings discovery +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /users/user/projects/project1/jsconfig.json +Info seq [hh:mm:ss:mss] Reusing resolution of module 'bar' from '/users/user/projects/project1/app.js' of old program, it was successfully resolved to '/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts'. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/bar/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/@types/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/node_modules/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/home/src/Library/Caches/typescript/package.json' exists according to earlier cached lookups. +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /users/user/projects/project1/jsconfig.json projectStateVersion: 5 projectProgramVersion: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/users/user/projects/project1/jsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /home/src/tslibs/TS/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; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" + /home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts Text-1 "export const x = 1;" + /users/user/projects/project1/app.js SVC-1-0 "var x = require('bar');" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] getUnresolvedImports:: Files:: 3 +Info seq [hh:mm:ss:mss] getUnresolvedImports:: Files:: 3 Done: [] Info seq [hh:mm:ss:mss] event: { "seq": 0, @@ -795,6 +1089,84 @@ Info seq [hh:mm:ss:mss] event: "diagnostics": [] } } +After running Timeout callback:: count: 2 + +PolledWatches:: +/home/src/Library/Caches/typescript/node_modules/@types/bar/package.json: *new* + {"pollingInterval":2000} +/home/src/Library/Caches/typescript/node_modules/@types/package.json: *new* + {"pollingInterval":2000} +/home/src/Library/Caches/typescript/node_modules/package.json: *new* + {"pollingInterval":2000} +/users/user/projects/node_modules: + {"pollingInterval":500} +/users/user/projects/node_modules/@types: + {"pollingInterval":500} +/users/user/projects/project1/bower_components: *new* + {"pollingInterval":500} +/users/user/projects/project1/node_modules/@types: + {"pollingInterval":500} + +PolledWatches *deleted*:: +/users/user/projects/package.json: + {"pollingInterval":2000} +/users/user/projects/project1/node_modules/bar/package.json: + {"pollingInterval":2000} +/users/user/projects/project1/node_modules/package.json: + {"pollingInterval":2000} +/users/user/projects/project1/package.json: + {"pollingInterval":2000} + +FsWatches:: +/home/src/Library/Caches/typescript/package.json: *new* + {} +/home/src/tslibs/TS/Lib/lib.d.ts: + {} +/users/user/projects/project1/jsconfig.json: + {} + +FsWatchesRecursive:: +/home/src/Library/Caches/typescript/node_modules: *new* + {} +/users/user/projects/project1: + {} +/users/user/projects/project1/node_modules: + {} + +Timeout callback:: count: 2 +4: *ensureProjectForOpenFiles* *deleted* +7: /users/user/projects/project1/jsconfig.json *new* +8: *ensureProjectForOpenFiles* *new* + +Projects:: +/users/user/projects/project1/jsconfig.json (Configured) *changed* + projectStateVersion: 5 *changed* + projectProgramVersion: 3 *changed* + dirty: false *changed* + +ScriptInfos:: +/home/src/Library/Caches/typescript/node_modules/@types/bar/index.d.ts *new* + version: Text-1 + containingProjects: 1 + /users/user/projects/project1/jsconfig.json +/home/src/tslibs/TS/Lib/lib.d.ts + version: Text-1 + containingProjects: 1 + /users/user/projects/project1/jsconfig.json +/users/user/projects/project1/app.js (Open) + version: SVC-1-0 + containingProjects: 1 + /users/user/projects/project1/jsconfig.json *default* +/users/user/projects/project1/node_modules/bar/index.js *changed* + version: Text-1 + containingProjects: 0 *changed* + /users/user/projects/project1/jsconfig.json *deleted* + +Before running Timeout callback:: count: 2 +7: /users/user/projects/project1/jsconfig.json +8: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /users/user/projects/project1/jsconfig.json Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: Info seq [hh:mm:ss:mss] Project '/users/user/projects/project1/jsconfig.json' (Configured) @@ -826,16 +1198,6 @@ Info seq [hh:mm:ss:mss] event: } After running Timeout callback:: count: 0 -Projects:: -/users/user/projects/project1/jsconfig.json (Configured) *changed* - projectStateVersion: 3 - projectProgramVersion: 1 - dirty: false *changed* - -Before running Timeout callback:: count: 0 - -After running Timeout callback:: count: 0 - Before running Timeout callback:: count: 0 After running Timeout callback:: count: 0