Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Certified Typescript Programming Expert Β· Lesson 2 of 16

Module One

πŸ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
2
Module 1 Β· Certified TypeScript Programming Expert Β· Beginners

πŸ“˜ Module One: Introduction to TypeScript – The Language That Makes Coding Safer


πŸ“– Module Introduction

Hello, future programmer! Welcome to the first module of Certified TypeScript Programming Expert. In this module, we will meet a powerful tool called TypeScript.

TypeScript is a programming language that helps developers write better and safer code. It is based on JavaScript – the language that powers the web. But TypeScript adds extra features that make it easier to catch mistakes and build large applications.

In this module, you will learn what TypeScript is, why it was created, and how it works. You will also set up your computer to write TypeScript code.

Let's start our journey into the world of TypeScript!


🎯 Learning Objectives

By the end of this module, you will be able to:

  • Explain what TypeScript is.
  • Understand why TypeScript was created.
  • Describe how TypeScript works with JavaScript.
  • Set up a TypeScript environment on your computer.
  • Write your first TypeScript program.

πŸ“š Warm-up Story: The Bug That Broke the Bank

In Lagos, a team of developers was building a banking app. The app was written in JavaScript. It worked well – until one day, a bug appeared. Customers were seeing wrong balances, and money was being transferred incorrectly.

The developers spent days trying to find the bug. They checked line after line of code. Finally, they found it – a simple mistake: a string was being used as a number.

One developer, Chidi, said, "This would not have happened if we had used TypeScript. TypeScript would have caught this error before we even ran the code."

The team decided to learn TypeScript. They rewrote the app in TypeScript and the bugs disappeared. Chidi said, "TypeScript saved our business!"

This is why we are here – to learn how TypeScript can help us build better software.


πŸ“˜ Main Lessons

Lesson 1: What is JavaScript?

Definition: JavaScript is a programming language used to make websites interactive.

Why is it important? It is the language of the web – almost every website uses it.

Simple explanation: JavaScript makes things move, change, and respond on web pages.

Real-life example: When you click a button and a message pops up, that's JavaScript.

School example: A student uses JavaScript to create a simple game.

Home example: A family uses a web app that was built with JavaScript.

Nigerian example: Nigerian websites use JavaScript for interactivity.

   JavaScript = The language of the web

Mini summary: JavaScript makes websites interactive.

Lesson 2: What is TypeScript?

Definition: TypeScript is a programming language that adds types to JavaScript.

Why is it important? It helps developers catch errors early and write better code.

Simple explanation: TypeScript is like JavaScript, but with extra safety features.

Real-life example: A developer uses TypeScript to build a large web app.

School example: A student writes TypeScript code for a school project.

Home example: A parent uses a TypeScript app to manage finances.

Nigerian example: Nigerian developers use TypeScript for secure applications.

   TypeScript = JavaScript + Types

Mini summary: TypeScript is JavaScript with types.

Lesson 3: Why Was TypeScript Created?

Definition: TypeScript was created to solve problems with JavaScript, especially when building large applications.

Why is it important? It makes code more reliable and easier to manage.

Simple explanation: JavaScript is flexible, but sometimes too flexible – TypeScript adds structure.

Real-life example: Large companies use TypeScript to prevent bugs.

School example: A student uses TypeScript to keep code organised.

Home example: A family uses a TypeScript app that works reliably.

Nigerian example: Nigerian fintech companies use TypeScript for safety.

   Why TypeScript was created:
   - To catch errors early
   - To make code easier to understand
   - To support large projects

Mini summary: TypeScript was created to make JavaScript safer.

Lesson 4: How Does TypeScript Work?

Definition: TypeScript works by checking types and converting (compiling) to JavaScript.

Why is it important? It ensures that your code is correct before it runs.

Simple explanation: You write TypeScript, and a compiler checks it and turns it into JavaScript.

Real-life example: A developer writes TypeScript code and runs the compiler.

School example: A student writes TypeScript code and sees the output.

Home example: A family uses an app built with TypeScript.

Nigerian example: A Nigerian team uses TypeScript to build reliable apps.

   How TypeScript Works:
   1. You write TypeScript code
   2. The compiler checks it
   3. The compiler converts it to JavaScript
   4. The JavaScript runs

Mini summary: TypeScript compiles to JavaScript.

Lesson 5: What is a Type?

Definition: A type is a label that tells you what kind of value something is – like a number, text, or true/false.

Why is it important? Types help you avoid mistakes – you can't accidentally use a number as text.

Simple explanation: Types are like labels on boxes – they tell you what's inside.

Real-life example: A number type can only hold numbers.

School example: A student uses types to organise data.

Home example: A parent uses types to keep track of expenses.

Nigerian example: A Nigerian developer uses types for data consistency.

   Types:
   - string: text (e.g., "hello")
   - number: numbers (e.g., 123)
   - boolean: true/false

Mini summary: Types tell you what kind of value something is.

Lesson 6: Setting Up TypeScript

Definition: Setting up TypeScript means installing it on your computer so you can write and run TypeScript code.

Why is it important? You need to have TypeScript installed to use it.

Simple explanation: You install TypeScript just like you install a game or app.

Real-life example: A developer installs TypeScript to start a project.

School example: A student installs TypeScript for a school project.

Home example: A parent installs TypeScript to learn programming.

Nigerian example: A Nigerian developer sets up TypeScript for a local project.

   Steps to Set Up TypeScript:
   1. Install Node.js
   2. Open the terminal
   3. Run: npm install -g typescript
   4. Check: tsc --version

Mini summary: Set up TypeScript to start coding.

Lesson 7: Writing Your First TypeScript Code

Definition: Your first TypeScript code is a simple program that prints a message.

Why is it important? It gets you started and shows you how TypeScript works.

Simple explanation: You write code that says "Hello, World!"

Real-life example: A developer writes "Hello, World!" as their first program.

School example: A student writes "Hello, World!" in class.

Home example: A parent writes "Hello, World!" to learn programming.

Nigerian example: A Nigerian developer starts learning with "Hello, World!"

   First TypeScript Program:
   let message: string = "Hello, World!";
   console.log(message);

Mini summary: Your first program prints "Hello, World!"

Lesson 8: Compiling TypeScript

Definition: Compiling means converting TypeScript code to JavaScript.

Why is it important? Browsers only understand JavaScript – you need to compile.

Simple explanation: You run a command that turns TypeScript into JavaScript.

Real-life example: A developer runs "tsc" to compile code.

School example: A student compiles TypeScript code.

Home example: A parent compiles a TypeScript program.

Nigerian example: A Nigerian developer compiles code for a project.

   Compiling:
   tsc filename.ts

Mini summary: Compiling converts TypeScript to JavaScript.

Lesson 9: Running TypeScript Code

Definition: Running means executing your code to see the output.

Why is it important? You need to see if your code works.

Simple explanation: You run your code and see the result.

Real-life example: A developer runs code to test it.

School example: A student runs code to see if it works.

Home example: A parent runs code to learn.

Nigerian example: A Nigerian developer runs code to build apps.

   Running:
   node filename.js

Mini summary: Running shows you the output of your code.

Lesson 10: What is a Compiler?

Definition: A compiler is a program that converts code from one language to another.

Why is it important? It makes your code runnable.

Simple explanation: It translates TypeScript to JavaScript.

Real-life example: The TypeScript compiler is called tsc.

School example: A student uses a compiler for projects.

Home example: A parent uses a compiler to learn.

Nigerian example: A Nigerian developer uses a compiler for apps.

   Compiler = A translator for code

Mini summary: A compiler converts TypeScript to JavaScript.

Lesson 11: Benefits of Using TypeScript

Definition: Benefits are the good things that come from using TypeScript.

Why is it important? It shows why TypeScript is valuable.

Simple explanation: TypeScript helps you catch errors before they happen.

Real-life example: A developer catches a bug before it reaches production.

School example: A student avoids mistakes in code.

Home example: A parent builds reliable apps.

Nigerian example: A Nigerian team builds secure applications.

   Benefits:
   - Catches errors early
   - Improves code quality
   - Makes code easier to understand
   - Supports large projects

Mini summary: TypeScript helps you write better code.

Lesson 12: TypeScript vs JavaScript

Definition: TypeScript and JavaScript are similar, but TypeScript has extra features.

Why is it important? You need to know the difference to choose the right one.

Simple explanation: TypeScript is JavaScript with superpowers.

Real-life example: A developer chooses TypeScript for a large project.

School example: A student learns both languages.

Home example: A parent uses TypeScript for safer code.

Nigerian example: A Nigerian developer chooses TypeScript for reliability.

   JavaScript: Flexible, runs everywhere
   TypeScript: JavaScript + Types, safer

Mini summary: TypeScript is JavaScript with types.

Lesson 13: Who Uses TypeScript?

Definition: Many companies and developers use TypeScript.

Why is it important? It shows that TypeScript is widely adopted.

Real-life example: Microsoft, Google, and Facebook use TypeScript.

School example: A student uses TypeScript for projects.

Home example: A parent uses TypeScript for personal projects.

Nigerian example: Nigerian tech companies use TypeScript.

   Companies using TypeScript:
   - Microsoft
   - Google
   - Facebook
   - Airbnb
   - Slack

Mini summary: Many large companies use TypeScript.

Lesson 14: TypeScript and the Future

Definition: TypeScript is becoming more popular and is likely to be a key skill for developers.

Why is it important? Learning TypeScript can help you get a job.

Simple explanation: TypeScript is a valuable skill for the future.

Real-life example: Many job postings ask for TypeScript skills.

School example: A student learns TypeScript to prepare for a career.

Home example: A parent learns TypeScript for career growth.

Nigerian example: Nigerian developers are learning TypeScript.

   TypeScript is a skill for the future.

Mini summary: TypeScript is a valuable future skill.

Lesson 15: You – The TypeScript Programmer

Definition: You are now a TypeScript programmer – you know the basics.

Why is it important? You have started your journey to becoming a TypeScript expert.

Simple explanation: You have written your first TypeScript program.

Real-life example: You can now build simple TypeScript apps.

School example: You can use TypeScript for school projects.

Home example: You can practice TypeScript at home.

Nigerian example: You can contribute to Nigerian tech projects.

   TypeScript Programmer Checklist:
   - Understands TypeScript basics
   - Can set up TypeScript
   - Can write simple programs
   - Knows how to compile and run

Mini summary: You are on your way to becoming a TypeScript expert!


πŸ“– Key Vocabulary

WordSimple Definition
TypeScriptA programming language with types.
JavaScriptThe language of the web.
TypeA label for values.
CompilerA program that converts code.
StringText in programming.
NumberA numeric value.
BooleanTrue or false.
VariableA container for data.
FunctionA block of code that does a task.
ConsoleA place to see output.

🧩 Important Concepts

  • TypeScript is JavaScript with types.
  • Types help catch errors early.
  • TypeScript compiles to JavaScript.
  • Setting up TypeScript is easy.
  • You are now a TypeScript programmer.

πŸ”’ Step-by-Step Explanations

How to Write and Run TypeScript (in 6 steps)

  1. Step 1: Install Node.js and TypeScript.
  2. Step 2: Create a file with a .ts extension.
  3. Step 3: Write TypeScript code in the file.
  4. Step 4: Open the terminal and compile: tsc filename.ts
  5. Step 5: Run the JavaScript: node filename.js
  6. Step 6: See the output.

🌍 Real-life Examples

  • Web apps: TypeScript is used in large web applications.
  • Mobile apps: TypeScript is used with React Native.
  • Backend services: TypeScript is used with Node.js.
  • Libraries: Many popular libraries are written in TypeScript.
  • Games: TypeScript is used to build browser games.

πŸ‡³πŸ‡¬ Nigerian Examples

  • Fintech: Nigerian banks use TypeScript for secure apps.
  • E-commerce: Nigerian online stores use TypeScript.
  • Startups: Nigerian startups use TypeScript for reliability.
  • Education: Nigerian universities teach TypeScript.
  • Tech hubs: TypeScript is popular in Nigerian tech hubs.

🎈 Fun Examples Children Can Relate To

  • Game character: A TypeScript type for a game character.
  • Recipe: A TypeScript interface for a recipe.
  • School: A TypeScript class for a student.
  • Playground: A TypeScript program for a playground game.
  • Pet: A TypeScript object for a pet.

🏠 Everyday Examples

  • To-do list: A TypeScript app for a to-do list.
  • Calendar: A TypeScript app for a calendar.
  • Shopping: A TypeScript app for shopping lists.
  • Contacts: A TypeScript app for contacts.
  • Notes: A TypeScript app for notes.

πŸ‘©β€πŸ« Teacher Notes

  • This module is an introduction – keep it simple and engaging.
  • Use the warm-up story to spark interest.
  • Encourage students to install TypeScript.
  • Emphasise the importance of types.
  • Make it interactive with live coding.

πŸ‘ͺ Parent Tips

  • Encourage your child to learn programming.
  • Help them set up a coding environment.
  • Discuss how technology is used in Nigeria.
  • Support their learning journey.
  • Celebrate their achievements.

πŸ’‘ Interesting Facts

  • TypeScript was created by Microsoft in 2012.
  • TypeScript is a superset of JavaScript.
  • Many large companies use TypeScript.
  • TypeScript is open source.
  • TypeScript is the second most loved language.

πŸ€” Did You Know?

  • Did you know that TypeScript was created at Microsoft?
  • Did you know that TypeScript is used by Google, Facebook, and Microsoft?
  • Did you know that Nigerian developers are using TypeScript?
  • Did you know that TypeScript helps prevent bugs?

🧠 Remember This

  • TypeScript adds types to JavaScript.
  • Types help catch errors early.
  • TypeScript compiles to JavaScript.
  • You can set up TypeScript easily.
  • You are now a TypeScript programmer.

⚠️ Common Mistakes

  • Mistake 1: Not installing Node.js first.
  • Mistake 2: Forgetting to compile.
  • Mistake 3: Not using types.
  • Mistake 4: Using any type too much.
  • Mistake 5: Not checking errors.

βœ… Best Practices

  • Always install Node.js first.
  • Always compile your code.
  • Always use types.
  • Always avoid using any.
  • Always check for errors.

🎨 ASCII Illustrations

How TypeScript Works – Flowchart

   Write TypeScript
         |
         V
   Compile to JavaScript
         |
         V
   Run JavaScript
         |
         V
   See Output

TypeScript vs JavaScript – Comparison

   +-----------------------+-----------------------+
   |  JavaScript           |  TypeScript           |
   +-----------------------+-----------------------+
   | Dynamic types         | Static types          |
   | Errors at runtime     | Errors at compile     |
   | Less safe             | More safe             |
   | No type checking      | Type checking         |
   | Flexible              | Structured            |
   +-----------------------+-----------------------+

πŸ“Š Comparison Tables

TypeScript Types

TypeWhat It RepresentsExample
stringText"Hello"
numberNumber123
booleanTrue/Falsetrue
arrayList of items[1,2,3]
objectCollection of properties{name:"John"}

TypeScript Features

FeaturePurposeBenefit
TypesDefine dataError prevention
InterfacesShape objectsConsistency
ClassesCreate blueprintsReusability
ModulesOrganise codeMaintainability

πŸ“ Summary After Every Lesson

(Included after each lesson above – review them!)


πŸ“Œ End-of-Module Summary

In this first module, you have learned the basics of TypeScript. You discovered what TypeScript is, why it was created, and how it works. You learned about types and how they help catch errors. You also set up TypeScript on your computer and wrote your first program. You are now on your way to becoming a TypeScript expert. In the next module, you will learn about basic types. Congratulations on completing Module One!


❓ Frequently Asked Questions

  1. What is TypeScript? A programming language with types.
  2. Why use TypeScript? To catch errors early.
  3. Do I need to know JavaScript? Yes – TypeScript builds on it.
  4. Is TypeScript hard? No – it's built on JavaScript.
  5. What is a type? A label for values.
  6. How does TypeScript work? It compiles to JavaScript.
  7. Who created TypeScript? Microsoft.
  8. Is TypeScript free? Yes – it's open source.
  9. Can I use TypeScript in Nigeria? Yes – many Nigerian developers do.
  10. What will I learn in this course? Everything about TypeScript!

πŸ“ Review Questions (15)

  1. What is TypeScript?
  2. Why was TypeScript created?
  3. How does TypeScript work?
  4. What is a type?
  5. What is a compiler?
  6. What is JavaScript?
  7. Why is TypeScript safer than JavaScript?
  8. What are the benefits of TypeScript?
  9. Who uses TypeScript?
  10. How do you set up TypeScript?
  11. How do you compile TypeScript?
  12. How do you run TypeScript code?
  13. What is the difference between TypeScript and JavaScript?
  14. Give a Nigerian example of TypeScript use.
  15. What makes you a TypeScript programmer?

✏️ Fill-in-the-Blank Exercises

  1. TypeScript adds __________ to JavaScript.
  2. __________ is the language of the web.
  3. A __________ is a label for values.
  4. A __________ converts TypeScript to JavaScript.
  5. __________ is a type for text.
  6. __________ is a type for numbers.
  7. __________ is a type for true/false.
  8. TypeScript was created by __________.
  9. TypeScript is used by large __________.
  10. You are now a TypeScript __________.

βœ… True or False Exercises

  1. TypeScript is the same as JavaScript. (False)
  2. TypeScript adds types to JavaScript. (True)
  3. Types help catch errors early. (True)
  4. TypeScript does not need a compiler. (False)
  5. TypeScript is open source. (True)
  6. TypeScript was created by Google. (False)
  7. TypeScript is used in Nigeria. (True)
  8. You do not need to know JavaScript to learn TypeScript. (False)
  9. TypeScript helps with large projects. (True)
  10. You are a TypeScript programmer. (True)

πŸ”˜ Multiple Choice Questions (15 with answers)

  1. What is TypeScript?
    a) A language with types
    b) A game
    c) A video
    Answer: a
  2. Why use TypeScript?
    a) To catch errors
    b) To slow down code
    c) To avoid coding
    Answer: a
  3. What is a type?
    a) A label for values
    b) A game
    c) A video
    Answer: a
  4. What is a compiler?
    a) Converts code
    b) Deletes code
    c) Plays games
    Answer: a
  5. What is JavaScript?
    a) The language of the web
    b) A game
    c) A video
    Answer: a
  6. What is a string?
    a) Text
    b) Number
    c) True/False
    Answer: a
  7. What is a number?
    a) Numeric value
    b) Text
    c) True/False
    Answer: a
  8. What is a boolean?
    a) True/False
    b) Text
    c) Number
    Answer: a
  9. Who created TypeScript?
    a) Microsoft
    b) Google
    c) Facebook
    Answer: a
  10. Is TypeScript open source?
    a) Yes
    b) No
    Answer: a
  11. Can TypeScript be used with React?
    a) Yes
    b) No
    Answer: a
  12. Can TypeScript be used with Node.js?
    a) Yes
    b) No
    Answer: a
  13. Is TypeScript popular in Nigeria?
    a) Yes
    b) No
    Answer: a
  14. What is a benefit of TypeScript?
    a) Catches errors early
    b) Slows down code
    c) Complicates code
    Answer: a
  15. Are you a TypeScript programmer?
    a) Yes
    b) No
    Answer: a

πŸ”— Matching Exercises

Match the term with its definition.

TermDefinition
1. TypeScriptA. Language with types
2. JavaScriptB. Language of the web
3. TypeC. Label for values
4. CompilerD. Converts code
5. StringE. Text

Answers: 1-A, 2-B, 3-C, 4-D, 5-E


πŸ“ Short Answer Questions

  1. What is TypeScript and why is it used?
  2. What is a type?
  3. How does TypeScript work?
  4. What is the difference between TypeScript and JavaScript?
  5. What are the benefits of using TypeScript?

🎭 Scenario-based Exercises

  1. Scenario 1: You are building a web app with a team. You need to catch errors early. Why would you use TypeScript?
  2. Scenario 2: You are defining data for a user profile. What type would you use for the name, age, and email?
  3. Scenario 3: You want to learn a new language. Why would you choose TypeScript over JavaScript?

πŸ‘₯ Group Activity

β€œTypeScript Discussion”

In groups, discuss why TypeScript is better than JavaScript. Share examples of where TypeScript is used. Present your findings.


πŸ§‘β€πŸ’» Individual Activity

β€œMy TypeScript Plan”

Write a plan for learning TypeScript. Include: what you will learn, resources, and projects. Share your plan with the class.


πŸ—£οΈ Classroom Discussion Questions

  1. How can TypeScript help Nigerian developers?
  2. What is the most important feature of TypeScript?
  3. What challenges do developers face when learning TypeScript?
  4. How does TypeScript improve code quality?
  5. What would you like to build with TypeScript?

πŸ› οΈ Mini Project

β€œTypeScript Presentation”

Create a presentation on TypeScript for an audience of beginners. Include: what it is, why it is used, and an example. Present to the class.


πŸ’» Practical Assignment

β€œInstall TypeScript and Write Code”

Install TypeScript on your computer. Write a simple TypeScript program. Share your code and experience.


⚑ Challenge Exercise

β€œTypeScript Project Plan”

Design a project that you will build with TypeScript. Include: what it does, what technologies you will use, and your plan. Present your plan to the class.


πŸ“‹ Quiz Answers

(Answers to fill-in-the-blank, true/false, and multiple choice are provided within those sections.)


🎁 Key Takeaways

  • TypeScript adds types to JavaScript.
  • Types help catch errors early.
  • TypeScript compiles to JavaScript.
  • Setting up TypeScript is easy.
  • You are now a TypeScript programmer.

πŸš€ Preparation for Module Two

In Module Two, you will learn about basic types. To prepare:

  • Review what you learned about types.
  • Think about how you use numbers, text, and true/false in everyday life.
  • Install Node.js and TypeScript if you haven't yet.
  • Bring your questions to the next class.

Get ready to learn about types in TypeScript!


End of Module One Β· Welcome to the world of TypeScript!

πŸ† Get Certified

πŸ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

πŸŽ“ Sign Up to Get Certified
πŸ› οΈ Practice Tools
Hands-on simulators & labs - subscription required.
β†’
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
β†’