TypeScript Version: 2.4.1
Code
import { EventEmitter } from 'events';
import { ComponentClass, Props, ReactElement } from 'react';
declare module "react-bootstrap-table" {
}
Where we do not install 'the types package for 'react-bootstrap-table' but try to create our own definitions file.
Expected behavior:
I would expect to be able to "augment" the module even if the d.ts file contains other things besides the code above. or at the very least to have the error message be less cryptic.
Actual behavior:
I get the compile error:
Invalid module name in augmentation. Module 'name-of-module-i-am-trying-to-augment' resolves to an untyped module at 'absolute-path/name-of-module-i-am-trying-to-augment', which cannot be augmented.
This is does not help at all to understand what is the error. Augment suggests that I am trying to change the module when in fact i'm just describing it. No steps to fix the problem are suggested.
@ofirgeller what did you do to solve this one? I'm also trying to write type definition for a package, and I get the same error message. Tried bunch of different packages, just didn't work.
@cyberhck You must have nothing else in the file outside of the module deceleration, even your imports must be inside of the body of the deceleration. You might also have a different root problem then this one. that still gives the same error message, hope not.
Thanks, I just solved it around 5 mins ago :smile: thanks for your reply.
Yes, I had imports at the top :slightly_smiling_face:
See also this StackOverflow question.
@DanielRosenwasser Thanks, we write our libraries in TypeScript itself, and we don't have to bother writing d.ts files manually, for other library we hardly write any, only now I wanted something not in this repository, I found at https://github.com/flaub/typescript-definitions, even thought that's MIT license I don't want to plagiarize someone else's work to send a PR. Maybe @flaub is willing to make a pr?
an augmentation is considered subservient to a declaration. if you want to declare a module, create a new .d.ts file, or in one that is not a module already declare it. Modules have their own scope.
Most helpful comment
@cyberhck You must have nothing else in the file outside of the module deceleration, even your imports must be inside of the body of the deceleration. You might also have a different root problem then this one. that still gives the same error message, hope not.