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

Elaborate on non-portable types #53764

Open
5 tasks done
Andarist opened this issue Apr 13, 2023 · 0 comments
Open
5 tasks done

Elaborate on non-portable types #53764

Andarist opened this issue Apr 13, 2023 · 0 comments
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@Andarist
Copy link
Contributor

Suggestion

πŸ” Search Terms

type annotation elaboration not portable cannot be named

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

To improve DX this error message should mention what part of the type is not portable:

The inferred type of 'XX' cannot be named without a reference to '../../lib/foo'. This is likely not portable. A type annotation is necessary.

Perhaps it could even suggest what export is missing in the referenced module.

I've experienced a situation in which an inferred return value was an object with multiple properties and some nesting. One of its properties had a non-portable type. It would be a huge improvement if the error message could mention which property is not portable (let's say user in this example) and it would be even a bigger improvement if the name of the said type would be mentioned (let's say User in this example)

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Experience Enhancement Noncontroversial enhancements labels Apr 13, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 13, 2023
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants