You are on page 1of 14

Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

TypeScript basics

npm install –g typescript :installa globaly typescript

tsc --version : version of typescript


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

tsc tp1.ts : pour compiler un fichier typescript

node tp1 : pour exécuter le programme.


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Differene between var and let


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

We sill generate js from typescript but we can catch the issue earlier at compile time

We can put at the same time

tsc main.ts |node main.js

Les types en typescript


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Type assertion ; c’est le casting

On caste un type à une variable (type any) pour avoir les intellisence(code completion,
parameter info, quick info, and member lists. IntelliSense features are sometimes called by other
names such as "code completion", "content assist", and "code hinting.")

on appel ça en arrow méthode, ça ressemble à l’expression lambda en Java et c#


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Sur une seule ligne on peut enlever les accolades

Les interfaces : des modèle d’objet avec des méthodes abstraites si elles existent
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Les classes : Attributs et méthodes concrètes

Les objets :
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Ca va pas marcher car il faut utiliser le new !


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Accès Modifiers

Constructor

En Typesript on a le droit à un seul constructeur, donc pour pouvoir utiliser plusieurs


constructeurs, o utilise les paramètres optionnels précédé de  ? Une fois on met le ? sur un
paramètres, les autres paramètres à droites doivent être aussi optionnel.
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Acces modifers dans les paramètres du constructeur

On peut initialiser les paramètres d’un constructeur sans déclarer des attributs, directement
dans le constructeur.
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Les properties
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Les modules en typescript (on va voir après les modules en angular) : C’est un fichier .ts, il peut
contenir une ou plusieurs classes. IL faut exporter la classe pour qu’elle soit visible de
l’extérieur; puis il faut l’importer pour l’utiliser
Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Ici l’import

On doit importer le module du chemin relatif à partir du fichier appelant

Pour compiler plusieurs fichiers et exécuter un fichier principal


Trainning: Springboot & Angular 8 Workshop n° 5: Angular 8

Trainner: Dr. Mohamed Amine MEZGHICH Goals: Typescript

Period of trainning :30 Hours November Session 20 June th, 2020

Email : ma.mezghich@smart-it-partner.com

Phone : +216 51 36 36 34

Parfois certains élément sont accessible avec ECMA 5 et plus

Du coup il faut changer ça au niveau compilateur

A propos des properties (get puis espace puis le nom de la propriétés)

You might also like