我突然有一个非常奇怪的编译我的一个文件。typescript编译器忽略定义/导入1个文件
comm.ts:
import document = require('./document/document');
import element = require('./document/elements/element');
import paragraph = require('./document/elements/paragraph');
import listBody = require('./document/list-body');
// ...
comm.js:
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
define(["require", "exports"], function(require, exports) {
// ...
什么是与延伸,更重要的是,为什么定义不能在4个进口拉?它们用于代码中。
而最大的问题是,现在当我跑我的错误:
SCRIPT5007:无法获取属性“原型”的未定义或空引用 comm.js,行18个字符5
在上面列出的代码中。
导入是必需的,但仅用于定义类型。所以我猜测对于类型定义来说,这是编译时需要的,但不是运行时。但是,__extends函数仍然会引发异常。在入口b上是未定义的,而d是“函数RunProperties”,这是我拥有的一个类,但它不在任何地方引用此文件。 –
如何找出延伸问题是什么?我仔细查看了代码,并且此文件中的所有扩展都是在同一个文件中的类和接口。 –
是否允许循环导入?我有一个案例,file1导入file2和file2导入file1。 –