Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Intro to TypeScript (Optional) | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 30 of 55

·javascript

Intro to TypeScript (Optional)

12 mins

Course progress55%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `TypeScript` code is **erased** to plain JavaScript at compile time.
  • Enable **strict mode** (`strict:true`) for best safety.
  • You can gradually add type annotations; only annotated parts are checked.

TypeScript adds static typing on top of JavaScript.

npm install -D typescript
npx tsc --init

tsconfig.json

{
  "target": "es2020",
  "module": "esnext",
  "strict": true,
  "sourceMap": true
}

Simple TS file:

function greet(name: string): string {
  return `Hi, ${name}`;
}
console.log(greet('World'));

Compile with npx tsc.

Benefits

  • Early detection of type errors.
  • Rich IDE autocomplete.
  • Gradual adoption – rename .js to .ts one file at a time.
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonDebugging – Chrome DevTools & Source MapsContinue to lesson 31Security – XSS, CSP & Input SanitisationBack to JavaScript Course curriculum