相关疑难解决方法(0)

如何在TypeScript外部模块中使用名称空间?

我有一些代码:

baseTypes.ts

export namespace Living.Things {
  export class Animal {
    move() { /* ... */ }
  }
  export class Plant {
    photosynthesize() { /* ... */ }
  }
}
Run Code Online (Sandbox Code Playgroud)

dog.ts

import b = require('./baseTypes');

export namespace Living.Things {
  // Error, can't find name 'Animal', ??
  export class Dog extends Animal {
    woof() { }
  }
}
Run Code Online (Sandbox Code Playgroud)

tree.ts

// Error, can't use the same name twice, ??
import b = require('./baseTypes');
import b = require('./dogs');

namespace Living.Things {
  // Why do …
Run Code Online (Sandbox Code Playgroud)

javascript module typescript

215
推荐指数
4
解决办法
12万
查看次数

命名空间vs模块与打字稿中的打字?

有人可以用一个例子来解释这些概念之间的区别,我真的很困惑,当它们都服务于同一目的时,有三个这样的用途是什么?

typescript

7
推荐指数
1
解决办法
1722
查看次数

标签 统计

typescript ×2

javascript ×1

module ×1