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

Shorter syntax for optional return types #13184

Closed
zakjan opened this issue Dec 27, 2016 · 1 comment
Closed

Shorter syntax for optional return types #13184

zakjan opened this issue Dec 27, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@zakjan
Copy link

zakjan commented Dec 27, 2016

Currently there is shorter syntax for optional named fields, the question mark next to the field name, field?: string means field: string | undefined.

Could this syntax be extended from named fields to all types in general? For example string? would mean string | undefined.

It would allow using this shorter syntax in function return types:

Proposed syntax:

function identity(value: string?): string? {
    return value;
}

Current syntax:

function identity(value?: string): string | undefined {
    return value;
}

(This should stay supported for backward compatibility.)

@aluanhaddad
Copy link
Contributor

@zakjan have fun in #7426

@zakjan zakjan closed this as completed Dec 27, 2016
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 27, 2016
@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants