Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import namespace exports should be immutable #2456

Closed
JsonFreeman opened this issue Mar 22, 2015 · 5 comments · Fixed by #2476
Closed

Import namespace exports should be immutable #2456

JsonFreeman opened this issue Mar 22, 2015 · 5 comments · Fixed by #2476
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

We should not allow mutating a property of a namespace import:

// Library
export var x = 1;

// Consumer
import * as stuff from 'Library';
stuff.x = 0;

In ES6, these bindings are immutable.

@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Mar 22, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 24, 2015
@vladima vladima added the Fixed A PR has been merged for this issue label Mar 24, 2015
@vladima vladima reopened this Apr 1, 2015
@vladima vladima removed the Fixed A PR has been merged for this issue label Apr 1, 2015
@mhegazy mhegazy modified the milestones: TypeScript 1.6, TypeScript 1.5 Apr 1, 2015
vladima added a commit that referenced this issue Apr 1, 2015
revert fix for #2456 'Import namespace exports should be immutable'
@mhegazy mhegazy added the ES6 Relates to the ES6 Spec label Apr 2, 2015
@JsonFreeman
Copy link
Contributor Author

Why was the fix for this reverted?

@mhegazy
Copy link
Contributor

mhegazy commented Apr 8, 2015

it breaks existing module import syntax. The fix did not handle all cases correctly. we probably need to do it "right" by adding a readonly flag on the type and checking it everywhere.

@JsonFreeman
Copy link
Contributor Author

To clarify, this breaks the import blah = require(...) scenario. We'd have to disallow this only for properties of namespaces.

@Arnavion
Copy link
Contributor

Fixed by #6532 ( e506378 )?

@JsonFreeman
Copy link
Contributor Author

If the exports on the namespace objects are marked readonly, then yes.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 22, 2016
@mhegazy mhegazy closed this as completed Feb 22, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants