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

Question, 'any' type compatible type to Object type. #1944

Closed
NN--- opened this issue Feb 5, 2015 · 2 comments
Closed

Question, 'any' type compatible type to Object type. #1944

NN--- opened this issue Feb 5, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@NN---
Copy link

NN--- commented Feb 5, 2015

I want a type similar to 'any' but can be initialized only with Object compatible type.
Is it possible to do this ?

var a : {any};

a.x = 1; // OK
a["x"] = 1; // OK
a = {}; // OK
a = 1; // Error !

The workaround is to use indexer, but then syntax 'a.x' doesn't work.

var a: {[key: string]: any;};

a = 1; // Error
@danquirk
Copy link
Member

danquirk commented Feb 6, 2015

I think this is roughly a duplicate of the request here #1809.

@danquirk danquirk closed this as completed Feb 6, 2015
@danquirk danquirk added the Duplicate An existing issue was already created label Feb 6, 2015
@NN---
Copy link
Author

NN--- commented Feb 6, 2015

Yes, exactly what I want.
Thanks

@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants