NEW
Font size
WorksheetsIntroduction to TypeScript
Total questions: 25
Worksheet time: 13mins
Who developed TypeScript?
Microsoft
Oracle
TypeScript is a superset of:
Python
JavaScript
Java
PHP
File extension of TypeScript files?
.js
.jsx
.ts
.json
TypeScript code is:
Directly executed in browser
Converted into Java bytecode
Compiled to JavaScript
Executed only by Node.js
One advantage of TypeScript is:
No IntelliSense support
Strong typing to prevent wrong values
Runs faster than JavaScript
No compilation needed
Which feature is not in TypeScript?
Static typing
Interfaces
IntelliSense support
Direct execution without compilation
Why testers use TypeScript?
It replaces all test frameworks
Detects errors before running tests
It is faster than JavaScript
It doesn’t need Node.js
TypeScript works with:
Only Jest
Only Jest
Playwright, Cypress, Jest, WebDriverIO, etc.
Only Mocha
First step before using TypeScript?
Install Python
Install Node.js
Install Java
Install Git
Command to create new project folder and initialize?
mkdir ts && cd ts && npm start
mkdir ts-tests && cd ts-tests && npm init -y
mkdir ts && npm install -g tsc
npm new ts
Command to install TypeScript & helpers locally?
npm install typescript
yarn add ts-node
npm install --save-dev typescript ts-node @types/node
npm install -g typescript
Command to generate tsconfig.json?
npm create tsconfig
yarn init tsc
npx tsc --init
ts-node setup
Command to run a .ts file directly?
npm run ts
node test.ts
npx ts-node test.ts
ts test.ts
Why use ts-node?
To initialize config
To run TypeScript files without manual compilation
To debug JavaScript
To install Node.js
@types/node package is used for:
Debugging
Type definitions for Node.js
Running browser scripts
Database connection
Typing in JavaScript is:
Strong
Static
Dynamic
Hybrid
Typing in TypeScript is:
Weak
Static (strict)
Dynamic
None
Error detection in JavaScript happens:
Compile-time
Runtime only
Never
During installation
Error detection in TypeScript happens:
Never
Runtime only
Compile-time
At debugging
IntelliSense support in JavaScript is:
Limited
Full
None
Same as TypeScript
IntelliSense support in TypeScript is:
None
Limited
Full support
Only in browsers
Managing large projects in JavaScript is:
Easy
Harder
Safer
Strict
Managing large projects in TypeScript is:
Harder
Easier & safer
Riskier
Impossible
Which statement is correct?
JavaScript is compiled to TypeScript
TypeScript runs without compilation
TypeScript is compiled into JavaScript
JavaScript and TypeScript are unrelated
Why TypeScript is better for testing?
It runs faster than JS
It catches errors early, has IntelliSense & strong typing
It doesn’t need test frameworks
It skips compilation
