IDEA 14 - debugging typescript - debugging

We've a project in Idea with some typescript files and use an ant file to transpile it generating the matching js and map files.
When debugging through IDEA (html file) breakpoints in the typescript files do not work and we don't see the map files in chrome even though existing.
What is the expected structure of the js, ts and map files for debugging typescript with IDEA ?
Debugging with chrome/firefox is fine.

You have to install Jetbrains IDE Support extension for Chrome (I also allowed this extension on incognito - chrome://extensions) and a plugin named Javascript Debugger for Intellij Idea or Webstorm (it needs Spy-js and NodeJs plugins to be enabled also).
After that you just have to do a right click on your project's .html file and click on 'Debug your-html.html'
Update: Sourcemap files are needed to debug, while compiling typescript --sourcemap option must be set.

I just ran into this. However I am not working on a frontend project.. but it might help just as well.
To debug in intellij, I first compile my typescript files.
I defined tsconfig.json
I used tsc -p tsconfig.json to compile.
To make debugging work I did the following
Added "sourceMap": true to tsconfig.json
I ran the compiled js file
==> debug just works when I put a breakpoint in the ts file.
Let me know if this does not resolve your scenario, I will investigate an modify the answer.
This is the project I am working on for reference: https://github.com/coder-on-deck/easy-typescript-setup

Related

outFiles in launch.json seems useless

Location string of sourcemap file is in generated javascript file,
VSCode can find sourcemap file from javascript file.
So why we need "outFiles" setting? The official doc says "VS Code will search your entire workspace, excluding node_modules, for sourcemaps". why should VS Code do that?

How do I link OpenSceneGraph libraries and includes to Visual Studio properly?

I am trying to compile and build the first basic example from the OSG 3.0 Beginner's Guide (Rui Wang, Xuelei Qian) run on Windows 10 (Build 18363) with Visual Studio Community 19 (16.7.3).
The code looks like this:
#include <osgDBd/ReadFile>
#include <osgViewerd/Viewer> //the "d" is supposed to be there when in Debug solution configuration
int main(int argc, char** argv)
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
return viewer.run();
}
But the error messages are:
Error (active) E1696 cannot open source file "osgDBd/ReadFile"
Error (active) E1696 cannot open source file "osgViewerd/Viewer"
Error C1083 Cannot open include file: 'osgDBd/ReadFile': No such file or directory
So I rechecked my solution properties, which I had set up following OSG's online documentation "compiling with visual studio" (Linker, C++ properties, ...), as well as my environment variables in Windows OS.
The recommended cmd commands, should something be out of order, didn't help either.
(I deemed it less cluttered leaving out all those screenshots, but I can of course upload them if wished)
I also compared my settings to this answer: How to add additional libraries to Visual Studio project? , which I thought same.
I should add, that I built OSG on a separate drive than Visual Studio or Windows, but I believed setting the environment variables properly should be ok.
Help would be greatly appreciated.
Thank you.
Have you set %OSG_ROOT% ?
I'm not sure what is in the guide, but my typical installation is to set Windows environment variable OSG_ROOT to the main OpenSceneGraph folder in my Program Files (x86), then to add $(OSG_ROOT)\include to my additional include folders and $(OSG_ROOT)\lib to my additional library folders.
Also, it looks like the example you are using has a "d" added to the folder names - should just be osgDB/ReadFile and osgViewer/Viewer for the Release versions - maybe they wanted you to build the debug libraries and add such folders for your includes? I get having a separate lib and bin but I don't know why they would want a separate include folder for Debug vs. Release, so my suggestion would be to remove the d from the include statements, e.g. osgDBd --> osgDB, osgViewerd --> osgViewer, etc.
Unfortunately, the Example applications in the OSG Solution reference the local build folders, not the installed folders, so will not serve as an example of how to reference OSG from its installed location. However, if you are ok building from the local build folder, you could just use the project settings from one of the Examples.

Suppress warnings/errors in Visual Studio 2017 for certain file

I have a project which is using TypeScript and some external libraries.
I'm searching a way to block all errors and warnings for all .js, .ts, .d.ts etc. files in node_modules folder and the folder with other libraries which relative path to the project root is assets/plugins . I've tried creating a .eslintignore file with the following content:
./node_modules/*
./assets/plugins/*
and also
./node_modules/**/*.js
./node_modules/**/*.ts
./node_modules/**/*.d.ts
./assets/plugins/**/*.js
./assets/plugins/**/*.ts
./assets/plugins/**/*.d.ts
but this didn't work.
Just to recap, I want to block errors and warnings for those files only and remain visible for all other files in the project.
P.S.: All those errors and warnings in .ts and .js files are visible only in Visual Studio 2017 when the project is opened in Visual Studio 2015 there are no errors and warnings.
Adding an .eslintignore to the root of the project, containing the following, and then restarting VS did the trick for me (for now at least)
**/*.d.ts
**/node_modules/*
In order to suppress all warnings for node_modules (both ECMAScript and TypeScript) you should create an .eslintignore file with the following content:
**/*.d.ts
**/node_modules/*
**/assets/plugins/*
and also create configuration for the typescript compiler (tsconfig.json file) in the project root containing the following:
{
"exclude": [
"node_modules/*",
"assets/plugins/*"
]
}

The TypeScript Compiler was given no files for compilation, so it will skip compiling

When i am trying to Build my default JavaScript project(BlankApp Apache Cordova) in Visual Studio 2015 preview am getting following error.
The TypeScript Compiler was given no files for compilation, so it will skip compiling.
Steps Taken in visual studio 2015 preview:
File -> New -> Project -> Apache Cordova apps(under Javascript templates).
Run the default project with Android Emulator.
Getting the following error.
Warning 2 The TypeScript Compiler was given no files for compilation, so it will skip compiling. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets 97 5 BlankCordovaApp4
This is a known issue in the CTP3 release. It sounds like you've created a JS-based project, and have not added any TypeScript files, and so of course there are no .ts (aka TypeScript) files passed to the compiler. Ideally the compiler wouldn't be run at all, but the warning is harmless, and everything else should otherwise be working.
You need to make sure that at least one of your TypeScript files is marked with the TypeScriptCompile build action.
If you click on the file and check the properties window in Visual Studio you will see the build action - it may be that they are all set to some other action.
Option 1:
Take Project offline, edit project, remove the following lines:
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')"/>
and
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')"
/>
Option 2:
Change "AddTypeScriptReferencePath": true to false in Webessentials-Settings.json
It seems that there is no type script file available to compile. add a blank type script file under script folder and then compile, it should work.
This warning was driving me nuts with ASP.NET 5 (asp.net core 1). If you double click the warning you open the Microsoft.TypeScript.targets file. Delete the line with CompileTypeScript and the warning goes away. I'm assuming this prevents TypeScript from compiling normally, which is fine by me as I don't want it anyway.
<PropertyGroup>
<CompileDependsOn>
CompileTypeScript; <--- delete this line
$(CompileDependsOn);
</CompileDependsOn>
I had the same issue.
Mine was due to missing system variable to nodejs. Check your visual studio output. If it is not recognizing “node” command, add system variable.
Computer->right click-> properties -> advanced system settings -> Environment Variable
Check “path” under user variables and system variables
Add the nodejs path to it. Ie: C:\Program Files (x86)\nodejs

How can I enable typescript compilation

I would like to add typescript files compilation in a VSIX project. I tried to add a typescript file inside the project, add code and save, but ths js file is not created.
thanks,
luca
download and install the typescript plugin
if you modify / rename an existing javascript file you have to set the build action property for that file in the Solution Explorer to TypeScriptCompile.

Resources