javascript - Visual Studio ReSharper - 在外部模块中声明的 Typescript 自动导入类 - 使用 from 而不是 require

标签 javascript visual-studio typescript visual-studio-2017 resharper

当使用 JetBrains ReSharper Ultimate 2018.3.4 并使用命令 Import 'class '' declared in external module ''' and all other types 它使用 require 进行导入.这可行,但我希望它像 Visual Studio 通常那样使用 from 。如何启用它?

从 ReSharper 生成的代码:

import Requests = require("../../../requests");
import ApiPaths = Requests.ApiPaths;

enter image description here

从标准 Visual Studio 2017 Professional 生成的代码:

import { ApiPaths } from '../../../requests';

enter image description here

最佳答案

在 ReSharper 选项中,导航至代码编辑 -> TypeScript -> 代码样式 -> 别名

对于“首选导入语句类型(如果可能)”,选择“ES6 样式导入”。

关于javascript - Visual Studio ReSharper - 在外部模块中声明的 Typescript 自动导入类 - 使用 from 而不是 require,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55060629/

相关文章:

javascript - Angular js错误: Argument 'questionsCtrl' is not a function

javascript - 使用 Joi 验证请求时如何避免 Hapi.js 发送 400 错误

visual-studio - 如何在 VSIX 扩展中集成 Microsoft.CodeAnalysis

javascript - 如何在 TypeScript 中将一种泛型类型(嵌套对象)的结构复制到另一种泛型?

node.js - Typescript 忽略 MakeDirectoryOptions 的 fs.d.ts 定义

javascript - 参数不会提升,会打临时死区?

javascript - 为使用 insertAdjacentHTML 创建的 HTML 元素分配唯一 ID

visual-studio - Visual Studio : How do I show all classes inherited from a base class?

visual-studio - VS2017 nuget 不断在错误的位置搜索包

angular - 错误 TS2769 : No overload matches this call