You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// RxPlus.ts # npm package containing this augmentation (of rxjs), and symlinked (under "shared" name)import{Observable}from'rxjs';declare module 'rxjs/Observable'{interfaceObservable<T>{parseInt(): Observable<number>;}}Observable.prototype.parseInt=function(this: Observable<any>){returnthis.map(res=>parseInt(res,10));};
// main.ts # usage of the augmentation in another packageimport'shared/RxPlus';import{Observable}from'rxjs';Observable.from([1,2]).parseInt();// error TS2339: Property 'parseInt' does not exist on type 'Observable<number>'.
However, the above works if the augmentation is defined in the same package than main.ts
I tried to investigate a bit more: it really seems to be caused by symlinking (npm link)
On the repro project I linked above, if I copy the shared module into project/node_modules (to simulate a "true" external package, not symlinked) it works...
I added instructions on my repository. I'm sorry to insist, but can anyone just take a look at the reproduction repo and confirm or not the issue? I tried to make it small and easy to setup. 😇
Edit: Also the reason I need symlinks is because I'm using lerna
Edit2: Or is it an issue with npm link/install not flattening the dependencies tree? Leading to having rxjs (in my case) "installed" twice? Thus confusing typescript?
TypeScript Version: 2.4.2
Code
However, the above works if the augmentation is defined in the same package than
main.ts
I also did a small repro project highlighting the error.
I tried adding a declaration file to the external package, without success (I might have declared it poorly though)
It might relate to/duplicate #11406 and #12607. Also I think this stackoverflow question describes the same case (but unfortunately no answers)
Expected behavior:
A module augmentation defined in an external (symlinked) package should be working when imported into another package
Actual behavior:
The compiler is unaware of an augmentation defined in an external (symlinked) package
The text was updated successfully, but these errors were encountered: