X Tutup
Skip to content

Fix nullish coalescing and conditionals when using generics#1191

Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
GlassBricks:fix-falsy-generics
Dec 21, 2021
Merged

Fix nullish coalescing and conditionals when using generics#1191
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
GlassBricks:fix-falsy-generics

Conversation

@GlassBricks
Copy link
Contributor

Fixes #1184

return ternary(true, ${trueVal}, "wasFalse")
`
.setOptions({
strict: true,
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for adding this strict here?

Copy link
Contributor Author

@GlassBricks GlassBricks Dec 20, 2021

Choose a reason for hiding this comment

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

if its not strict, in the old logic, due to any object possibly being null, it will always use an if statement, and so the current logic is not tested (wasn't previously a failing test).
I could change this to strictNullChecks to be more clear

@Perryvw Perryvw merged commit 2429e26 into TypeScriptToLua:master Dec 21, 2021
@GlassBricks GlassBricks deleted the fix-falsy-generics branch March 16, 2022 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong not-falsy assumption when using generics

2 participants

X Tutup