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

Reuse type assertion syntax with literal and tuple values for its type assertion #22872

Closed
falsandtru opened this issue Mar 25, 2018 · 6 comments
Labels
Duplicate An existing issue was already created

Comments

@falsandtru
Copy link
Contributor

This is very simple, clear, and easy syntax extension since this is reusing of verbose existing syntax. And it has no confusion neither semantic nor syntactic.

let b = true!; // type is true
let n = 0!; // type is 0
let s = 'a'!; // type is 'a'
let a = [0!]; // type is 0[]
let t = [0]!; // type is [number]

cc @sandersn @ahejlsberg

@yortus
Copy link
Contributor

yortus commented Mar 26, 2018

Looks the same as the suggestion in #10195 (comment).

@falsandtru
Copy link
Contributor Author

Yep, but that issue is not opened for this syntax.

@yortus
Copy link
Contributor

yortus commented Mar 26, 2018

Sure, but since discussion is already going on there about this syntax, so you might want to at least reference it from this issue.

@falsandtru
Copy link
Contributor Author

Of course; I've invited that discussion now.

@krryan
Copy link

krryan commented Mar 26, 2018

Could you use it on inner types? As in,

let t = [0!]!; // type is [0]

And if so, what happens if you use it on an inner type, but not on outer types?

let t = [0!]; // type is ???

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 26, 2018
@RyanCavanaugh
Copy link
Member

Tracking at #10195. Please don't post solutions for other issues as standalone issues.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 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

4 participants