Skip to content

Conversation

ahejlsberg
Copy link
Member

This change adds support for parentheses in type literals. For example:

var a: (string | number)[];
var b: (() => string)[];
var b: (() => string) | (() => number);
var c: ((() => string) | (() => number))[];

There is a formal definition of the grammar in the updated language specification, but basically the grammar requires parentheses in the following cases:

  • When function and constructor types are used in union types.
  • When union, function, and constructor types are used in array types.

Similar to expressions, parentheses may be used for clarity in other contexts even if they aren't necessary.

@CyrusNajmabadi
Copy link
Contributor

👍 Very nice. Looks clean and simple. I wish the CR for the spec update parts were easier to understand (but that's not under your control).

ahejlsberg added a commit that referenced this pull request Oct 20, 2014
@ahejlsberg ahejlsberg merged commit 152a940 into master Oct 20, 2014
@ahejlsberg ahejlsberg deleted the parensInTypes branch October 20, 2014 16:43
@DanielRosenwasser DanielRosenwasser mentioned this pull request Nov 4, 2014
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants