microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
99.34k stars 12.31k forks source link

JS should allow merging/expando properties on imports #26912

Open sandersn opened 5 years ago

sandersn commented 5 years ago
// Filename: mod.js
export const Ns = function () { }

// @Filename: use.js
import { Ns } from './mod'
Ns.expando = 1

Expected behavior: No error, and Ns has property 'expando'

Actual behavior: Error, 'expando' not found on 'Ns'.

This merge shouldn't be allowed in Typescript, but it will work in Javascript, so it should be allowed there.

weswigham commented 5 years ago

Of note: This "works in javascript" in CJS and similar runtimes. However a real es6 namespace object would be immutable and it wouldn't work. So.... eh? Kinda depends on the output target.