From other languages I know __FILE__
or similar expressions (for instance: in PHP a constant, in C a preprocessor macro) that are replaced with the current source file path. Is there anything like this in TypeScript?
If you are creating a node application
__dirname
Will give you the current module directory path
https://nodejs.org/docs/latest/api/globals.html#globals_dirname
There is currently feature request for that, see https://github.com/Microsoft/TypeScript/issues/4892
From what I am seeing it is not implemented yet.
One work-around can be, adding your custom comments( for example /** @compile-if */) and then using Gulp/Grunt task to transform code after actual Typescript compilation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With