38得票5回答
在TypeScript中从根路径导入模块

假设我有一个项目,它的主要源代码目录是:C:\product\src 根据该目录,每个导入路径都将相对于它。例如,假设:// Current script: C:\product\src\com\name\product\blah.ts import { thing } from '/com...

32得票2回答
错误 TS2345:类型为“T”的参数无法分配给类型为“object”的参数

以下代码在TypeScript 2.1.6版本中可以正常工作: function create<T>(prototype: T, pojo: Object): T { // ... return Object.create(prototype, descripto...

31得票1回答
使用ts-node执行时导入NodeJS的`fs`模块需要怎样做?

我正在尝试使用 ts-node 运行以下代码。import { writeFileSync, readFileSync } from 'fs'; 但是我得到:src/main/ts/create.ts (1,45): Cannot find module 'fs'. (2307) 我需要在哪里...

15得票1回答
Typescript返回值用花括号包裹?

在下面的代码块中,heros被大括号括起来: export class InMemoryDataService implements InMemoryDbService { createDb() { let heroes = [ {id: 11...

12得票1回答
如何在Visual Studio 2017上安装TypeScript 2.2

我们团队中有一些人同时安装了Visual Studio 2015和Visual Studio 2017,而其他人只安装了最新的Visual Studio 2017(15.5)。对于后者,我们注意到IDE中的TypeScript项目由于各种lib.es2015.d.ts问题生成了各种意外错误。 ...

11得票1回答
TypeScript 2.2 接口扩展对象类型

我有一个使用对象作为参数的函数,像这样: interface Options { foo?: string; bar?: number; }; function fooNction(opts: Options): void { } 这在某些情况下可以正常工作,但不是所有...

8得票3回答
TypeScript错误:类型“HTMLElement”上不存在属性“append”。

问题: 当尝试将编译后的Angular 1.5模板附加到现有的HTMLElement时,我收到了Typescript 2.2.1编译错误。 代码: $document.find(scope.target)[0].append($compile(menu)(scope)[0]); 编译...