You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have the option to emit certain code as is, without the tsc touching it or analyzing it.
I'd imagine it could be achieved with a simple, special comment that the TypeScript transpiler would understand, e.g.:
// normal TypeScript code.../// <no-compile>'whatever is here will just get copied to the output .js file, without being touched';/// </no-compile>// more proper TypeScript code...
My use case and reasoning is the following:
I'm currently using a dual transpiling stack:
TS -> ES6 (via TS) -> ES6 (via Babel).
This works great, but Babel has some nice new ES2016 features that TypeScript probably won't have for a year or more. It would be great if we could write using those features, surround them with such no-compile comments so that only those would not get transpiled or analyzed by TS. Babel could take care of them in the next stage of transpilation pipeline.
There might be other reasonable use-cases for the ability to turn off TypeScript for a part of code.
Partially related to these, but I'd imagine this would be much simpler to implement:
Here is a different use-case: if the you have an extremely large and complex .d.ts file, such as one for Angular, and the file is mostly fine but has occasional small errors in them which block you from writing perfectly legitimate code. Let's assume this file is so large and so complex that finding the method that's troubling you, figuring out the syntax/structure, and properly fixing the error would be a sizeable waste of time.
You could still write declare let angular: any at the head of the file, but then that will disable type checking for all the times you reference Angular within that file, not just the few lines or particular method you care about.
Declaration correctness is an issue that should be solved on the producer side, in your example angular team for angular2 or definitely typed for angular1.
If the file has errors, you copy them locally, change the declarations to either stub out parts you do not care about or fixing the declarations. from the compiler perspective all errors are equal, regardless if they come from a file you wrote, or a file you acquired form definitely typed.
It would be great to have the option to emit certain code as is, without the
tsc
touching it or analyzing it.I'd imagine it could be achieved with a simple, special comment that the TypeScript transpiler would understand, e.g.:
My use case and reasoning is the following:
I'm currently using a dual transpiling stack:
TS -> ES6 (via TS) -> ES6 (via Babel).
This works great, but Babel has some nice new ES2016 features that TypeScript probably won't have for a year or more. It would be great if we could write using those features, surround them with such
no-compile
comments so that only those would not get transpiled or analyzed by TS. Babel could take care of them in the next stage of transpilation pipeline.There might be other reasonable use-cases for the ability to turn off TypeScript for a part of code.
Partially related to these, but I'd imagine this would be much simpler to implement:
The text was updated successfully, but these errors were encountered: