Does the import operation really occupy a semicolon?

I found some import statements for my .ts files in ion projects:

import { Component } from '@angular/core' 

instead

 import { Component } from '@angular/core'; 

which skips the semicolon, and the projects seem to run fine, does the import operator really need a semicolon at the end?

+5
source share
2 answers

Javascript only requires a semicolon to separate statements on a single line. However, I would recommend that you follow good practices and use them.

From the manual for typescript

Use semicolons:

Reasons: Explicit semicolons help language formatting tools give consistent results. The lack of ASI (automatic semicolon) may disable new developers, for example.

 foo() (function(){}) 

there will be one operator (not two).

I understand that ultimately it is a matter of style, since you should not have any problems if you do not use them when they are not strictly required, although in order to be consistent, it is better to use them than not.

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

Hope this helps!

+1
source

Like any other line in JavaScript, you do not need it.

0
source

Source: https://habr.com/ru/post/1259945/


All Articles