You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespace empty object literal and https://github.com/Microsoft/TypeScript/tree/master/tests/cases
Code
varns={};// 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.
Yes, this is specific to JavaScript. In TypeScript you should declare the intended type of your variables beforehand. One exception will come for function types: #26368
TypeScript Version: 3.1.0xxxxx
Search Terms:
namespace empty object literal
andhttps://github.com/Microsoft/TypeScript/tree/master/tests/cases
Code
Expected behavior:
Release notes (source)
Actual behavior:
Compile error.
Playground Link:
Playground
Related Issues:
I'm migrating a codebase and tried a few minor variations unsuccessfully.
The text was updated successfully, but these errors were encountered: