I have a I am trying to create a typing for a node module. I found that when I am using decomposed class, the code is not compiling.
This is my declaration file
declare namespace DemoNs {
interface Foo_static {
new(): Foo_instance;
}
interface Foo_instance {}
export var Foo: Foo_static;
}
declare module 'demo-ns' {
export = DemoNs
}
and this is my test file
/// <reference path="demo.d.ts" />
import { Foo } from 'demo-ns';
var a: Foo;
When trying to compile last line of the test file says:
error TS2304: Cannot find name 'Foo'.
Found the problem.
The compiler throw the error because even tough I exported Foo, there is no place saying it's a type. And therefore he isn't finding Foo.
I fixed by adding to my namespace Foo in my declaration file, the line:
export type Foo = Foo_instance;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.