Errata

Learning TypeScript

Errata for Learning TypeScript

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Page https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch09.html#idm45584679661
https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch09.html#idm45584679661808

function getRating(ratings: Ratings, key: 'audience' | 'critic'): number {
return ratings[key]; // Ok
}

const ratings: Ratings = { audience: 66, critic: 84 };

getCountLiteral(ratings, 'audience'); // Ok

getCountLiteral(ratings, 'not valid');

There is no getCountLiteral its supposed to be
getRating(ratings, 'audience'); // Ok
getRating(ratings, 'not valid');

Note from the Author or Editor:
Thanks for the catch!

Anonymous  Jun 10, 2022  Jul 01, 2022
Page Arrays : Union-Type Arrays
First code example under the Union-Type Arrays sections

Here's the excerpt from the book
// Type is either a number or an array of strings
let stringOrArrayOfNumbers: string | number[];

where the comment above should actually be
// Type is either a string or an array of numbers

Note from the Author or Editor:
You're right, thanks for the spot!

Wale  Jul 13, 2022  Aug 26, 2022
Page Ch 02. Type Shapes
https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch02.html#:-:text=TypeScript%20knows%20the,key%20and%20complains%3A

The text talks about "birthNames" object, but the object declared in the snippet below that is "cher", and there is no reference to "birthNames" anywhere in that mini-section. I guess we need to replace "birthNames" with "cher" or the other way around (rename "cher" in the code snippet to "birthNames").

Note from the Author or Editor:
Correct, great find! It should be `cher`, not `birthNames`.

Anonymous  Jul 23, 2022  Aug 26, 2022
Page Ch05 Functions | Function types
https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch05.html#:-:text=logSongs%3A%20(strong%3A%20string)

"logSongs: (strong: string)" should be
logSong(song: string)

Note from the Author or Editor:
Great spot, thanks!

Anonymous  Jul 27, 2022  Aug 26, 2022
Page Ch05 Functions | Function types
https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch05.html#:-:text=song%E2%80%99s%20number%20type%20is%20not%20assignable%20to%20index%E2%80%99s%20string%20type

"song’s number type is not assignable to index’s string type" should be
"song’s string type is not assignable to index’s number type"

Note from the Author or Editor:
Indeed. Thanks!

Anonymous  Jul 27, 2022  Aug 26, 2022
Page Interface Extensions
https://learning.oreilly.com/library/view/learning-typescript/9781098110321/ch07.html#:-:text=extraProperty

Error states
Error: Type '{ genre: string; name: string; strategy: string; }'
is not assignable to type 'Novella'.
Object literal may only specify known properties,
and 'genre' does not exist in type 'Novella'.
when it should be
Error:Type '{ pages: number; strategy: string; style: string; }'
is not assignable to type 'Novella'.
Object literal may only specify known properties,
and 'strategy' does not exist in type 'Novella'.

Note from the Author or Editor:
Nice spot, thanks!

Ryan C  Aug 14, 2022  Aug 26, 2022
Page p136
In the "Assertions versus declarations" code example

In the type error for the `const declared: Entertainer` expression, it mentions " Error: Property 'acts' is missing in type '{ one: number; }' but required in type 'Entertainer'.". That object should be `{ name: string; }` instead.

Note from the Author or Editor:
Thanks for the spot!

David Brownman  Oct 17, 2022  May 05, 2023
Page Page 89
Code example

In the code sample, it says that the following should throw an error becasue "Property 'author' is missing in type..."

interface Book {
author?: string;
pages: number;
}

const missing: Book = {
pages: 80
}

But, it's actually okay as the 'author' property is optional.

The following will indeed be wrong because it's missing the 'pages' property, which is required:

const missing: Book = {
author: "Rita Dove"
}

Note from the Author or Editor:
Thanks for the spot!

Pablo Alonso  Sep 22, 2022  May 05, 2023
Page Chapter 7, Section: Call Signatures
Last code snippet and paragraph

In the code snippet

```
interface FunctionWithCount {
count: number;
(): void;
}

let hasCallCount: FunctionWithCount;

function keepsTrackOfCalls() {
keepsTrackOfCalls.count +=1;
console.log(`I've been called ${keepsTrackOfCalls.count} times!`)
}

keepsTrackOfCalls.count = 0

hasCallCount = keepsTrackOfCalls

function doesNotHaveCount() {
console.log('No Idea!')
}

hasCallCount = doesNotHaveCount
```

Error is listed as
```
"Property 'count' is missing in type '() => void' but required in type 'FunctionWithCalls'."
```

Should be
```
"Property 'count' is missing in type '() => void' but required in type 'FunctionWithCount'."
```

Note from the Author or Editor:
Nice spot, thanks!

Sara Regan  May 05, 2023  Apr 19, 2024
Page Chapter 8. Classes, Section: Function Properties
last paragraph/code example

Text says
"`takesParameters` property of type `(input: string) => number`

Code example has `takesParameter = (input: boolean) => input ? "Yes" : "No"`

Note from the Author or Editor:
Great spot!

Sara   May 12, 2023  Apr 19, 2024
Page Function Properties Section of Chapter 8 on pg.105
Last line of code

new WithMethod().myProperty === new WithMethod().myProperty; // false should use WithProperty() not WithMethod()

Note from the Author or Editor:
Aha, nice spot. Thanks!

Jeff  Aug 12, 2023  Apr 19, 2024
Page Overridden Methods section of Chapter 8 on pg. 117
1st sentence

Remove "method" after "subclass" in the excerpt below:

", as long as the method on the subclass method is assignable to the method on the base class."

Note from the Author or Editor:
Nice spot, thanks!

Jeff  Aug 13, 2023  Apr 19, 2024
Page page 5
Code Listing

'@param {Painting} painter' should be '@param {Painter} painter'

Note from the Author or Editor:
Indeed, nice spot. Thank you!

Valentin Jochinger  Dec 23, 2023  Apr 19, 2024
4
Optional Properties

In the Optional properties section [author?: string;] is optional, there is no error for [missing], in the graphic it shows the false error "// Error: Property 'author' is missing in type" for [missing]
type Book = {
author?: string;
pages: number;
};

const missing: Book = {
pages: 80
};

Mark Oliver  May 28, 2022  Jun 03, 2022
Page 6
The praise quote for Lenz

The name is "Lenz Weber-Tronic" (with a 'c'), not "...Tronik" (with a 'k')

Note from the Author or Editor:
This was reported by Lenz. Sorry, and thank you for the note! Subsequent editions will have the correction.

Josh Goldberg  Jun 07, 2022  Jul 01, 2022
Page 8. Classes
Overridden Constructors

constructor(grade: number) {
this.message = grade >= 65 ? "Maybe next time..." : "You pass!";
}

The '>=' should be '<=' to logically make sense.

Note from the Author or Editor:
Thanks for the spot!

Megan Ku  Oct 16, 2022  May 05, 2023
Page 30
Last paragraph

"When a value is known to be a union type, TypeScript will only allow you to access
member properties that exist on all possible types in the union. It will give you a
type-checking error if you try to access a type that doesn’t exist on all possible types."

Second sentences should probably read:

"It will give you a type-checking error if you try to access a member property that doesn’t exist on all possible types."

Note from the Author or Editor:
Agreed, this is more accurate & clear. Thanks!

Jens Olaf Koch  Dec 29, 2022  May 05, 2023
Page 31
2nd paragraph

Issue with first sentence.

I believe it needs to change from "Restricting access to properties that don't exist on all union types is a safety measure" needs to be changed to "Restricting access to properties that exist on all union types is a safety measure".

Remove the word "don't" from this sentence to make it technically accurate.

Note from the Author or Editor:
Heh, interesting - I'd meant "restricting" as in "blocking". But you're right, the way it's written now is misleading. I'll switch it to "Blocking access to properties that don't exist on all union types ..." to be more clear.

Thanks for the spot!

Emrah Abdurahman  Oct 23, 2022  May 05, 2023
Page 33
Last paragraph

Change "I'd like go the opposite direction" to "I'd like to go the opposite direction".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Oct 23, 2022  May 05, 2023
Page 36
4. paragraph

"If you’ve previously worked in a typed language such as C++ or Java that suffers
from the billion-dollar mistake, it may be surprising to you that some languages don’t
allow such a thing. If you’ve never worked in a language with the strict null checking
before, it may be surprising that some languages allowed the billion-dollar mistake in
the first place!"

I believe the second sentence is unclear. I think it should read:

"If you’ve previously worked in a typed language such as C++ or Java that suffers
from the billion-dollar mistake, it may be surprising to you that some languages don’t
allow such a thing. If you’ve never worked in a language ___without___ strict null checking before, it may be surprising that some languages allowed the billion-dollar mistake in the first place!"

Note from the Author or Editor:
Agreed, thanks!

Jens Olaf Koch  Dec 30, 2022  May 05, 2023
Page 39
2nd paragraph

Change "Each of these variables can be one of four possible types" to "Each of these variables can be one of five possible types".

I believe the unions are made of five separate types:
* boolean
* number
* string
* null
* undefined

Even though null and undefined can be viewed as similar types I believe they are separate types according to the list at the bottom of page 17.

Note from the Author or Editor:
Thanks for the spot - this is a counting typo!

Emrah Abdurahman  Oct 24, 2022  May 05, 2023
Page 44
End of the code snippet

`'{ name: string; start: number; }'` should be `'{ born: number; name: string; }`

Josh Goldberg  Jun 05, 2022  Jul 01, 2022
Page 45
1st code example

Change "// Error: Type 'string' is not assignable to 'Poet'" to "// Error: Type 'string' is not assignable to type 'Poet'" in order to include the word "type" and be technically accurate.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Oct 25, 2022  May 05, 2023
Page 46
2nd paragraph

Change "Structural typing not the same as duck typing,..." to "Structural typing is not the same as duck typing,..."

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Oct 25, 2022  May 05, 2023
Page 47
1st sentence of 1st paragraph for section titled "Excess Property Checking"

Change the first word from "Typescript" to "TypeScript" with an uppercase S.

Note from the Author or Editor:
Thanks for the spot! Corrected in a few places.

Emrah Abdurahman  Oct 25, 2022  May 05, 2023
Page 52
2nd Paragraph In "Explicit Object-Type Unions"

The sentence:

"This version of the previous poem variable is explicitly typed to be a union type that always has the always property along with either pages or rhymes"

Should be:

"This version of the previous poem variable is explicitly typed to be a union type that always has the name property along with either pages or rhymes"

Note from the Author or Editor:
Indeed, nice find - thanks!

Sean Lynch  Jul 03, 2022  Aug 26, 2022
Page 52
Very top of page in code - TypeScript comment

The text:

poem.rhymes; // booleans | undefined

Should be:

poem.rhymes; // boolean | undefined

Note from the Author or Editor:
Correct, thanks!

Sean Lynch  Jul 03, 2022  Aug 26, 2022
Page 53
Error message for second code example

The error message shown in VS Code is:
"Property 'pages' does not exist on type 'Poem'."

Change "Property 'pages' does not exist on type 'PoemWithPages | PoemWithRhymes'." to "Property 'pages' does not exist on type 'Poem'."

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Oct 29, 2022  May 05, 2023
Page 71
1st code example

Change "console.log(`${songs}`);" to "console.log(`${song}`);" so it matches the non-plural form of the parameter name.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 03, 2022  May 05, 2023
Page 73
second last paragraph

"Thus, the return type and each parameter in a function's overload signatures must be assignable to the parameter at the same index in its implementation signature."

How can a return type be assignable to the parameter in the implementation signature?

Shouldn't it better read without referal to the return type:

"Thus, all parameters in the overload signatures of a function must be assignable to the corresponding parameters of its implementation signature located at the same index position."

Would that be correct?

Note from the Author or Editor:
Agreed, should be clarified. Thanks!

Jens Olaf Koch  Jan 11, 2023  May 05, 2023
Page 76
Crow callout

Generics are covered in Chapter 10, "Generics", not Chapter 9, "Type Modifiers".

Josh Goldberg  Jun 05, 2022  Jul 01, 2022
Page 79
Crow callout

TypeScript's configuration options are covered in Chapter 13, "Configuration Options", not Chapter 12, "Using IDE Features".

Josh Goldberg  Jun 05, 2022  Jul 01, 2022
Page 82
last sentence

... attempting to pass the entire `[string, [number, boolean]` as the first parameter ...

misses the closing bracket I think and should read

... attempting to pass the entire `[string, [number, boolean] ]` as the first parameter ...

Note from the Author or Editor:
Agreed, thanks for the spot!

Jens Olaf Koch  Jan 13, 2023  May 05, 2023
Page 83
1st code example

The issue is with the console.log statement inside the logTrio function. It has an opening parenthesis before the third dollar symbol but there is no closing parenthesis. I'm not sure if this is intended or a mistake.

Suggestions to change to either one of the bottom versions of logTrio:

function logTrio(name: string, value: [number, boolean]) {
console.log(`${name] has ${value[0]} (${value[1]})`);
}

function logTrio(name: string, value: [number, boolean]) {
console.log(`${name] has ${value[0]} ${value[1]}`);
}

Note from the Author or Editor:
Indeed, it's a small typo - good catch!

Emrah Abdurahman  Nov 06, 2022  May 05, 2023
Page 89 Optional Properties
code example

In the provided code example, "author" is an optional property, so it is not "missing" as suggested in the "// Error Property 'author' is missing in type..."



Note from the Author or Editor:
Thanks for the spot!

vojimir golem  Sep 11, 2022  May 05, 2023
Page 90
4th paragraph and accompanying code example

The paragraph beginning "In this continuation of the exclaim example,..." and the code example below it don't make sense:

* What is meant by "...isn't explicitly used as a Text until inside the function"? Did you mean Page rather than Text
* The code comments refer to "messengerIsh" but there is no reference code to an object called messengerIsh. Is messengerIsh supposed to be pageIsh?

Note from the Author or Editor:
Thanks for the spot! This had previously been partially reported - the remaining issue was referring to `read` as `exclaim`.

Emrah Abdurahman  Nov 07, 2022  May 05, 2023
Page 90
2nd listing

const pageIsh = {
text:
"Hello, world!",
};
// Ok: messengerIsh is an inferred object type with text, not a Page
page.text += "!";
// Ok: read takes in Page, which happens to
// be a more specific version of pageIsh's type
read(messengerIsh);

What is "messengerIsh"? Did you mean "pageIsh" (2x)?

Please provide the correct code listing as answer if there is something wrong, thank you!

Note from the Author or Editor:
Indeed, thanks for the spot!

Jens Olaf Koch  Jan 17, 2023  May 05, 2023
Page 101
Squirrel tip

The URL should be https://learningtypescript.com/interfaces, not https://learningtypescript.com/objects-and-interfaces. Both work but the latter is a redirect to the former.

Josh Goldberg  Jun 05, 2022  Jul 01, 2022
Page 103
4th paragraph

The paragraph refers to Greeter class with greet class method that takes a type number parameter. In the code below we the paragraph, the greet method declares a parameter name of type string.

Note from the Author or Editor:
Good spot, thanks!

Anonymous  Aug 18, 2022  Aug 26, 2022
Page 105
WithProperty class

I test new WithMethod().myProperty === new WithMethod().myProperty;
book expects it is false. but my result is true.
chatgpt said, "This may be because the TypeScript compiler is optimizing the code and replacing the two separate functions with a single shared function. This optimization is possible because the myProperty function has no side effects and always returns void, so it is safe to reuse it."
I request it is right or not.

Note from the Author or Editor:
Thanks for the report! Indeed, the class should assign an initial value to the myProperty property:

class WithProperty {
myProperty = () => {}
}

Right now it just defines the type of the property without assigning an initial value. So new WithMethod().myProperty will be undefined.

By the way, I would strongly discourage anybody from asking ChatGPT about type checking or other intricate programming operations. It can get most basic & common questions right but is often shockingly wrong about more advanced topics. In this case, it's *very* wrong about TypeScript. TypeScript's compiler performs almost no code optimization, and certainly doesn't optimize by replacing separate functions with a single shared function. You can check how the compiler acts on typescriptlang.org/play.

ChatGPT and other generative AI stuff is very nifty but not ready yet for this kind of question. ????

hanasiyou  Mar 11, 2023  May 05, 2023
Page 108
2nd paragraph

Change "This OptionalProperty class..." to "This MissingInitializer class...".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 11, 2022  May 05, 2023
Page 108 - Chapter 8: Classes
Second code example

The assignment in the Quote constructor has a syntax error. Instead of `this.text = ;`, it should be `this.text = text;`.

Note from the Author or Editor:
Thanks for the spot!

Pablo Alonso  Sep 28, 2022  May 05, 2023
Page 108-9
class Quote

on p.109 first line, Quote.text = "Ha!" // maybe quote.text = "Ha!" ?

class Quote {
readonly text: string;

constrcutor(text: string) {
this.text = text; // changed by other reader's report
}
}

const quote = new Quote(
"There is..."
)

constructor is not working here.
error message: Cannot assign to 'text' because it is a read-only property. // Expected 0 arguments, but got 1.

Note from the Author or Editor:
Indeed - I don't know how that 'Q' became capitalized. Thanks for the report!

hanasiyou  Mar 28, 2023  May 05, 2023
Page 116
1st code example

The following code doesn't make logical sense:
this.message = grade >= 65 ? "Maybe next time..." : "You pass!";

This code says if your grade is greater than or equal to 65, you have failed.

It seems the string returned depending on the grade number need to be switched around.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 12, 2022  May 05, 2023
Page 118
Code example at the top of page 118

There seems to be an issue with the following code example:
const counter: GradeCounter = new AnyFailureChecker();
const count = counter.countGrades(["A", "C", "F"]);

The issue is with the use of the countGrades() method. Even though the counter variable is set to an instance of AnyFailureChecker, the countGrades() method produces an error stating "Expected 2 arguments, but got 1". It doesn't seem to seem to be referring to the countGrades() method on the subclass but instead on the base class.

Note from the Author or Editor:
Indeed - it's mismatched no matter how it's written (per the intent of the example), but adding in that second argument to match the letter parameter makes it more clear. Thanks for the spot!

Emrah Abdurahman  Nov 12, 2022  May 05, 2023
Page 119
Error message comments at the top of page 119

It should say "Error: Property 'value' in type 'VagueGrade' is not assignable to the same property in base type 'NumericGrade'."

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 13, 2022  May 05, 2023
Page 122
2nd paragraph of section titled "Static Field Modifiers"

Change "This HasStatic class..." to "This Question class..." in order to match the class name below it.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 13, 2022  May 05, 2023
Page 123
Code comment at top of page 123

Change "HasStatic" to be "Question" in the error code example.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 13, 2022  May 05, 2023
Page 126
Code snippet at the bottom of page 126

For the first if branch inside of the greetComedianSafety() function, change it from "if (typeof value === "string")" to "if (typeof name === "string")" so it matches the parameter.

For the two greetComedianSafety() function calls at the bottom of page 126, change their corresponding comments as the first call logs "Announcing BETTY WHITE!" and the second call logs "Well, I'm off.".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 14, 2022  May 05, 2023
Page 130
1st code example at the top of page 130

Change "const ratings: Ratings = { audience: 66, critic: 84 };" to "const ratings: Ratings = { audience: 66, critics: 84 };".

The change is to the "critic" property which is incorrectly declared as its non-plural form and doesn't match the Ratings interface declaration on the previous page.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 16, 2022  May 05, 2023
Page 130
All code examples on page 130

Change all object declarations to have the plural form of the property critic.

Or you can change the property name in the Ratings interface on page 129 to match the property name critic on page 130.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 16, 2022  May 05, 2023
Page 132
1st code example's error message at the top of page 132

Change "// Error: Argument of type '"missing"'..." to "// Error: Argument of type '"invalid"'...".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 16, 2022  May 05, 2023
Page 134
1st sentence of 1st paragraph for section titled "Non-Null Assertions"

In the first sentence, "defined" should be "undefined".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 17, 2022  May 05, 2023
Page 135
1st code example

The "maybeValue" and "knownValue" variables will be of type "number | undefined" and "number" respectively as Map.get() is retrieving the numeric value of the provided string key.

As the type returned by Map.get() in this example is "number | undefined" or just "number" with non-null assertion, the toUpperCase() method doesn't exist on the number type.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 17, 2022  May 05, 2023
Page 135
Code example at the bottom of page 135 for the section titled "Type Assertion Caveats"

The "knownValue" variable will be of type "number" rather than "string" as the Map.get() method is returning the corresponding number value for the provided string key.

As "knownValue" is of type number, the toUpperCase() method wont exist on it.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 17, 2022  May 05, 2023
Page 136
1st code example

The first error comment states { one: number; } which needs to be changed to { name: string; }.

The second error comment incorrectly states "reading 'toPrecision'" which should say "reading 'join'".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 17, 2022  May 05, 2023
PDF
Page 137
First sentence under

The `as const` syntax was introduced in Chapter 6, "Arrays", not Chapter 4, "Objects".

Joshua Goldberg
Joshua Goldberg
 
Jun 05, 2022  Jul 01, 2022
Page 138
Error message comments at the bottom of page 138

"LogAction" should be "Joke" instead.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 18, 2022  May 05, 2023
Page 139
Second sentence of third paragraph

The variable "favoritesConst" is not defined in the code example on page 139. Did you mean "preferencesReadonly" instead?

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 18, 2022  May 05, 2023
Page 142
1st code example

Change the following code:
const numeric = identity("me"); // Type: "me"
const stringy = identity(123); // Type: 123

To the following:
const stringy = identity("me"); // Type: "me"
const numeric = identity(123); // Type: 123

This is so that the constant variable names match the argument types.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 18, 2022  May 05, 2023
Page 147
Second code example just before the start of the "Generic Classes" section

The usage and error message of the CrateLike<T> interface are incorrectly named.

Change the 'Crate<T>' in the error message to 'CrateLike<T>' so it matches with its interface declaration.

Also change '"inside: "??"' to "contents: "??"' so it matches the contents property declared in the interface.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 20, 2022  May 05, 2023
Page 154
Bottom code snippet

The type of allExplicit is KeyValuePair<string, number>, not KeyValuePair<string, string>.

Josh Goldberg  Jun 05, 2022  Jul 01, 2022
Page 154
middle

Should we delete // and move tilde symbol under the word “value?

let mismatch: Quote = { value: 123 };
~~~~~

Note from the Author or Editor:
Oof, yes, thanks - that is offset a bit. Thanks for the report!

Sophia  Apr 05, 2023  May 05, 2023
Page 155
Code example at the top of page 155

The type inferred by TypeScript for the variable "oneDefaulting" is "KeyValuePair<string, string>" rather than "KeyValuePair<string>".

"KeyValuePair<string, string>" is what is displayed when hovering over the "oneDefaulting" variable in VS Code.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 23, 2022  May 05, 2023
Page 158
3rd paragraph

The third paragraph states that lengthEventually waits an additional second to resolve with a number.

I believe this is incorrect and it instead resolves with a number immediately after textEventually resolves as the function provided to the .then() method doesn't call setTimeout().

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 24, 2022  May 05, 2023
Page 173
Last sentence of last paragraph at the bottom of page 173

For the last sentence at the bottom of page 173 which says "For example, the Storage interface...", add the word "is" between "interface" and "used" so it says "interface is used" rather than "interface used".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 27, 2022  May 05, 2023
Page 176
1st sentence of 1st paragraph

Remove the word "some" from the first sentence "...they might look some something like these files.".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Nov 27, 2022  May 05, 2023
Page 216
Second sentence of first paragraph of section titled "strictFunctionTypes"

This sentence states the following: "A function type is no longer considered assignable to another function type if its parameters are subtypes of that other type's parameters.".

The comments for the "strictFunctionTypes" compiler option in the "tsconfig.json" file say "When assigning functions, check to ensure parameters and the return values are subtype-compatible".

My question is if the sentence in the book is technically accurate as the comment states checking if the parameters are subtype compatible?

Note from the Author or Editor:
Indeed - this sentence was meant to be a double negative. Adding a missing 'not' in there makes it technically accurate. Thanks for the spot!

Emrah Abdurahman  Dec 04, 2022  May 05, 2023
Page 228
Code snippet at the bottom of page 228

The "composite" setting should be nested inside the "compilerOptions".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Dec 13, 2022  May 05, 2023
Page 238
First sentence of last paragraph

The key of the property should be "greet" instead of "log".

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Dec 15, 2022  May 05, 2023
Page 246
Code example at the bottom of page 246

I'm not too sure if this is correct.

If the code is output JavaScript, shouldn't the output filename extensions be ".js" rather than ".ts"?

For example, shouldn't "settings/constants.ts" and "settings/describe.ts" be "settings/constants.js" and "settings/describe.js" respectively?

Note from the Author or Editor:
Ha, yes. Technically if the comments were `*.ts` in the source code, they'd still be `*.js` in the output - which is I believe what I was aiming for originally. But you're right, that's both confusing and misleading. I'll switch them to `*.js` for future prints and online.

Emrah Abdurahman  Dec 16, 2022  May 05, 2023
Page 248
Code example at the bottom of page 248

The describe() function is using "Settings.name" and "Settings.version" in its template string literal.

This is incorrect and "Settings." should be removed in both instances as the "name" and "version" value are being imported from the "./constants" module.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Dec 16, 2022  May 05, 2023
Page 256
Second paragraph of section titled "Changing Modifiers" on page 256

"OptionalReadonlyConservationist" should be "OptionalReadonlyEnvironmentalist" to match the type name in the code below.

Note from the Author or Editor:
Thanks for the spot!

Emrah Abdurahman  Dec 18, 2022  May 05, 2023
Page 261
https://www.google.ca/books/edition/Learning_TypeScript/YD5zEAAAQBAJ?hl=en&gbpv=1&dq=throwIfNotFound+Conditional+types+distribute+over+unions&pg=PA261&printsec=frontcover

ConditionalType<T | U> is the same as Conditional<T> | Conditional<U>
should be
ConditionalType<T | U> is the same as ConditionalType<T> | ConditionalType<U>

Note from the Author or Editor:
Thanks for the spot!

Ting Chong Ma  Nov 02, 2022  May 05, 2023
Page 264
2nd paragraph of section titled "never and Conditional Types"

Change the word "null" to "false" in the sentence ""This OnlyStrings generic conditional type filters out types..." so it matches the union provided to OnlyStrings<> in the code below this sentence.

Note from the Author or Editor:
Nice spot, thanks!

Emrah Abdurahman  Dec 24, 2022  May 05, 2023
Page 269
second paragraph and first full code comment

Change "This ConfigGetter type is based..." to "This LazyValues type is based...".

Change code comment keys "location", "name", and "year" to "locationLazy", "nameLazy", and "yearLazy".

Note from the Author or Editor:
Nice spot, thanks!

Emrah Abdurahman  Dec 25, 2022  May 05, 2023
Page 274
Last sentence of glossary term "distributivity"

Change the last sentence of the "distributivity" glossary entry to "ConditionalType<T | U> is the same as ConditionalType<T> | ConditionalType<U>".

Note from the Author or Editor:
Nice spot, thanks!

Emrah Abdurahman  Dec 25, 2022  May 05, 2023
Page 277
Second sentence of glossary entry "target"

Add the word "to" in between the words "advisable" and "use" so it says "...it's advisable to use as new JavaScript syntax...".

Note from the Author or Editor:
Nice spot, thanks!

Emrah Abdurahman  Dec 26, 2022  May 05, 2023