VS Code enforces semicolons but why doesn t Angular and TypeScript not use it consistently

0 votes

I'm taking the Microsoft Angular Fundamentals course right now and I spotted lack of semicolons in their examples, something like:

gitSearch = (query: string): Promise<GitSearch> => {
    let promise = new Promise<GitSearch>((resolve, reject) => {
        if (this.cachedValues[query]) {
            resolve(this.cachedValues[query])
        }
        else {
            this.http.get('https://api.github.com/search/repositories?q=' + query)
            .toPromise()
            .then( (response) => {
                resolve(response as GitSearch)
            }, (error) => {
                reject(error);
            })
        }
    })
    return promise;
  }

Notice they don't use semicolons after resolve.thisCachedValues[query]). But VS Code gives me TSLint warning 'Missing semicolon' at that line. Is this an issue if I omit the semicolon?

May 31, 2022 in TypeSript by Logan
• 2,140 points
4,222 views

1 answer to this question.

0 votes

JavaScript has a syntactic feature known as semicolon insertion. Since Typescript is a strict superset of JavaScript, semicolon insertion applies to Typescript as well. This means that in most cases, semicolons are not required. You can refer the documentations for more information.

To know more about Angular, It's recommended to join online Angular Course today.

answered May 31, 2022 by Nina
• 3,060 points

Related Questions In TypeSript

0 votes
0 answers
0 votes
0 answers

What is TypeScript and why would I use it in place of JavaScript?

Can you please describe what the TypeScript ...READ MORE

Jul 18, 2022 in TypeSript by Logan
• 2,140 points
197 views
0 votes
1 answer

The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.3 was found instead

Run this script to find exact version npm ...READ MORE

answered Aug 3, 2022 in TypeSript by Abhinaya
• 1,160 points
3,723 views
0 votes
1 answer
0 votes
1 answer

How to set meta tags using Angular universal SSR and ngx-seo plug-in?

first Install the plug-in with npm i ngx-seo ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,420 points
1,922 views
0 votes
1 answer

Can't bind to 'ngModel' since it isn't a known property of 'input'

Just add this in the app.module.ts file: import { FormsModule ...READ MORE

answered Apr 30, 2022 in Other DevOps Questions by narikkadan
• 63,420 points
3,937 views
0 votes
1 answer

Square brackets around vs after expression in Typescript

x is an Array, while y is a Tuple. The ...READ MORE

answered Jun 7, 2022 in TypeSript by Nina
• 3,060 points
3,223 views
0 votes
1 answer

What does the @ (at sign) sign do in TypeScript?

The big news this week is the ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
607 views
0 votes
1 answer

What is TypeScript and why would I use it in place of JavaScript?

TypeScript is a superset of JavaScript which primarily ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
317 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP