简体   繁体   English

使用ES6模块语法在Webstorm中浏览Typescript引用

[英]Navigating through Typescript references in Webstorm using ES6 module syntax

We are using Typescript with Intellij Webstorm IDE. 我们在Intellij Webstorm IDE中使用Typescript。

The situation is we use ES6 import syntax and tsc compiler 1.5.3 (set as custom compiler in Webstorm also with flag --module commonjs ) 情况是我们使用ES6导入语法和tsc编译器1.5.3(在Webstorm中也设置为自定义编译器,同时带有--module commonjs标志)

The problem is it is imposible to click through (navigate to) method from module (file) 问题是无法从模块(文件)中单击(导航至)方法

// app.ts

import * as myModule from 'myModule';

myModule.myFunction();



// myModule.ts

export function myFunction() {
    // implementation
}

When I click on .myFunction() in app.ts I expect to navigate to myModule.ts file but this doesn't happen? 当我点击.myFunction()app.ts我期望导航到myModule.ts文件,但这种情况不会发生?

EDIT: 编辑:

The way we exported functionality was bit different as in first example: 我们导出功能的方式与第一个示例有些不同:

export: {
    myFunction1,
    myFunction2,
    // ...
};

When I click on .myFunction() in app.ts I expect to navigate to myModule.ts file but this doesn't happen 当我在app.ts中单击.myFunction()时,我希望导航到myModule.ts文件,但这不会发生

This is working fine in the current WebStorm release. 在当前的WebStorm版本中,此方法运行良好。

I found out the problem, my example in question was simplified too much. 我发现了问题,所讨论的示例简化得太多了。 In real code we are using: 在实际代码中,我们使用:

export: {
    myFunction1,
    myFunction2
    // ...
};

and this really doesn't work. 这真的行不通。

I have to change it to: 我必须将其更改为:

export function myFunction1() { /* impl */ }
export function myFunction2() { /* impl */ }

then it works. 然后就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS 2.0 TypeScript Intellij想法(或webstorm) - ES6导入语法 - AngularJS 2.0 TypeScript Intellij idea (or webstorm) - ES6 import syntax 在 Webstorm 中为我的自定义 npm 模块(ES6/Babel)自动完成 - Auto-completion in Webstorm for my custom npm module (ES6/Babel) 项目中损坏的WebStorm中的ES6检测 - ES6 Detection in WebStorm Broken in Project IntelliJ/WebStorm 中的自动格式化 ES6 解构赋值 - Auto formatting ES6 destructuring assignment in IntelliJ/WebStorm WebStorm:标记方法在 ES6 基类中被覆盖 - WebStorm: Mark method to be overridden in ES6 base class Intellij IDEA和WebStorm中的无类型属性的内联ES6脚本 - Inline ES6 Scripts in Intellij IDEA and WebStorm without type attribute 配置 IntelliJ Ultimate 以了解 ES6 语法 - Configure IntelliJ Ultimate to understand ES6 Syntax 尝试 ES6 样式导入会给出“无法在模块外使用导入语句” - Trying ES6 style import gives 'Cannot use import statement outside a module' WebStorm / PhpStorm:按文件导航停止工作 - WebStorm/PhpStorm: navigating by file stopped working 在WebStorm / IntelliJ中使用lodash定义存根时,TypeScript导入会阻止智能感知/自动完成 - TypeScript importing prevents intellisense/autocomplete when using lodash definition stubs in WebStorm/IntelliJ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM