在VS 2012中查看typescript输出js文件

时间:2023-01-17 09:12:48

I've installed TypeScript and Web Essential for Visual Studio 2012.

我为Visual Studio 2012安装了TypeScript和Web Essential。

In a new TypeScript Project were created 3 files:

在一个新的TypeScript项目中创建了3个文件:

  • default.html
  • default.html中
  • app.css
  • app.css
  • app.ts
  • app.ts

In all tutorials, VS 2012 automatically create dropdown for app.ts file in explorer, where is hidden app.js file.

在所有教程中,VS 2012会自动为资源管理器中的app.ts文件创建下拉列表,其中隐藏了app.js文件。

Like on the image below:

如下图所示:

在VS 2012中查看typescript输出js文件

But in my case it doesn't happen for "app.ts", and for new TypeScript file "file1.ts":

但在我的情况下,“app.ts”和新的TypeScript文件“file1.ts”不会发生:

在VS 2012中查看typescript输出js文件

What I need to do in settings for VS 2012, to automatically creating and viewing outputed js files?

我需要在VS 2012的设置中做什么,自动创建和查看输出的js文件?

2 个解决方案

#1


2  

There is a quick fix to show the files inside the solution.

有一个快速解决方案来显示解决方案中的文件。

If you click the "Show Hidden Files" icon in Solution Explorer you'll see the files appear and you can right-click and select "Add file to solution".

如果单击解决方案资源管理器中的“显示隐藏文件”图标,您将看到文件出现,您可以右键单击并选择“将文件添加到解决方案”。

The slight problem here is that they won't be correctly nested against your TypeScript file - they'll appear on their own. You can fix this by editing the project file to show the dependency between the files - I have shown two files that both depend on app.ts as an example, you may only need the JavaScript file to depend on the TypeScript file:

这里的一个小问题是它们不能正确地嵌套在你的TypeScript文件中 - 它们会单独出现。您可以通过编辑项目文件来显示文件之间的依赖关系来解决这个问题 - 我已经展示了两个依赖于app.ts的文件作为示例,您可能只需要JavaScript文件依赖于TypeScript文件:

<Content Include="app.d.ts">
  <DependentUpon>app.ts</DependentUpon>
</Content>
<Content Include="app.js">
  <DependentUpon>app.ts</DependentUpon>
</Content>

#2


2  

There is a Visual Studio extension to do what you need: File Nesting

有一个Visual Studio扩展可以满足您的需求:文件嵌套

This extension allows you to specify which files are nested under which other files in the Solution Explorer. You can have files nested manually or by defining file name-based nesting rules.

此扩展允许您指定哪些文件嵌套在解决方案资源管理器中的哪些其他文件下。您可以手动嵌套文件,也可以通过定义基于文件名的嵌套规则。

Here is an example screenshot of what you can do with the plugin:

以下是使用该插件可以执行的操作的示例屏幕截图:

在VS 2012中查看typescript输出js文件

#1


2  

There is a quick fix to show the files inside the solution.

有一个快速解决方案来显示解决方案中的文件。

If you click the "Show Hidden Files" icon in Solution Explorer you'll see the files appear and you can right-click and select "Add file to solution".

如果单击解决方案资源管理器中的“显示隐藏文件”图标,您将看到文件出现,您可以右键单击并选择“将文件添加到解决方案”。

The slight problem here is that they won't be correctly nested against your TypeScript file - they'll appear on their own. You can fix this by editing the project file to show the dependency between the files - I have shown two files that both depend on app.ts as an example, you may only need the JavaScript file to depend on the TypeScript file:

这里的一个小问题是它们不能正确地嵌套在你的TypeScript文件中 - 它们会单独出现。您可以通过编辑项目文件来显示文件之间的依赖关系来解决这个问题 - 我已经展示了两个依赖于app.ts的文件作为示例,您可能只需要JavaScript文件依赖于TypeScript文件:

<Content Include="app.d.ts">
  <DependentUpon>app.ts</DependentUpon>
</Content>
<Content Include="app.js">
  <DependentUpon>app.ts</DependentUpon>
</Content>

#2


2  

There is a Visual Studio extension to do what you need: File Nesting

有一个Visual Studio扩展可以满足您的需求:文件嵌套

This extension allows you to specify which files are nested under which other files in the Solution Explorer. You can have files nested manually or by defining file name-based nesting rules.

此扩展允许您指定哪些文件嵌套在解决方案资源管理器中的哪些其他文件下。您可以手动嵌套文件,也可以通过定义基于文件名的嵌套规则。

Here is an example screenshot of what you can do with the plugin:

以下是使用该插件可以执行的操作的示例屏幕截图:

在VS 2012中查看typescript输出js文件

相关文章