diff --git a/book-content/chapters/13-modules-scripts-declaration-files.md b/book-content/chapters/13-modules-scripts-declaration-files.md index ad9ee12..38a51ea 100644 --- a/book-content/chapters/13-modules-scripts-declaration-files.md +++ b/book-content/chapters/13-modules-scripts-declaration-files.md @@ -280,13 +280,13 @@ type Album = { releaseDate: string; }; -declare const ALBUM_API: { +declare const MUSIC_API: { getAlbumInfo(upc: string): Promise; searchAlbums(query: string): Promise; }; ``` -Because we haven't included any imports or exports, this file is treated as a script. This means that the `ALBUM_API` variable is now available globally in our project. +Because we haven't included any imports or exports, this file is treated as a script. This means that the `MUSIC_API` variable is now available globally in our project. #### Scoping Global Variables To One File @@ -301,17 +301,17 @@ type Album = { releaseDate: string; }; -declare const ALBUM_API: { +declare const MUSIC_API: { getAlbumInfo(upc: string): Promise; searchAlbums(query: string): Promise; }; export function getAlbumTitle(upc: string) { - return ALBUM_API.getAlbumInfo(upc).then((album) => album.title); + return MUSIC_API.getAlbumInfo(upc).then((album) => album.title); } ``` -Now, `ALBUM_API` is only available in the `musicUtils.ts` file. `declare` defines the value within the scope it's currently in. So, because we're now inside a module (due to the `export` statement), `ALBUM_API` is scoped to this module. +Now, `MUSIC_API` is only available in the `musicUtils.ts` file. `declare` defines the value within the scope it's currently in. So, because we're now inside a module (due to the `export` statement), `MUSIC_API` is scoped to this module. #### `declare const`, `declare var`, `declare let`, `declare function` @@ -343,7 +343,7 @@ type Album = { // ---cut--- // inside musicUtils.ts declare global { - declare const ALBUM_API: { + declare const MUSIC_API: { getAlbumInfo(upc: string): Promise; searchAlbums(query: string): Promise; }; @@ -356,14 +356,14 @@ This almost works, except for the error. We can't use `declare` inside an ambien // inside musicUtils.ts declare global { - const ALBUM_API: { + const MUSIC_API: { getAlbumInfo(upc: string): Promise; searchAlbums(query: string): Promise; }; } ``` -Now the `ALBUM_API` variable has been put into the global scope. +Now the `MUSIC_API` variable has been put into the global scope. ### `declare module` diff --git a/book-content/chapters/16-the-utils-folder.md b/book-content/chapters/16-the-utils-folder.md index 3694077..8149e50 100644 --- a/book-content/chapters/16-the-utils-folder.md +++ b/book-content/chapters/16-the-utils-folder.md @@ -216,7 +216,7 @@ const getFirstElement = (arr: TMember[]) => { Just like generic functions, it's common to prefix your type parameters with `T` to differentiate them from normal types. -Now when we call `getFirstElement`, TypeScript will infer the type of `` based on the argument we pass in: +Now when we call `getFirstElement`, TypeScript will infer the type of `TMember` based on the argument we pass in: ```ts twoslash const getFirstElement = (arr: TMember[]) => {