The Fibonacci sequence in TypeScript

The Fibonacci sequence in TypeScript

The Fibonacci sequence in TypeScript. Writing the Fibonacci sequence in Javascript is the “hello world” of recursion.

Writing the Fibonacci sequence in Javascript is the “hello world” of recursion. You are likely to come across it first in your intro level computer science class. It looks something like:

function fibonacci(num) {
  if (num <= 1) {
    return 1;
  }

  return fibonacci(num - 1) + fibonacci(num - 2);
}

What I want to show in this article, is how to write the Fibonacci sequence in TypeScript… in the type system.

Building blocks

Before writing our algorithm, let’s start off by exploring some features recently and not-so-recently added to the TypeScript type system. We will treat these as our building blocks to our eventual algorithm.

Lookup Types

Introduced in TS 2.1

typescript programming javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

What is TypeScript? Why TypeScript? and Why Not TypeScript?

TypeScript extends JavaScript by adding Types. There are many great reasons to switch to TypeScript. Especially if your team uses JavaScript. There are some reasons to not use TypeScript as there are with any language or framework.

TypeScript Tutorial For JavaScript Developers - TypeScript Basics

TypeScript Tutorial For JavaScript Developers - TypeScript Basics. I will show you guys 4 example of JavaScript code, and how to convert it to TypeScript. This is a typescript beginners tutorial.

TypeScript: A Superset of JavaScript

Multi-paradigm, Functional, Generic, Imperative, Object-Oriented. In this article, I have shared the essential information about TypeScript programming language. This article contains a basic overview, brief history, features and applications of TypeScript. TypeScript is getting more popular in Full-stack development. In terms of popularity, in the last two years TypeScript pulled ahead of Ruby, Shell, and C.

How an Anti-TypeScript “JavaScript Developer” Like Me Became a TypeScript Fan

In this article, I will discuss my journey from being an anti-TypeScript developer to a developer who now couldn’t think of going back to the plain JavaScript world. Let's see How an Anti-TypeScript “JavaScript Developer” Like Me Became a TypeScript Fan.

Functional Programming: Using the Functor Type Class in TypeScript

Functional Programming: Exploring the Functor type class and its use cases