Type acquisition support for bower_components directory#14100
Conversation
| */ | ||
| function getTypingNamesFromNodeModuleFolder(nodeModulesPath: string) { | ||
| function getTypingNamesFromPackagesFolder(packagesFolderPath: string) { | ||
| filesToWatch.push(packagesFolderPath); |
There was a problem hiding this comment.
should we watch the path after confirming it exists?
There was a problem hiding this comment.
I kept this before the path existence check as we want to watch these paths even if they haven't been created yet. (ex: User creates an empty ASP.NET project, adds a js file then uses Manage Bower Packages to install jQuery.)
| installer.installAll(/*expectedCount*/ 1); | ||
|
|
||
| checkNumberOfProjects(projectService, { configuredProjects: 1 }); | ||
| checkProjectActualFiles(p, [app.path, jqueryDTS.path]); |
There was a problem hiding this comment.
Can you also check what paths are being watched?
There was a problem hiding this comment.
Good idea - will add this to the test
| const fileNames = host.readDirectory(packagesFolderPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); | ||
| for (const fileName of fileNames) { | ||
| const normalizedFileName = normalizePath(fileName); | ||
| if (getBaseFileName(normalizedFileName) !== "package.json") { |
There was a problem hiding this comment.
For bower, should be checking bower.json instead
There was a problem hiding this comment.
Also, line 228 and below have some logics specifically targetting npm 3, now we should check if the json file name is package.json before applying these logics.
There was a problem hiding this comment.
We already retrieve the bower.json typings using getTypingsFromJson(bowerJsonPath, filesToWatch). This addresses the case when there is no bower.json present and just a bower_components folder that contains the packages. From my tests the bower_components folder is similar to the node_modules folder. It contains a directory for each package with a package.json (bower_components/jQuery/package.json). I've been testing using the ASP.NET UI. Let me try bower cmd line and see if this is consistent...
You're correct - from the cmd line install there isn't always a package.json generated. I'll have to check bower.json as well. thanks!
|
👍 |
Fixes #13917 [Type Acquisition] auto d.ts acquisition no longer works for bower_components
Issue: retrieving typing names from the bower_components directory is not currently supported. We only retrieve typings for bower components when a bower.json is present. By default in VS, ASP.NET projects do not create a bower.json when using the Manage Bower Packages option. No typings are currently being acquired for these components.
Fix: