Skip to content

Use type name in error messages and inline doc #16798

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
testerez opened this issue Jun 28, 2017 · 2 comments
Closed

Use type name in error messages and inline doc #16798

testerez opened this issue Jun 28, 2017 · 2 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@testerez
Copy link

TypeScript Version: 2.4.0

Code

const foo = {
  name: 'Foo',
  age: 20,
}
type Foo = typeof foo;

function test(foo: Foo) { }

test('');

Expected behavior:

I'd like the error message to be:

Argument of type '""' is not assignable to parameter of type Foo

And the inline doc to be:

function test(foo: Foo): void

Actual behavior:
But the error message is

Argument of type '""' is not assignable to parameter of type '{ name: string; age: number; }'.

And the inline doc is

function test(foo: {
    name: string;
    age: number;
}): void

In this example, the current behavior is alright but in more complicated situations the error messages can become very verbose and intimidating. Using the types name would make them a lot cleaner IMO.

@mhegazy
Copy link
Contributor

mhegazy commented Aug 24, 2017

Type aliases are just aliases, and they are eagerly resolved to what they alias by the compiler. This saves the compiler time and space when dealing with types. we try to do a reverse lookup process when we are writing the type name, but there is a limit to that.

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Aug 24, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 8, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 8, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants