Skip to content

Better errors for non-exported types #29624

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
DanielRosenwasser opened this issue Jan 28, 2019 · 3 comments · Fixed by #36187
Closed

Better errors for non-exported types #29624

DanielRosenwasser opened this issue Jan 28, 2019 · 3 comments · Fixed by #36187
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jan 28, 2019

// @filename a.ts

declare function foo(): any

declare function bar(): any;

export { bar };

// @filename b.ts

import { foo, bar } from "./a";

Currently we provide the following error messages:

Module '"./a"' has no exported member 'foo'.
Module '"./a"' has no exported member 'bar'.

We could instead provide the errors:

Module '"./a"' declares 'foo' locally, but it is not exported.
Module '"./a"' declares 'bar' locally', but it is exported as 'baz'.

Also using the

'{0}' is declared here.

related span.

Later on, we could provide quick fixes to respectively

  • Export foo from ./a.
  • Correct the usage of bar to baz.
@DanielRosenwasser DanielRosenwasser changed the title Better error for non-exported types Better errors for non-exported types Jan 28, 2019
@DanielRosenwasser DanielRosenwasser added Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements labels Jan 28, 2019
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.4.0 milestone Jan 28, 2019
@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Mar 7, 2019
@a-tarasyuk
Copy link
Contributor

@DanielRosenwasser Is there any way to check if a variable was declared in a module? I mean, in order to show message Module '"./a"' declares 'foo' locally, but it is not exported., need to check if it was declared in a module locally.

@DanielRosenwasser
Copy link
Member Author

There should be a symbol table for sourceFile.locals if it's non-exported (as opposed to sourceFile.symbol.exports.

@DanielRosenwasser DanielRosenwasser added Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Dec 17, 2019
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Jan 21, 2020
@DanielRosenwasser
Copy link
Member Author

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Error Messages The issue relates to error messaging Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants