Repository navigation
error TS2664: Invalid module name in augmentation #9748
Description
Activity
the declaration
declare module 'jsonschema';should be in a global scope. i.e. a top level declaration in a non module (where a module is a file with at least one top levelimportorexport).A declaration of the form
declare module '...' { }in a module is an augmentation, see https://github.com/Microsoft/TypeScript-Handbook/blob/fa9e2be1024014fe923d44b1b69d315e8347e444/pages/Declaration%20Merging.md#module-augmentation for more details.Reacted by Lucas Theisen, Boris Cherny, Pavel Ivanov, Kristian Hanekamp, Kirk Bulis, Yoyo Zhou and Thomas Anciaux- addedQuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
on Jul 14, 2016 Thanks for the quick answer. Seems obvious in retrospect. Perhaps you could update the What's New documents or make sure it's included in the final documentation? It would also be nice if the error message were more helpful...
The answer was alluded to by the use of declarations.d.ts. Is that the recommended name? Where's the best place to put this file in 2.0? Are you still recommending the "typings" folder?
Reacted by Jacob Peddicord, Daniel Opden Dries, hinell, Kirk Bulis, Ky Bishop and Ryan QuinnAh, waste some much time to find out this issue. +1 for update What's New documents.
Reacted by costa974, Liren Sun and Dathanmuzuiget (@muzuiget), Yeah, humdinger. To +1 use the new "add your reaction" feature in GitHub.
I am getting a similar error:
[ts] Invalid module name in augmentation. Module 'shiitake' resolves to an untyped module at 'd:/dev/foo/foobar.foo.Client.Web/node_modules/shiitake/dist/index.js', which cannot be augmented.
I have asked this on StackoverFlow, too: TypeScript custom declaration files for untyped npm modules
It would be nice if someone can shed some light on that.
Reacted by Brian Schlenker and Daniel WolfMohamed Hegazy (@mhegazy) Thanks for that link on augmentation, the errors really don't help much, until Googling landed me here. I
amwas having this problem: #4166 (comment) (solved).- locked and limited conversation to collaborators
on Jun 19, 2018
Description
The What's new in TypeScript wiki page and the Announcing TypeScript 2.0 Beta blog posting
both indicate that TypeScript 2.x supports Shorthand ambient module declarations, yet when I
attempt to use
declare module 'jsonschema';for thejsonschemanpm package I getThere is a GitHub issue (#8518) that recommends getting the latest nightly build, but I
have the latest and still get the problem. How can this be resolved?
Steps to reproduce
Navigate to a parent folder
Clone repo
cdto repoInstall packages
Build project
Result
Output