Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Linting TypeScript

Автор: kudvenkat

Загружено: 2017-10-24

Просмотров: 32709

Описание:

Text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

Slides
http://csharp-video-tutorials.blogspo...

Angular CLI Tutorial
   • What is Angular CLI  

Angular CLI Text articles & Slides
http://csharp-video-tutorials.blogspo...

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...

All Dot Net and SQL Server Tutorials in Arabic
   / kudvenkatarabic  

In this video we will discuss Linting TypeScript Code

Angular has a linting tool that checks our TypeScript code for programmatic and stylistic errors as well as non-adherence to coding standards and conventions. tslint.json is the configuration file for linting. This file contains all the default rules for linting our code.

For the purpose of this demo I have created a brand new Angular project using the following command.
ng new AngularProject

Use the following command to lint the code
ng lint

Since we have just generataed a new angular project and all the code in the project is auto-generated, we do not have any linting errors and we get the message - All files pass linting.

We also see the following warning
Warning: The 'no-use-before-declare' rule requires type checking

Basically this warning is saying, if 'no-use-before-declare' rule is enabled we need to use --type-check option with the ng lint command
ng lint --type-check

'no-use-before-declare' rule is enabled out of the box and it disallows usage of variables before their declaration. To understand what this means, place the following sayHello() function in AppComponent class in app.component.ts file.
sayHello() {
console.log(message);
var message = 'Hello';
message = message + ' Pragim';
}

At this point, execute ng lint command again with --type-check option.

ERROR: C:/AngularProject/src/app/app.component.ts[12, 17]: variable 'message' used before declaration
ERROR: C:/AngularProject/src/app/app.component.ts[13, 5]: Forbidden 'var' keyword, use 'let' or 'const' instead

Lint errors found in the listed files.

Out of the box, "no-var-keyword" rule is also enabled by default. Turn this rule off by setting it's value to false in tslint.json
"no-var-keyword": true

Run ng lint command again with --type-check option

Notice, now we only get 1 linting error
variable 'message' used before declaration

Now modify the code in sayHello() function as shown below.
sayHello() {
var message = 'Hello';
message = message + ' Pragim';
console.log(message);
}

Run ng lint command again with --type-check option. Notice now we do not get any linting errors.

Variables declared with let keyword are not accessible before they are declared. So this rule 'no-use-before-declare' can be safely disabled, if you have 'no-var-keyword' rule enabled. When 'no-use-before-declare' rule is disabled and when we run ng lint command without --type-check option, we will no longer get the below warning
The 'no-use-before-declare' rule requires type checking

Linting TypeScript

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Angular tslint rules

Angular tslint rules

Angular Routing

Angular Routing

Angular CLI configuration file

Angular CLI configuration file

Я Построил Молот Высокого Давления

Я Построил Молот Высокого Давления

"Игра в кальмара" по версии Первого канала - КВН Не кипишуй

Почему нельзя делить на ноль? – Алексей Савватеев | Лекции по математике | Научпоп

Почему нельзя делить на ноль? – Алексей Савватеев | Лекции по математике | Научпоп

Angular CLI tutorial for beginners

Angular CLI tutorial for beginners

Сергей Тихановский уехал, а Светлана осталась / Лукашенко придумал хитрый план: подробности

Сергей Тихановский уехал, а Светлана осталась / Лукашенко придумал хитрый план: подробности

Самый короткий тест на интеллект Задача Массачусетского профессора

Самый короткий тест на интеллект Задача Массачусетского профессора

Задача века решена!

Задача века решена!

Я тренировал одну сторону ТЯЖЕЛЫЕ против ЛЕГКИХ (60-дневный эксперимент)

Я тренировал одну сторону ТЯЖЕЛЫЕ против ЛЕГКИХ (60-дневный эксперимент)

Ошибки наследования

Ошибки наследования

Каково это — изобретать математику?

Каково это — изобретать математику?

Программирование на ассемблере без операционной системы

Программирование на ассемблере без операционной системы

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Я в опасности

Я в опасности

Я качаю печень — Уральские Пельмени | География Уральских Пельменей - Папуа - Новая Гвинея

Я качаю печень — Уральские Пельмени | География Уральских Пельменей - Папуа - Новая Гвинея

Задача про надёжный пароль | В интернете опять кто-то неправ #035 | Борис Трушин и Математик Андрей

Задача про надёжный пароль | В интернете опять кто-то неправ #035 | Борис Трушин и Математик Андрей

Как взломать любое программное обеспечение

Как взломать любое программное обеспечение

Я ненавижу длинные цепочки If-Elif: этот шаблон проектирования решил эту проблему раз и навсегда

Я ненавижу длинные цепочки If-Elif: этот шаблон проектирования решил эту проблему раз и навсегда

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com