Skip to content

Discussion: Type casting and typing = position ambiguity #6519

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

Closed
Alphapage opened this issue Jan 17, 2016 · 2 comments
Closed

Discussion: Type casting and typing = position ambiguity #6519

Alphapage opened this issue Jan 17, 2016 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@Alphapage
Copy link

Hello,

Here is my code example:

let value : any;                   // ok javascript like 
(<string[]>value).length     // why not (value<string[]>).length

< string[] > value is more c# like : (string[])value in c#

Why not using a javascript style for typing and type casting: always put typing at the end of the expression ? (I mean "javascript style" because :any signature seems to be adopted)

Thanks in advance for your answers.

@ahejlsberg
Copy link
Member

We already support postfix type assertions using the as operator, so if you prefer that you can simply write (value as string[]).length.

@ahejlsberg ahejlsberg added the Question An issue which isn't directly actionable in code label Jan 17, 2016
@Alphapage
Copy link
Author

Thank you. You learn me something. +1

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants