:books: The definitive guide to TypeScript and possibly the best TypeScript book :book:. Free and Open Source 🌹

Overview

TypeScript Deep Dive

I've been looking at the issues that turn up commonly when people start using TypeScript. This is based on the lessons from Stack Overflow / DefinitelyTyped and general engagement with the TypeScript community. You can follow for updates and don't forget to ★ on GitHub 🌹

Reviews

  • Thanks for the wonderful book. Learned a lot from it. (link)
  • Its probably the Best TypeScript book out there. Good Job (link)
  • Love how precise and clear the examples and explanations are! (link)
  • For the low, low price of free, you get pages of pure awesomeness. Chock full of source code examples and clear, concise explanations, TypeScript Deep Dive will help you learn TypeScript development. (link)
  • Just a big thank you! Best TypeScript 2 detailed explanation! (link)
  • This gitbook got my project going pronto. Fluent easy read 5 stars. (link)
  • I recommend the online #typescript book by @basarat you'll love it.(link)
  • I've always found this by @basarat really helpful. (link)
  • We must highlight TypeScript Deep Dive, an open source book.(link)
  • Great online resource for learning. (link)
  • Thank you for putting this book together, and for all your hard work within the TypeScript community. (link)
  • TypeScript Deep Dive is one of the best technical texts I've read in a while. (link)
  • Thanks @basarat for the TypeScript Deep Dive Book. Help me a lot with my first TypeScript project. (link)
  • Thanks to @basarat for this great #typescript learning resource. (link)
  • Guyz excellent book on Typescript(@typescriptlang) by @basarat (link)
  • Leaning on the legendary @basarat's "TypeScript Deep Dive" book heavily at the moment (link)
  • numTimesPointedPeopleToBasaratsTypeScriptBook++; (link)
  • A book not only for typescript, a good one for deeper JavaScript knowledge as well. link
  • In my new job, we're using @typescriptlang, which I am new to. This is insanely helpful huge thanks, @basarat! link
  • Thank you for writing TypeScript Deep Dive. I have learned so much. link
  • Loving @basarat's @typescriptlang online book basarat.gitbooks.io/typescript/# loaded with great recipes! link
  • Microsoft doc is great already, but if want to "dig deeper" into TypeScript I find this book of great value link
  • Thanks, this is a great book 🤓 🤓 link
  • Deep dive to typescript is awesome in so many levels. i find it very insightful. Thanks link
  • @basarat's intro to @typescriptlang is still one of the best going (if not THE best) link
  • This is sweet! So many #typescript goodies! link

Get Started

If you are here to read the book online get started.

Translations

Book is completely free so you can copy paste whatever you want without requiring permission. If you have a translation you want me to link here. Send a PR.

Other Options

You can also download one of the Epub, Mobi, or PDF formats from the actions tab by clicking on the latest build run. You will find the files in the artifacts section.

Special Thanks

All the amazing contributors 🌹

Share

Share URL: https://basarat.gitbook.io/typescript/

Comments
  • Gitook to Ebook Mobi PDF

    Gitook to Ebook Mobi PDF

    When I click the EPUB / MOBI links on the site, legacy GitBook just redirects me back to your homepage. Could you maybe attach the downloadable ebook files as a release on this repo?

    help wanted 
    opened by TodoCleverNameHere 16
  • The donate element is repeating

    The donate element is repeating

    It appears something funky is happening in Chrome 62.

    image

    After clicking around a few pages I start to see a build-up of the donate element. I have replicated on two separate instances of chrome 62 without addons.

    opened by da1rren 10
  • Guide for writing AST transformers

    Guide for writing AST transformers

    Now that https://github.com/Microsoft/TypeScript/issues/5595 is done, I'm assuming there is new API in LS that allows writing TypeScript to TypeScrtipt syntax transformers. Right now I'm trying to figure out how to write an TS to TS transformer function

    opened by mohsen1 9
  • Search function broken?

    Search function broken?

    If I try to search the doc online, using the search in the upper left corner, it fails with stack trace:

    Uncaught TypeError: Cannot read property 'tf' of undefined
        at t.Index.documentVector (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-lunr/lunr.min.js:7:8688)
        at t.Index.<anonymous> (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-lunr/lunr.min.js:7:8449)
        at Array.map (native)
        at t.SortedSet.map (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-lunr/lunr.min.js:7:4292)
        at t.Index.search (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-lunr/lunr.min.js:7:8396)
        at LunrSearchEngine.search (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-lunr/search-lunr.js:34:40)
        at Object.query (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-search/search-engine.js:31:23)
        at launchSearch (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-search/search.js:79:33)
        at handleUpdate (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-search/search.js:121:17)
        at HTMLInputElement.<anonymous> (https://basarat.gitbooks.io/typescript/content/gitbook/gitbook-plugin-search/search.js:142:13)
    t.Index.documentVector @ lunr.min.js:7
    (anonymous) @ lunr.min.js:7
    t.SortedSet.map @ lunr.min.js:7
    t.Index.search @ lunr.min.js:7
    LunrSearchEngine.search @ search-lunr.js:34
    query @ search-engine.js:31
    launchSearch @ search.js:79
    handleUpdate @ search.js:121
    (anonymous) @ search.js:142
    dispatch @ gitbook.js:2
    m.handle @ gitbook.js:2
    
    opened by estaub 8
  • nominalTyping.html

    nominalTyping.html "Using Enums" method is more restrictive than "Using Interfaces" one

    The "Using Enums" method doesn't work for number types, but the "Using Interfaces" works ok for them:

    enum FooIdBrand {}
    type FooId = FooIdBrand & number;
    enum BarIdBrand{}
    type BarId = BarIdBrand & number;
    
    var fooId: FooId;
    var barId: BarId;
    
    fooId = barId; // NO error (wrong)
    barId = fooId; // NO error (wrong)
    

    Add a note explaining this Enum method restriction.

    opened by nahuel 7
  • A few questions

    A few questions

    A really good read. Thank you.

    • Could you add an example for browser using browserify?
    • You suggest using -module system but in the node and browser sections you don't use it. Why?
    • How do we use ESLint etc with typescript?
    • Can we use Typescript as a replacement for Babel and then start to add type info over time
    opened by SteveALee 7
  • What are Microsoft's

    What are Microsoft's "TypeScript StyleGuide and Coding Conventions" based on?

    Microsoft approach:

    // rocket.ts
    export interface Rocket {
      fuel: number
      weight: number
    }
    
    export class Rocket implements Rocket {  // error: Duplicate identifier 'Rocket'
      fuel = 100;
      weight = 3000;
    
      launch(){
        console.log('launched!');
      }
    }
    
    export type Rocket = typeof Rocket; // error: Duplicate identifier 'Rocket' + unable to use type as value
    
    
    // main.ts
    import { Rocket } from './rocket.ts';     // error: Duplicate identifier 'Rocket'
    
    const myRocket = new Rocket(); 
    const myRocket2 : Rocket = {
      fuel : 50,
      weight : 2000
    };  // Error: Type '{ fuel: number; weight: number; }' is missing the following properties from type 'Rocket': color, launch | ts(2739)
    

    Normal approach:

    // rocket.ts
    export interface IRocket {
      fuel: number
      weight: number
    }
    
    export class Rocket implements IRocket {  
      fuel = 100;
      weight = 3000;
    
      launch(){
        console.log('launched!');
      }
    }
    
    export type TRocket = typeof Rocket; 
    
    
    // main.ts
    import { Rocket, IRocket } from './rocket.ts';  
    
    const myRocket : IRocket = new Rocket(); 
    const myRocket2 : IRocket = {
      fuel = 50,
      weight = 2000
    };  // no errors
    

    There is NO explanation why using prefixes, like "I", "T", "N" and others are bad.

    opened by akopchinskiy 5
  • Question: Is there an official style recommendation for

    Question: Is there an official style recommendation for "space before type"?

    I've found different formatting for types:

    let x: number;
    let x:number;
    

    Most of the code I read uses a space after the colon and AFAIK most of the code examples in the book are using this formatting as well. Unfortunately IntelliJ, (Php|Web)Storm code formatting default for TypeScript is using no space after the colon.

    Is there an official recommendation?

    If yes, would you mind adding this to your styleguide-page?

    Thanks a lot. :rose:

    opened by hgoebl 5
  • Confusing statement on project/external-modules.md

    Confusing statement on project/external-modules.md

    As seen here

    Import type only

    The following statement:

    import foo = require('foo');
    

    actually imports two things:

    • The type information from the imported file.
    • Takes are runtime dependency on the foo module.

    You can pick and choose so that only the type information is loaded and no runtime dependency occurs. Before continuing you might want to recap the declaration spaces section of the book.

    What does the second list item meant? Perhaps it should be

    • The runtime dependencies on the foo module

    If it is what was meant with the statement, I'll submit a PR .

    opened by lifenautjoe 5
  • suggestion: Iterators

    suggestion: Iterators

    It would be nice to have a chapter describing iterators (with iterator symbol) specific with TypeScript. It is quite straight forward, we're just need to define proper type as it expressed in https://github.com/Microsoft/TypeScript/blob/master/src/lib/es6.d.ts, but still good to have as a separate chapter.

    opened by andruhon 5
  • TIP : Singleton

    TIP : Singleton

    Ryan's answer : http://stackoverflow.com/questions/30174078/how-to-define-singleton-in-typescript

    However I prefer to have them using a once wrapper utility function which allows singletons to be lazy.

    https://github.com/TypeScriptBuilder/tsb/blob/48da91c68a1977aeaa665ca609b8cf86bc32ec71/src/common/utils.ts#L73-L83

    export function once<T extends Function>(func: T): T {
        let ran = false;
        let memo = undefined;
        return function() {
            if (ran) return memo;
            ran = true;
            memo = func.apply(this, arguments);
            func = null;
            return memo;
        } as any;
    }
    
    opened by basarat 5
  • What is place in module lookup

    What is place in module lookup

    https://basarat.gitbook.io/typescript/project/modules/external-modules#what-is-place

    else if the place is a folder and there is a foo/package.json and a file specified in the types key in the package.json that exists, then hurray! else if the place is a folder and there is a package.json and a file specified in the main key in the package.json that exists, then hurray! Does the second line here (4th in the book) imply foo/package.json?

    opened by Aryan3212 0
Owner
Basarat Ali Syed
That #TypeScript guy. If you like my work please click the follow button 🌹
Basarat Ali Syed
This project is an Awesome Books web page where users can add or remove books from the site. It also displays a list of the books added to the collection. This Awesome books webpage was created using ES6.

Awesome books App using Module Awesome books App using Module This book list was built using modules and other ES6 syntax. It allows users to add/remo

Esther Udondian 6 Jul 25, 2022
Awesome Books is a basic website that allows users to add/remove books from a list (including the title and author). It has threee different sections: 1. books list, 2. add new book, 3. contact.

awesomeBooks-modules Awesome Books is a basic website that allows users to add/remove books from a list (including the title and author). It has three

Juan Diaz 6 Aug 26, 2022
A single-page application that allows users to keep track of their books. Users can add the book details (book title and author) and also, and the books can also be removed. Built with JavaScript, HTML, and CSS

Project Name Awesome book with ES6 Description the project. This is a single page application that allows users to keep track of their books. Users ca

Micheal Oguntayo 4 Oct 13, 2022
Possibly the coolest way to install apps and customize your Mac!

BrewMyMac Possibly the coolest way to install apps and customize your Mac! Introduction This article explains the motivation behind this project. Gett

Alan Tai 38 Dec 6, 2022
An IoT bottle that tracks water consumption. Winner of Best Health Hack, MLH's Best Hardware Hack, and QB3's Best Big Data for the Improvement of Health Care Winner at CruzHacks 2022.

An IoT bottle that tracks water consumption. Winner of Best Health Hack, MLH's Best Hardware Hack, and QB3's Best Big Data for the Improvement of Health Care Winner at CruzHacks 2022.

Nathanael Garza 2 Jan 21, 2022
Awesome books is a simple website that displays a list of books and allows you to add and remove books from that list

Awesome books is a simple website that displays a list of books and allows you to add and remove books from that list. By building this application, you will learn how to manage data using JavaScript. Thanks to that your website will be more interactive. built with modern JavaScript and uses SPA technology.

Aniekan udo 9 Mar 29, 2022
"Awesome books" is a simple website that displays a list of books and allows you to add ang remove books from that list. Also you can store your data in your local storage. Build with JavaScript, HTML and CSS.

Awesome Books Creating an app that adds and delete books from a list. Built With HTML CSS JavaScript Application Page url https://TimmyChan99.github.i

Fatima Ezzahra elmenoun 5 Jan 28, 2022
"Awesome books" is a simple website that displays a list of books and allows you to add and remove books from that list.

Hello! I am a software developer! I can help you build a product, feature or website. Take a look of my works. If you like what you see and have a pro

Roberto A. Baños Alvarez 8 May 9, 2022
"Awesome books" is a simple website that displays a list of books and allows you to add and remove books from that list. By building this application with JavaScript, the website is more interactive!

Awesome-books Description "Awesome books" is a simple website that displays a list of books and allows you to add and remove books from that list. By

Cindy Dorantes 11 Oct 18, 2022
This website is dedicated to be able to store books, add new books and delete books.

awesome-books This is a book shelve website dedicated to store collection of books, add new books and delete books. In this project, you will be using

Okoroji Victor Ebube 11 Jul 4, 2022
Esther Udondian 6 Aug 1, 2022
Awsome-Books is an app that let you create a list of books by adding the book name and the author.

This app create a list of books, naming author and title. The lis of books is created dynamicly using javascrtipt, every time the user add a new book on the Add New Section. All the methods and fuctions are separated in modules and imported to the index.js file.

Tomas Milanesi 9 Jul 21, 2022
Awesome Books. In this project, I built a basic website that allows users to add/remove books from a book list. This project is build with JavaScript.

Event Page Awesome Books. In this project, I built a basic website that allows users to add/remove books from a book list. Built With HTML CSS JavaScr

Miftah Amin 16 Feb 28, 2022
The Bookstore is a website where the user can display a list of books, add a book by providing a title, an author, and selecting from the categories, and remove a selected book.

Bookstore The Book Store is a website where the user can display a list of books, add a book and remove a selected book. Microverse's Bookstore API wa

Virag Kormoczy 9 Jan 1, 2023
The Bookstore is a website that allows the user to :display a list of books , Add a book and remove a selected book.

Book Store The Bookstore is a website that allows the user to : -Display a list of books. -Add a book. -Remove a selected book. Built With ?? Basic CS

Nedjwa Bouraiou 4 Sep 6, 2022
BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book.

Project Name : BookStore CMS BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book. In or

Chris Siku 10 Aug 22, 2022
This is an app that displays a list of books, allow users add a book and remove a selected book.

BookStore This is an app that displays a list of books, allow users add a book and remove a selected book. Built With HTML CSS -React -Redux -JavaScri

ABDUL ALI 5 Jul 22, 2022
Awesome-book is an online library website where a user can store a collection of books. Different book can be added and removed. Built with JavaScript using Dom

Awesome-book Description Awesome-book is an online library website where a user can store a collection of books. Differents book can be added and remo

tarike bouari 8 Sep 9, 2022
Awesome Books project : An online Book Library. Storing book information using local storage and displaying it as a list on HTML page

This is project is my based on building an online Book Library. Storing book information using local storage and displaying it as a list on html page

Richard Chileya 7 Nov 11, 2022