Closed
<
6899
div class="Box-sc-g0xbh4-0 dkqtNN">
Description
TypeScript Version: 3.1.0xxxxx
Search Terms:
namespace empty object literal
and https://github.com/Microsoft/TypeScript/tree/master/tests/cases
Code
var ns = {}; // recognized as a declaration for a namespace `ns`
ns.constant = 1; // recognized as a declaration for var `constant`
// ^^^^^^^^ <- Property 'constant' does not exist on type '{}'.
Expected behavior:
TypeScript 2.8 adds support for understanding more namespace patterns in
.js
files. Empty object literals declarations on top level, just like functions and classes, are now recognized as as namespace declarations in JavaScript.
Actual behavior:
Compile error.
Playground Link:
Related Issues:
I'm migrating a codebase and tried a few minor variations unsuccessfully.