The require Keyword in TypeScript (import = require, TS2591, ESM)

require in TypeScript: Command Prompt output of a CommonJS file requiring an ES module in Node.js 22

The require keyword in TypeScript is really Node.js’s CommonJS require() function: it loads a module synchronously and returns its exports. In a .ts file it needs Node’s types, and it returns any, so prefer import x = require() or plain import: Every example here ran on TypeScript 7.0.2 and Node.js v22.22.2, compiled in strict mode. … Read more >>

How to Get String Between 2 Characters in TypeScript

Get string between 2 characters in TypeScript: Command Prompt output of matchAll pulling every value between brackets

You can get string between 2 characters in TypeScript with indexOf() and slice(): find the start character, search for the end character from just after it, and slice the text in between. Here’s the core of it: Nothing below is typed from memory: I saved each example as a .ts file, compiled it in strict … Read more >>

How to Split a String by Dot in TypeScript (With Examples)

Split string by dot in TypeScript: Command Prompt output of splitting file names into name and extension

To split a string by dot in TypeScript, call split(“.”). It returns a string[] of the pieces between each period. Pass the plain string “.”, not /./, because an unescaped regex dot matches every character: I ran all of this code through TypeScript 7.0.2 and Node.js v22.22.2 with strict mode on, and the outputs below … Read more >>

Types of Errors in Python (With Real Examples)

Types of errors in Python: Command Prompt output of common built-in exceptions and their messages

There are three main types of errors in Python: syntax errors, which stop the code from running at all; runtime errors (exceptions), which crash it partway through; and logical errors, which run fine but give the wrong answer. All the error messages below are copied from Python 3.12.5 running in a Windows Command Prompt, so … Read more >>

How to Install Python on Ubuntu Linux (2026 Guide)

Install Python on Linux Ubuntu: packages.ubuntu.com listing the python3 version for each Ubuntu release

Most Ubuntu Linux systems already include Python 3, so installing Python on Ubuntu often just means adding pip and venv. Open a terminal and run: Which version you get depends on your Ubuntu release. I checked packages.ubuntu.com in October 2026, and the screenshots are real captures of that page and the deadsnakes PPA. This guide … Read more >>

How to Get the Decimal Part of a Number in TypeScript

TypeScript decimal part of a number: Command Prompt output comparing % 1, trunc and floor for negative numbers

You can get the decimal part of a number in TypeScript with the remainder operator: x % 1 returns everything after the decimal point as a number. For 24.75 that’s 0.75, and an integer gives 0: My test machine runs TypeScript 7.0.2 and Node.js v22.22.2; I built each file with strict checks on and copied … Read more >>

How to Find a Key by Value in a TypeScript Dictionary

Find key by value in a TypeScript dictionary: Command Prompt output of Object.keys with find

To find a key by value in a TypeScript dictionary, get the keys with Object.keys(), type them as keyof, and call find() to return the first key whose value matches. If nothing matches, you get undefined: Nothing below is pseudo-code: each lookup went through tsc –strict and then Node, using TypeScript 7.0.2 and Node.js v22.22.2, … Read more >>

How to Split a String by Regex in TypeScript

Split string by regex in TypeScript: Command Prompt output of camelCase and sentence splits with lookahead and lookbehind

You split a string by regex in TypeScript by passing a RegExp to split() instead of a string. Every match becomes a cut point, and you get back a string[]: Each snippet here was compiled in strict mode with TypeScript 7.0.2 and Node.js v22.22.2. I pasted the console output straight from those runs. How split() … Read more >>

ReferenceError: fetch is not defined in TypeScript (Fixed)

ReferenceError fetch is not defined in TypeScript: Command Prompt output from Node.js with and without global fetch

ReferenceError: fetch is not defined in TypeScript means your compiled JavaScript is running somewhere that has no global fetch, usually Node.js older than 18 or a Jest jsdom test. Upgrade Node, or load node-fetch first: Every example below ran on TypeScript 7.0.2 and Node.js v22.22.2 with strict mode, and I copied the output straight from … Read more >>