-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore Regions of code in compiler #829
Comments
The C# conditional compilation flags does not make the compiler copy the code, it ignores it totally if "Debug" is not defined. Why not just include these in a js file, that you do not pass to the compiler, and include in with you output, either through concatenation or through including it in the html file of your application? |
This is essentially a use case for #449 is it not? |
I ran into the same issue with App Insights. My thought was instead of having conditional compilation flags, why not specify a region that TypeScript should ignore? Supposedly valid javascript is valid TypeScript but if you try using the App Insights code in an Angular service that is not the case. What I would like is a #region directive or something that tells the TypeScript compiler to completely ignore the code. |
Can u share a sample of the issues u are running into? |
Sure, take for example the application insights code...
If you take that code and put it in a
|
looks like you need to define interface Window {
appInsights: any;
}
declare var appInsights: typeof window.appInsights; |
The other option is to leave your non-ts code in a .js file, and include that in your code using |
I want to include this logic in an Angular service. The window line isn't the problem. The issue is with one of the array indexers. Having a way to exclude a part of a TS file because I don't want the TS compiler to check it would be a nice to have. |
My recommendation here is either 1. use I do not think we have plans to support exclude regions or preprocesor directives. |
Sometimes i use minified script snippets like AppInsights (code snippet is generated by the azure portal), that creates a class in windows.whatever.
Typescript compiler then complains about unknown things on window.
Code would work great if the compiler did not complain.
It costs lots of time finding a workarround. So creating something simple like regions of code that the compiler should ignore and just copy would be cool. Could be some easy syntax like he IF DEBUG flags in C#.
The text was updated successfully, but these errors were encountered: