【发布时间】:2017-07-15 15:17:43
【问题描述】:
我在 Visual Studio 2015 中使用 TypeScript 2.1.5。该项目配置为使用“ES 2015”模块系统和 ECMAScript 6。
我正在尝试使用由 DefinitelyTyped as 定义的 Angular 本地存储模块:
declare module 'angular' {
export namespace local.storage {
interface ILocalStorageService {
}
}
}
在我的一项服务中,我想导入该接口以便我可以使用它,如下所示:
module Foooooo.Services {
export class FooService {
constructor(private localStorageService: local.storage.ILocalStorageService) {
}
}
}
在翻阅文档后,我已经尝试了所有我能想到的:
import local from "angular"; // bzzzzzt
import * as ang from "angular"; // causes all of my other interfaces to no longer resolve
import { local } from "angular"; // doesn't compile
import { ILocalStorageService } from "angular"; // other interfaces don't resolve anymore
import { local.ILocalStorageService } from "angular"; // nopenope
import ILocalStorageService = require("angular"); // error: not compatible with ECMAScript 6 or higher
如何正确导入?
【问题讨论】:
标签: typescript typescript2.0 definitelytyped