This code does not compile if I save it as . 。 This is expected because cantSeeMe
is hidden (I would need to export
it if I want it to be seen outside the module.
However, if I save the file as it compiles fine. 则可以正常编译。 I would also expect it to not compile.
Why does Typescript not follow the same encapsulation rules when it's compiled as a definition file?
module blah {
interface cantSeeMe { a: any; }
}
var variable: blah.cantSeeMe;
定义文件中的export
关键字是可选的,因为.d.ts文件的整个要点是描述您的公共表面区域。
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.