Does import statement need semicolon actually?

OP is asking about if semicolons are required in an import statement.

Use semi colons when declaring variables, returning something or making variable calls, as you are declaring a variable with the import it is my understanding that you should use a semicolon.


Javascript only requires semicolons to separate statements in the same line. However I'd recommend you to stick to the good practices and use them.

From the style guide for typescript

Use semicolons:

Reasons: Explicit semicolons helps language formatting tools give consistent results. Missing ASI (automatic semicolon insertion) can trip new devs e.g.

foo() (function(){}) 

will be a single statement (not two).

I understand that ultimately this is a matter of style, as you shouldn't have any issues if you don't use them when they are not strictly required, although in order to be consistent, it's better to use them than not.

This is a pretty good article also. https://www.codecademy.com/blog/78

Hope this helps!

Tags:

Ecmascript 6