【发布时间】:2014-05-27 05:10:54
【问题描述】:
我正在尝试使用 requireJS 将外部类(用 Typescript 编写)导入另一个 Typescript 类。我使用了这个语法,但我不明白为什么我在这个 import 语句中遇到语法错误:
我也尝试过使用它:
import t = module("Controller/TestController");
我也遇到了同样的错误。
上面的 import/require 语句位于appmod.ts。这是我的文件结构:
+Root
+Scripts
+app
-main.ts
-appmod.ts
+Controller
-TestController.ts
我查看了文档,这条线对我来说看起来非常好。路径中确实存在 TestController.ts 文件,并且类前面带有 export 关键字。
这条线有什么问题?
这就是我的 TestController.ts 的样子:
/// <reference path="../typings/angularjs/angular.d.ts" />
module testApp.Controller {
export interface ITestScope extends ng.IScope {
helloString:string;
}
export class TestController {
public static $inject = [
"$scope"
];
constructor(private $scope: ITestScope) {
this.$scope.helloString = "Hello!";
}
}
}
我在我的TestController.js 中使用了DefinitelyTyped 的AngularJS 定义。
【问题讨论】:
标签: javascript visual-studio angularjs requirejs typescript