TS1036
error TS1036: Statements are not allowed in ambient contexts.
Broken Code ❌
1 |
|
Fixed Code ✔️
With declare global
an ambient context is created. TypeScript does not allow statements in such ambient context declaration which is why we have to change the statement into a declaration:
1 |
|
If you don’t want client
to be a function, you have to use the
var` keyword:
1 |
|