Skip to content

Commit ac46f10

Browse files
authored
Merge pull request #3121 from onufd/patch-3
Update part9b.md
2 parents 76b6bd7 + 24926ae commit ac46f10

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/content/9/en/part9b.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,8 @@ If the query parameters of the request are of the wrong type or missing, a respo
833833

834834
Do not copy the calculator code to file *index.ts*; instead, make it a [TypeScript module](https://www.typescriptlang.org/docs/handbook/modules.html) that can be imported into *index.ts*.
835835

836+
For *calculateBmi* to work correctly from both the command line and the endpoint, consider adding a check *require.main === module* to the file <i>bmiCalculator.ts</i>. It tests whether the module is main, i.e. it is run directly from the command line (in our case, *npm run calculateBmi*), or it is used by other modules that import functions from it (e.g. <i>index.ts</i>). Parsing command-line arguments makes sense only if the module is main. Without this condition, you might see argument validation errors when starting the application via *npm start* or *npm run dev*.
837+
836838
</div>
837839

838840
<div class="content">

0 commit comments

Comments
 (0)