These are referred to as “Triple Slash Directives” (Typescript docs)
As stated on the first line of that link:
Triple-slash directives are single-line comments containing a single XML tag. The contents of the comment are used as compiler directives.
So yes, the typescript compiler is picking this up during compilation and taking the appropriate action.
In this case, since you are using a types
directive, you are telling the compiler that this file has a dependency on the node
typings.
That said, the docs also state that for types
directives:
Use these directives only when you’re authoring a
d.ts
file by hand
So if you have added this do a .ts
file rather than a .d.ts
file, you may be setting yourself up for further problems.
For declaring a dependency on an @types package in a .ts file, use –types on the command line or in your tsconfig.json instead. See using @types, typeRoots and types in tsconfig.json files for more details.