Skip to content

No compile error when generic type inferred to be {} #756

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
duncanbrown opened this issue Sep 26, 2014 · 2 comments
Closed

No compile error when generic type inferred to be {} #756

duncanbrown opened this issue Sep 26, 2014 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@duncanbrown
Copy link

I think the following should result in an error, but it passes the type checker:

function foo<T>(getT: () => T, setT: (t: T) => void) { }

function getString() {
    return 'a';
}

function setNum(n: number) { }

foo(getString, setNum);

Hovering over the call to foo in VS or the Playground shows that T has been inferred to be of type {}, but since {} isn't of type number, doesn't that make setNum an invalid argument to be passing in?

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Sep 26, 2014
@DanielRosenwasser
Copy link
Member

Seems to be a duplicate of #360.

@RyanCavanaugh
Copy link
Member

Yep

@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants