-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
I've run into this a bundle of times now and usually just force myself back to using classic module resolution, and looking into the code briefly yields no reason this should be happening.
Basically, I have a lot of modules like popsicle which does not specify a typings field in package.json. However, once I install it using typings (which is just wrapping everything up into ambient module declarations) and use it, it starts to resolve the actual files even though the ambient definitions are already provided. I can only assume that there's some sort of declaration file merging doing on when using node module resolution, but some clarification would be good.
Here's a snippet of the generated definition:
// Compiled using typings@0.5.2
// Source: node_modules/popsicle/dist/form.d.ts
declare module 'popsicle/dist/form' {
import FormData = require('popsicle~form-data');
export default function form(obj: any): FormData;
}Notice that the file is being correctly rewritten. However, with node resolution enabled, it'll also load the original file too - even though nothing at all references it. This results in the original code generating compiler errors and having to switch back to classic.
node_modules/popsicle/dist/form.d.ts(1,27): error TS2307: Cannot find module 'form-data'.
node_modules/popsicle/dist/jar.d.ts(1,27): error TS2307: Cannot find module 'tough-cookie'.
I can create a replicated repo, if needed, but I hope the issue sheds enough light on the problem.