What is TypeScript?
Author
TypeScript is a typed superset of JavaScript compiled to JavaScript i.e, javascript with some extra added features. It cannot run on its own and instead compiles to standard-bases javascript.
Key features of typescript
- Statically typed language.
- Helps to detect errors including typos at run time.
- Offer additional features generics, interfaces, and enums.
Installing and compilation using typescript
- The TypeScript compiler is available as an npm package
- After installation one can start creating TypeScript files(*.ts).
- The compiler compiles the .ts files into standard .js
Typescript with LWC
Lightning Web Components has basic support for TypeScript. Type checking is not possible between js files and Html and even deployed typescript code can not be processed by the lwc platform compiler. To overcome this one can use vs code’s language service and use the lesser strict levels of typescript.
The level of typescript according to its strictness goes on increasing as mentioned below
For Javascript files.
- Using //@ts-check at beginning of the js file or using checkjs in checkjs in compilerOptions in jsconfig.json file.
- A type system based only on interference with js code.
- Using incremental typing with JSDoc https://www.typescriptlang.org/docs/handbook/jsdoc-supporte d-types.html
For Javascript files.
- Typescript code
- Typescript with strict enabled.
Using typescript in VS code for LWC
- Specify the types using JSDoc constructs.
- To enable type checking add //ts-check at beginning of the js file.
- VS code will show an error as in the below example
One can also enable type checking for all js files by adding “checkJs”: true in the jsconfig.json file. Also, make sure you set “ESNext” as a target to prevent errors from showing up on ES5+ features like get/set accessors.
{
“compilerOptions”: {
“checkJs”:true,
“target”: “ESNext”
}
}
Benefits of Typescripts
- Compilation − As compared to JavaScript, instead of running code and finding out errors typescript has an error-checking feature provided by TypeScript transpiler which compiles the code and generates errors it also finds some sort of syntax error which helps find errors before the run.
- Strong Static Typing- It is a strongly typed language ie. if no type is declared for a variable it is inferred by TLS based on its value.
- OOP’s – supports concepts like interfaces, inheritance, etc.
Pranshu Goyal, Director of Products at Mirekta, states: “We envision DSM to be used by every small to a medium-sized organization dealing with bad data and want to get rid of duplicates easily with no cost. We have faced issues dealing with duplicates in our organization. That inspired us to make a solution that is not only simple to use but can be used widely to make the organization’s data clean to make them more efficient and productive. We want DSM to be a solution for every organization looking for duplicate management capability better than the Salesforce out-of-the-box solution with no additional cost.”
Recent Posts
-
Salesforce 2025 Game-Changing Trends You Need to Know28 Jan 2025 Blog
-
Agentforce 2.0: Everything You Need to Know About the Latest Update22 Jan 2025 Blog
-
The Ultimate Guide to NetSuite Development: Tools and Techniques10 Jan 2025 Blog
-
How Salesforce Nonprofit Cloud Transforms Fundraising Strategies10 Jan 2025 Blog
-
The Impact of Salesforce Development Partners on Small and Medium Businesses08 Jan 2025 Blog
-
Key Questions to Ask When Hiring a NetSuite Development Partner08 Jan 2025 Blog
-
Salesforce Agentforce Demystified: Your Essential Guide08 Jan 2025 Blog
-
Salesforce and NetSuite Integration: Driving Business Efficiency with Precision06 Jan 2025 Blog
-
Everest Group has positioned Mirketa as an Aspirant in the report24 Dec 2024 Press Release
-
Salesforce Einstein20 Dec 2024 E-Book
-
Order to Cash Cycle with NetSuite20 Dec 2024 E-Book
-
Empower Your Marketing Strategy with Salesforce Marketing Cloud's Automation Studio Activities13 Dec 2024 Blog
-
Salesforce CPQ for Subscription-based Businesses10 Dec 2024 Blog
-
Unleashing the Magic of Einstein Prediction Builder10 Dec 2024 Blog
-
Customized Templates and Branding with Salesforce Experience Cloud10 Dec 2024 Blog
-
Unleashing the Power of Real- Time Reports and Dashboards in NPSP10 Dec 2024 Blog
-
Top 4 Salesforce Automation Tools in 202409 Dec 2024 Blog
-
Salesforce Service Cloud Implementation: The Ultimate Guide09 Dec 2024 Blog
-
Salesforce CRM Implementation Partner Enhancing Automation in Healthcare09 Dec 2024 Blog
-
Shorten Your Sales Cycle in 8 Steps: Salesforce CPQ Implementation Guide09 Dec 2024 Blog