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

[transpileDeclaration API] What to do about "has or is using private name" diagnostics #58496

Closed
6 tasks done
MichaelMitchell-at opened this issue May 10, 2024 · 1 comment Β· Fixed by #58536
Closed
6 tasks done
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@MichaelMitchell-at
Copy link

MichaelMitchell-at commented May 10, 2024

πŸ” Search Terms

isolated declarations transpile transpiledeclaration diagnostic private name

βœ… Viability Checklist

⭐ Suggestion

Either make ts.transpileDeclaration not report "has or is using private name" diagnostics, or provide a method to easily check whether a diagnostic is related to private names.

πŸ“ƒ Motivating Example

Usage of ts.transpileDeclaration for any project with isolatedDeclarations

πŸ’» Use Cases

ts.transpileDeclaration will report usage of global types such as Pick, Omit, Promise, or project-specific ones, as using private names. These are not really actionable, so I wonder if these diagnostics should just not be reported at all. What I've been doing is to just filter them out. The structured way of doing that is checking the diagnostic code, but there are so many codes to check that I decided to take a more unstructured approach by just checking diagnostic.messageText.includes('private name'). So at the very least, if these diagnostics will continue to be reported, it would be nice if there was some boolean method that says whether or not a given diagnostic is related to private names.

@weswigham weswigham added the Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it label May 13, 2024
@weswigham
Copy link
Member

weswigham commented May 13, 2024

I think this is just an unfortunate conflation of behaviors in our normal declaration emit errors. Emitting "X is using private name Y" when Y actually just doesn't resolve at all seems wrong - it's not that it's there but inaccessible from here, it's that it's not there at all. In all of these cases, the checker should be reporting a Name Y cannot be found error or the like (if it's run), so I don't think declaration emit should be doubling up on that with its' own confusing error. We probably want to trim "X is using private name Y" errors to just resolvable privates and leave the unresolved names errors to the checker pass.

@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels May 13, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants