EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials TypeScript Tutorial TypeScript npm
 

TypeScript npm

Updated April 10, 2023

TypeScript npm

 

 

Introduction to TypeScript npm

The following article provides an outline for TypeScript npm. TypeScript is a language used for application scale JavaScript. Microsoft develops and maintains TypeScript. TypeScript adds more features but also follows JavaScript on the basis of its syntax. Basically, TypeScript is a superset of JavaScript. Optional types are added to JavaScript using TypeScript which supports various tools for creating large-scale JavaScript applications irrespective of the browser, host or operating system. Basically, TypeScript is a language that compiles codes to readable codes of JavaScript.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax to install tsc or using npm in TypeScript:

npm install -g typescript

Working of npm in TypeScript

For installing TypeScript, there are two ways:

  • js package manager also called as npm is used for installing TypeScript.
  • TypeScript plug-in can also be used in the Integrated Development Environment.

TypeScript is a language which starts using JavaScript and also ends with JavaScript. The basic building blocks of JavaScript is adopted by TypeScript. So, a person only needs to understand JavaScript for using TypeScript. After writing the complete TypeScript code and executing it, the TypeScript code gets converted into JavaScript code which would be equivalent to the original TypeScript code and the resultant is used for final execution.

Any executable .js file can be converted or renamed into .ts file to get compiled along with the other TypeScript files. String values in TypeScript are used with keyword “string” and numeric values are used with keyword “number” in TypeScript. These keywords are used in several examples below.

Examples of TypeScript npm

Given below are the examples mentioned:

If you have saved the file of the below codes as Rahul.ts, so to compile TypeScript code you can run the following command on the command line: tsc Rahul.ts.

By doing this a JavaScript file will be generated as Rahul.js and to run this javascript file use the following command on the command line: Node Rahul.js.

Example #1

Code:

class TrainingProvider {
Typescript():void {
console.log(
"**EDUCBA**"
)
}
}
var obj = new TrainingProvider();
obj.Typescript();

Output:

TypeScript npm 1

Example #2

Code:

var year: number = 2021;
var us: string = "EDUCBA";
var course1: string = "TypeScript";
var price1: number = 232323;
var course2: string = "React Native";
var price2: number = 212121;
var course3: string = "React";
var price3: number = 191919;
var course4: string = "Data Science";
var price4: number = 252525;
var course5: string = "Finance";
var price5: number = 171717;
var course6: string = "Swift";
var price6: number = 151515;
var Contact_us: number = 9876543210;
console.log(year + " journey " + us + course1 + price1 + course2 + price2 + course3 + price3 + course4 + price4 + course5 + price5 + course6 + price6 + "You can" + "Call us on" + Contact_us)

Output:

TypeScript npm 2

Example #3

Code:

function Textual(
M: string
, N: string) {
return M + N;
}
var Texting: string = Textual(
"Great"
, "Training")
console.log(' We are : ' + Texting + "providers :P");
function Numeric(
S: number
, T: number) {
return S + T;
}
var Numbernew: number = Numeric(
14092019
, 14092021)
console.log(' Added numbers concluded to : ' + Numbernew );

Output:

Added numbers concluded

Example #4

Code:

function Numeric(
M: number
, N: number) {
return M * N;
}
var Numbernew1: number = Numeric(
14092019
, 14092021)
console.log(' Multiplied numbers concluded to : ' + Numbernew1 );
function Numeric1(
S: number
, T: number) {
return S + T;
}
var Numbernew: number = Numeric1(
14092019
, 14092021)
console.log(' Added numbers concluded to : ' + Numbernew );
function Numeric2(
Q: number
, R: number) {
return Q - R;
}
var Numbernew2: number = Numeric2(
14092019
, 14092021)
console.log(' Subtracted numbers concluded to : ' + Numbernew2 );

Output:

Multiplied numbers

Conclusion

On the basis of the above article, we can understand the concept of TypeScript and how it is used to simplify the complexity of JavaScript for large applications. This article explains TypeScript using different examples and the working of TypeScript with node.js package manager commonly known as npm. These examples would help the beginners to understand and work on TypeScript.

Recommended Articles

This is a guide to TypeScript npm. Here we discuss the introduction, working of npm in TypeScript and examples respectively. You may also have a look at the following articles to learn more –

  1. TypeScript Functions
  2. TypeScript Operators
  3. TypeScript Versions
  4. What is TypeScript?

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW