Skip to content

Allow void ternary expressions #2060

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

Merged
merged 2 commits into from
Sep 10, 2021
Merged

Allow void ternary expressions #2060

merged 2 commits into from
Sep 10, 2021

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Sep 10, 2021

Fixes #1960 by special-casing compilation of ternary ifs where contextual type is void, dropping each arm evaluating to a concrete value, including ignoring type mismatch if not relevant.

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@MaxGraey
Copy link
Member

MaxGraey commented Sep 10, 2021

could you also add this test?

function boo(): void {}
function foo(fn: () => void): void {
  fn();
}
foo(() => boo()); // allow return void

@dcodeIO
Copy link
Member Author

dcodeIO commented Sep 10, 2021

Seems like a separate issue that is rather related to return. Does the code snippet work right now?

@MaxGraey
Copy link
Member

Does the code snippet work right now?

no Currently it broke compiler

@dcodeIO
Copy link
Member Author

dcodeIO commented Sep 10, 2021

Wasn't there an issue somewhere about that, hmm...

@MaxGraey
Copy link
Member

not sure but I can create

@dcodeIO
Copy link
Member Author

dcodeIO commented Sep 10, 2021

I think there was, but can't find it rn. And yeah, a new one seems good :)

@dcodeIO dcodeIO merged commit c23059a into main Sep 10, 2021
@dcodeIO dcodeIO deleted the issue-1960 branch September 14, 2021 12:21
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.

bug: Type 'void' is not assignable to type 'void' although not returning the expression
2 participants