Skip to content

Stop block transpilation after encountering a return statement#161

Merged
Perryvw merged 5 commits intomasterfrom
feature/code-after-return
Jul 29, 2018
Merged

Stop block transpilation after encountering a return statement#161
Perryvw merged 5 commits intomasterfrom
feature/code-after-return

Conversation

@Perryvw
Copy link
Copy Markdown
Member

@Perryvw Perryvw commented Jul 28, 2018

Addresses #153

@Perryvw Perryvw requested a review from lolleko July 28, 2018 15:57

// Don't transpile any dead code after a return
if (ts.isReturnStatement(statement)) {
break;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please no breaks.

`class def { public static abc() { return 3; const a = 5; } } return def.abc();`);

Expect(result).toBe(3);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

namespaces also use transpire block a test would be nice.

Copy link
Copy Markdown
Member Author

@Perryvw Perryvw Jul 28, 2018

Choose a reason for hiding this comment

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

You cannot return from a namespace since it is not a function body.

`if (true) { return 3; const b = 8; }`);

Expect(result).toBe(3);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

switch also use transpileblock irrc, but I think this is less important than the namespace test and probably not needed.

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 28, 2018

Codecov Report

Merging #161 into master will increase coverage by 0.49%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #161      +/-   ##
==========================================
+ Coverage   96.02%   96.51%   +0.49%     
==========================================
  Files           9        9              
  Lines        1081     1349     +268     
  Branches      179      247      +68     
==========================================
+ Hits         1038     1302     +264     
- Misses         18       22       +4     
  Partials       25       25
Impacted Files Coverage Δ
src/Transpiler.ts 96.86% <100%> (+0.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c10c28...f09f2f0. Read the comment docs.

@Perryvw Perryvw merged commit 07c836c into master Jul 29, 2018
@Perryvw Perryvw deleted the feature/code-after-return branch July 29, 2018 12:19
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.

2 participants