Skip to content

Commit a337bf7

Browse files
committed
Updated FAQ (markdown)
1 parent 10d4331 commit a337bf7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

FAQ.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ In order to ensure that the flag doesn't have any "gaps", requests to change the
8484

8585
Note: Section titles here state the *true* version of the fact.
8686

87+
## Comment Emit is Best-Effort
88+
89+
When TypeScript emits JavaScript, it does not guarantee that 100% of source comments will be present in the output.
90+
Not storing or computing comment ranges on emit is important for performance, and reasonable people can and do disagree about which comment blocks "belong" to either type (thus omitted) or expression (thus retained) constructs, so in general you should not take a hard dependency on comments being preserved or removed in arbitrary positions.
91+
92+
You can *generally* expect comments to be preserved in cases where the comment immediately precedes a value declaration
93+
```ts
94+
// This comment will be in the output
95+
const n = 5;
96+
```
97+
98+
Comments will *generally* not be emitted when they occur inside types:
99+
```ts
100+
interface Foo {
101+
// This comment won't be in the output
102+
s: string;
103+
}
104+
```
105+
106+
There are no specified guarantees on comme if you need 100% comment preservation according to some metric, we recommend using a different emit tool.
107+
Edge cases or "inconsistencies" *will not be considered as defects*, and we don't accept PRs to tinker with comment emit.
108+
87109
### Primitives are `{ }`, and `{ }` Doesn't Mean `object`
88110

89111
The type `{ }` refers to any (non-null/undefined) value with zero or more properties.

0 commit comments

Comments
 (0)