Skip to content

Don't escape unicode characters in import/export paths in reported errors #57550

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #57539

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Feb 26, 2024
@@ -4324,7 +4324,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
symbolFromModule || symbolFromVariable;
if (!symbol) {
errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, node, name);
errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, getSourceFileOfNode(node), name);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on the printer selection in symbolToStringWorker. While the containing function also accepts node.kind === SyntaxKind.VariableDeclaration, such a node doesn't reach this line in any test case so I'm currently not 100% sure if I can just call getSourceFileOfNode unconditionally here. I think it's OK for imports and exports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misrepresenting the location that we’re going to scope a symbol reference from sounds like a bad idea—the original fix in #39463 that you’re building on here feels a little too magically indirect to begin with to me. Is there any way you see to make the printer escaping behavior more directly dependent on whether a module specifier is being printed?

@@ -6375,7 +6375,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {

function symbolToStringWorker(writer: EmitTextWriter) {
const entity = builder(symbol, meaning!, enclosingDeclaration, nodeFlags)!; // TODO: GH#18217
// add neverAsciiEscape for GH#39027
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now not only about this issue - I'm not sure if this comment has a lot of value here. If you think otherwise, I can bring it back.

@@ -4324,7 +4324,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
symbolFromModule || symbolFromVariable;
if (!symbol) {
errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, node, name);
errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, getSourceFileOfNode(node), name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misrepresenting the location that we’re going to scope a symbol reference from sounds like a bad idea—the original fix in #39463 that you’re building on here feels a little too magically indirect to begin with to me. Is there any way you see to make the printer escaping behavior more directly dependent on whether a module specifier is being printed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

unintended escaped string for hover
4 participants