Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add check to see in ownerSymbol parent is the global symbol#1472

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
starsprung wants to merge1 commit intoTypeScriptToLua:master
base:master
Choose a base branch
Loading
fromstarsprung:fix-node-console-log

Conversation

@starsprung
Copy link

@starsprungstarsprung commentedAug 5, 2023
edited
Loading

Add check to see in ownerSymbol.parent is the global symbol when determining when to transform global builtin calls.

I'm not sure if this is the appropriate fix, but this change allows calls toconsole.log to compile correctly when using the types from @types/node and not using thedom lib. They already work correctly with the type declarations inlib.dom.d.ts, due to a difference in structure:Node's typings wrapconsole insideglobal { }, which means it has a parent, whereas console fromlib.dom.d.ts doesn't.

E.g.
Input

console.log('test');

tstl output without fix

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]console:log("hello world")

tstl output with fix

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]print("hello world")

when determining when to transform global builtin calls.
){
constownerType=context.checker.getTypeAtLocation(calledMethod.expression);
constownerSymbol=tryGetStandardLibrarySymbolOfType(context,ownerType);
if(!ownerSymbol||ownerSymbol.parent)return;
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if instead we shouldn't just be removing thisownerSymbol.parent, not really sure if it adds anything

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@PerryvwPerryvwPerryvw left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@starsprung@Perryvw

[8]ページ先頭

©2009-2025 Movatter.jp