typescript-book
typescript-book copied to clipboard
Confusion on modules section
The section where the global module declaration explained there is an example like that:
// global.d.ts
declare module 'foo' {
// Some variable declarations
export var bar: number; /*sample*/
}
and
// anyOtherTsFileInYourProject.ts
import * as foo from 'foo';
// TypeScript assumes (without doing any lookup) that
// foo is {bar:number}
I can't achieve to make this work. I'm not quite sure this is a typo or something else or I don't understand the concept very well as a learner. But if I define the module like that, I can make it work:
declare module "foo" {
// Some variable declarations
export type bar = number; /*sample*/
}