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

Void type and type parameters constraints #4654

Closed
osdm opened this issue Sep 4, 2015 · 1 comment
Closed

Void type and type parameters constraints #4654

osdm opened this issue Sep 4, 2015 · 1 comment
Assignees
Labels
Spec Issues related to the TypeScript language specification

Comments

@osdm
Copy link

osdm commented Sep 4, 2015

Spec for 1.6, p. 3.6.1 says:

Omitting a constraint or specifying type any as the constraint corresponds to specifying the empty object type {}.

This phrase is not clear, because the following code works:

function foo<A>() {
    return 2;
}
var x = foo<void>();

and the following code doesn't

function foo<A extends {}>() {
    return 2;
}
var x = foo<void>();

Could you please clarify what is meant by the word "corresponds" then?

@danquirk danquirk added the Bug A bug in TypeScript label Sep 4, 2015
@ahejlsberg ahejlsberg added the Spec Issues related to the TypeScript language specification label Sep 7, 2015
@ahejlsberg
Copy link
Member

We should remove that statement from the spec and instead say that

  • Any type can be a type argument for a type parameter that has no constraint, and
  • A type parameter with no constraint has the same apparent members as type {}.

We can probably also remove the notion of a _base constraint_ as it isn't actually used anymore.

@ahejlsberg ahejlsberg self-assigned this Sep 7, 2015
@ahejlsberg ahejlsberg added this to the TypeScript 1.7 milestone Sep 7, 2015
@mhegazy mhegazy removed the Bug A bug in TypeScript label Sep 10, 2015
@mhegazy mhegazy modified the milestones: TypeScript 1.7, TypeScript 1.8 Oct 9, 2015
@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
Spec Issues related to the TypeScript language specification
Projects
None yet
Development

No branches or pull requests

4 participants