Code Monkey home page Code Monkey logo

essential-typescript's Introduction

Apress Source Code

This repository accompanies Essential TypeScript by Adam Freeman (Apress, 2019).

Cover image

Download the files as a zip using the green button, or clone the repository to your machine using Git.

Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

Contributions

See the file Contributing.md for more information on how you can contribute to this repository.

essential-typescript's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

essential-typescript's Issues

p52 Defect in example code

function sumPrices(...numbers){
return numbers.reduce(function(total,value){
return total + (Number.isNaN(Number(val)) ? 0 : Number(val));
}, 0);
}

The book say "To ensure the function produce a useful sum of its parameter values, however they are received......

sumPrices(100,200,true)
return 301 because Number(true) is 1
and there are other edge cases (as Infinity for example)

p100 bug

export function applyDiscount(product, discount = 5) {
    product.price = product.price - 5; // <- should be ** product.price - discount **
}

Error on Page 44

The first six types in the table are the JavaScript primitive data types. The primitive types are always available, and every value in a JavaScript application either is a primitive type itself or is composed from primitive types. The sixth type is object and is used to represent objects.

Should be the seventh type

Spread Operator of add function in Chapter 13

I found maybe there is a typo of add function in chapter 13.

add(...newItems: T[]): void {
        this.items.push(...newItems);
}

should be ???

add(newItems: T[]): void {
        this.items.push(...newItems);
}

With the spread syntax in the argument, It will be

col.add([{ name: 'prod1', price: 10 }, {name: 'prod2', price: 20}])
col.add([{ name: 'prod3', price: 30 }, {name: 'prod4', price: 40}])
// the result of items
[
    [{
        { name: 'prod1', price: 10 }, 
        {name: 'prod2', price: 20}
    }],
    [{
        { name: 'prod3', price: 30 }, 
        {name: 'prod4', price: 40}
    }]
]

Is it designated?

p53 Initial value parameter to `reduce` function silently dropped

function sumPrices (...numbers {
  return numbers.reduce(function(total, val) {
    return total + (Number.isNaN(Number(val))? 0 : Number(val))
  }**, 0**)

function sumPrices (...numbers {
  return numbers.reduce((total, val) => 
    total + (Number.isNaN(Number(val))? 0 : Number(val)) /* **, 0** */)

Typo on page 114

In the Tip: "... provided by the ts-watch package."
should be "...provided by the tsc-watch package."

image

Typo on Page 367

Last paragraph on page 367, second line.
"open a new web browser and navigate to http://locahost:4500,"

locahost --> localhost (missing "l")

image

p28 - Defect in example code

Steps to reproduce:

  • Choose to "Hide complete items"
  • Choose "Complete items"
  • Hit return
  • All previously completed items are now marked as incomplete

One possible solution:

function promptComplete() : void {

  ...

        collection.getTodoItems(true).forEach(item =>
            (!showCompleted && item.complete) ||
                collection.markComplete(item.id, completedTasks.find(id => id === item.id) != undefined))

  ...

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.