Skip to content

Commit 4f4ee0a

Browse files
authored
docs: add section on decorators (#48)
This PR attempts to add some clarification about the expectations around decorator usage with `ts-blank-space`. Signed-off-by: Ashley Claymore <[email protected]>
1 parent 4102b1f commit 4f4ee0a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/unsupported_syntax.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The following TypeScript features can not be erased by `ts-blank-space` because
1212
- `module` (unless `declare module "path"`) [more details](#module-namespace-declarations)
1313
- `import lib = ...`, `export = ...` (TypeScript style CommonJS)
1414
- `constructor(public x) {}` [more details](#constructor-parameter-properties)
15+
- `experimentalDecorators` and `emitDecoratorMetadata` [more details](#decorators)
1516

1617
For more details on use of `declare` see [the `declare` hazard](#the-declare--hazard).
1718

@@ -129,6 +130,17 @@ So it may throw at runtime if nothing created a runtime value for `N` as promise
129130

130131
Tests are a great way to catch issues that may arise from an incorrect `declare`.
131132

133+
### Decorators
134+
135+
Decorators in TypeScript have two different interpretations. There is the [official stage 3 decorators proposal](https://github.com/tc39/proposal-decorators) and TypeScript's own [`experimentalDecorators`](https://www.typescriptlang.org/tsconfig/#experimentalDecorators).
136+
137+
As `ts-blank-space` only removes type annotations, and decorators are a runtime feature they are correctly preserved in the output. However, at the time of writing, there are no runtimes that have shipped support for the decorator syntax. If a JavaScript runtime does add support it will be for https://github.com/tc39/proposal-decorators and not `experimentalDecorators`.
138+
139+
Further reading on decorators:
140+
141+
- https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#decorators
142+
- https://2ality.com/2022/10/javascript-decorators.html
143+
132144
## Compile time only syntax
133145

134146
TypeScript type assertions have no runtime semantics, however `ts-blank-space` does not erase the legacy prefix-style type assertions.

0 commit comments

Comments
 (0)