> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Single-line Comment

A single-line comment in TypeScript is a lexical construct initiated by a double forward-slash (`//`) or triple forward-slash (`///`) that extends to the next line terminator (such as `\n` or `\r`) or the End of File (EOF). While standard single-line comments act as non-executable text, the TypeScript compiler explicitly parses specific single-line comments as pragmas or directives that directly alter type-checking evaluation, diagnostic reporting, and module resolution.

Standard single-line comments are scanned and processed during the lexical analysis and parsing phases. During the emit phase, the compiler (`tsc`) merely determines whether to strip or preserve them in the generated JavaScript output based on the `removeComments` boolean flag in the `tsconfig.json` configuration.

```typescript theme={"dark"}
// Standard single-line comment preceding a statement
const isCompiled: boolean = true; 

const compilerTarget: string = "ES6"; // Inline single-line comment
```

**Compiler Directives**
Unlike standard JavaScript, TypeScript evaluates specific single-line comments as compiler instructions rather than ignored text. These are categorized into type-checking directives and triple-slash directives.

**Type-Checking Directives**
Initiated by `//` followed by specific `@ts-` flags, these comments alter the compiler's diagnostic behavior for the subsequent line or the entire file:

* `// @ts-expect-error`: Suppresses the compiler error on the following line, but emits a new error if no type error actually exists.
* `// @ts-ignore`: Unconditionally suppresses any compiler error on the following line.
* `// @ts-check`: Enables standard type-checking for a JavaScript (`.js`) file (equivalent to enabling the `checkJs` compiler option). Whether the checking is strict depends on the `strict` family of compiler options in the configuration.
* `// @ts-nocheck`: Disables type-checking for the entire file.

```typescript theme={"dark"}
// @ts-expect-error
const count: number = "string"; 
```

```typescript theme={"dark"}
// @ts-ignore
const data: boolean = 1;
```

```typescript theme={"dark"}
// @ts-nocheck
// Disables checking for this entire file, preventing errors on the following line
const uncheckedVariable: number = "string";
```

```javascript theme={"dark"}
// @ts-check
// Enables type-checking for this specific .js file
let checkedVariable = 10;
```

**Triple-Slash Directives**
A specialized single-line comment initiated by `///` containing a single XML tag. These must be placed at the top of the file (prior to any statements) and instruct the compiler on dependency resolution, type declarations, and compilation context.

```typescript theme={"dark"}
/// <reference path="internal-types.d.ts" />
/// <reference types="node" />
/// <reference lib="es2019.array" />
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor TypeScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
