Showing posts with label typescript. Show all posts
Showing posts with label typescript. Show all posts

Friday, 24 April 2026

Why does TypeScript feel a bit C-Sharpy?

TypeScript was created by Anders Hejlsberg, a Danish software engineer, in 2012. He formerly created C# around the year 2000. He is also known for Turbo Pascal and Delphi, both extraordinary products in their time. Deservedly he is a Microsoft Technical Fellow (a list of whom appear here).

Types in TypeScript

The basic types are called primitives: 
  • boolean
  • number (which represents integers and floating points)
  • string  
There is also:
  •  BigInt (ES2020+) to represent whole numbers larger than 2^53 -1, and
  •  symbol to create unique identifiers
Starting with ES2015, symbol is a primitive type, whose values are created by calling the Symbol constructor.

Examples:

let sym1 = Symbol();
let sym2 = Symbol("keyname");

Symbols are immutable and unique, which can result in what may be initially feel like strange behaviour, but on reflection makes sense.

let sym2 = Symbol("key");
let sym3 = Symbol("key");

sym2 === sym3; // triple equality - false, Symbols are unique.

Installing a Transpiler

Do install a transpiler in WSL as follows.

sudo npm install -g typescript

The -g option to npm install is short for --global and means install the said package globally (global npm directory) as opposed to the local node_modules folder of a project.

Binaries are then also exposed on your PATH, so you can run tsc conveniently.

Note that you need an up-to-date installation of Node to run TypeScript. If not, some of the modern operators (e.g. null coalescing operator) will not work when running tsc.

Dawn of the Transpiler

The term "transpiler" (referring to a source-to-source translation tool, or "translating compiler") gained popularity around 2013 with the proliferation of translators from TypeScript and other abstractions (CoffeeScript, Dart) into JavaScript.  

JavaScript at the time was becoming a "universal runtime".

Babel is a popular transpiler. tsc is the official transpiler. It can be installed via npm.

Saturday, 4 April 2026

TypeScript in CodePen

Can you do TypeScript in CodePen?  

The question is valid as CodePen reveals three containers, one for HTML, one for CSS and one for JavaScript, in its default interface.

To enable TypeScript input, go to Settings, select JavaScript preprocessor and choose TypeScript. Other available preprocessors are LiveScript, CoffeeScript (billed as a "simple and elegant way" to write JavaScript) and Babel.

Note that CodePen will run TypeScript without type-checking errors blocking execution.

Thursday, 2 April 2026

Inside the Claude Code CLI

On 31 March 2026, Anthropic's CLI tool Claude Code that lets you interact with Claude for software engineering tasks from the command line - edit files, search codebases, manage git workflows and more - had its src directory leaked revealing TypeScript code with UI written in React and Ink (React for interactive command-line applications). It uses the Bun runtime - a fast JavaScript, TypeScript and JSX toolkit.

Tuesday, 17 March 2026

TypeScript for Java and C# Programmers

There is a good tutorial here and also a basic (W3schools) one here.

An important point to note is that while TypeScript adds static typing to JavaScript, the underlying runtime is the same as JavaScript.

Recall that with static typing, the type of every variable and expression is checked before the program runs.  This enables errors to be caught at compile-time rather than run-time (in dynamic typing, by contrast, types are enforced only when code executes).

TypeScript is not a "mandatory" OOP language, in the same way as Java or C# (wherein the class is the basic unit of code organization - all data and behaviour is contained in a class). In JavaScript, and by extension TypeScript, this constraint is not present.  Functions can live anywhere. Avoiding OOP hierarchies where possible tends to be the preferred programming model.

In the spirit of not mandating classes for general programming, static classes are unnecessary in JavaScript. Singletons are also generally not used.

Friday, 12 September 2025

Microsoft Semantic Kernel

Microsoft Semantic Kernel is a "lighweight, open-source development kit" to build AI agents and integrate models into C#,  Python and Java code.

When you load up SK into a fresh Visual Studio Code (no extensions) it will prompt to install recommended extensions. These will include:

  • ESLint - integrates ESLint JavaScript into VS Code (for static analysis)
  • Prettier - integrates Prettier, the opinionated code formatter (for JavaScript, TypeScript and other webby stuff)
  • Azure Functions - to quickly manage serverless apps directly from VS Code
  • vscode-pdf - to display pdf files in VSCode (required to open PDF code maps for .NET and Python)

Tuesday, 22 March 2022

Visual Studio Code for JavaScript Development

Visual Studio Code is a great way to keep up with your JavaScript development. Support for JavaScript, TypeScript and Node.js are built-in (with IntelliSense activated for JavaScript and TypeScript). In addition to Windows VS Code is available for macOS and Linux.

There are also a bunch of extensions for other languages. Python (Pylance) is available, and Jupyter notebooks.

The VS Code ESLint extension is very interesting too. This enables the ESLint static analyzer in VS Code.

In terms of source code management, Git support is built-in, with other SCM platforms accessible via extensions i.e. there are specific extensions for SVN, Mercurial and Perforce.