Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-north authored Oct 1, 2023
2 parents f398c7f + ac8698a commit b42114b
Show file tree
Hide file tree
Showing 22 changed files with 5,565 additions and 6,075 deletions.
7 changes: 6 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
versioning-strategy: widen
open-pull-requests-limit: 20
open-pull-requests-limit: 20
55 changes: 25 additions & 30 deletions .github/workflows/ci-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand All @@ -47,10 +47,10 @@ jobs:
# - macos-latest
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand All @@ -70,14 +70,15 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x]
# node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
with:
node-version: ${{ matrix.node-version }}
- name: restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand All @@ -98,23 +99,17 @@ jobs:
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
typescript-version: ['~4.2.0', '~4.3.0', '~4.4.0','~4.5.0', latest, next, beta, rc]
typescript-version: ['~5.1.0', next, beta, rc]
include:
- typescript-version: '~4.2.0'
# - typescript-version: '~5.0.0'
# experimental: false
# name: 'ts-5.0'
- typescript-version: '~5.1.0'
experimental: false
name: 'ts-4.2'
- typescript-version: '~4.3.0'
experimental: false
name: 'ts-4.3'
- typescript-version: '~4.4.0'
experimental: false
name: 'ts-4.4'
- typescript-version: '~4.5.0'
experimental: false
name: 'ts-4.5'
- typescript-version: latest
experimental: false
name: 'ts-stable'
name: 'ts-5.1'
# - typescript-version: latest
# experimental: false
# name: 'ts-stable'
- typescript-version: beta
experimental: false
name: 'ts-beta'
Expand All @@ -127,10 +122,10 @@ jobs:


steps:
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand All @@ -156,8 +151,8 @@ jobs:
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v1
- uses: volta-cli/action@v1
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: |
yarn
yarn lerna bootstrap
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"packages/*"
],
"volta": {
"node": "14.17.0",
"yarn": "1.22.10"
"node": "20.8.0",
"yarn": "1.22.19"
},
"devDependencies": {
"@babel/core": "^7.4.0-0",
"@babel/preset-typescript": "^7.16.7",
"core-js": "^3.0.0",
"lerna": "^4.0.0",
"replace-in-file": "^6.2.0",
"replace-in-file": "^7.0.1",
"webpack": "^5.37.0"
},
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion packages/hello-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"license": "NOLICENSE",
"version": "0.0.1",
"devDependencies": {
"typescript": "^4.3.2"
"typescript": "~5.2.0"
},
"scripts": {
"dev": "tsc --watch --preserveWatchOutput"
},
"volta": {
"node": "20.8.0",
"yarn": "1.22.19"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In this chapter we will...

## Anatomy of the project

Let's consider your [`a very simple TypeScript project`](https://github.com/mike-north/ts-fundamentals-v3/blob/main/packages/hello-ts/)
Let's consider [`a very simple TypeScript project`](https://github.com/mike-north/ts-fundamentals-v3/blob/main/packages/hello-ts/)
that consists of only three files:

```sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We could create a JavaScript object to represent this information:
}
```

The type that would describes this object's structure:
The type that would describe this object's structure:

```ts
{
Expand Down Expand Up @@ -146,7 +146,7 @@ TypeScript helps us catch a particular type of problem around the use of object
Let's look at the situation where the error arises:

```ts twoslash
// @errors: 2345
// @errors: 2345 2353
function printCar(car: {
make: string
model: string
Expand Down Expand Up @@ -213,7 +213,7 @@ phones.fax
// ^?
```

Now, no matter what key we lookup, we get an object that represents
Now, no matter what key we look up, we get an object that represents
a phone number.

## Array Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ If the argument passed to it meets these requirements, `printCar` is happy.

"Duck typing" gets its name from the "duck test".

> “If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck”.
> “If it looks like a duck, swims like a duck, and quacks like a duck, then it's probably is a duck”.
In practice, this is very similar to structural typing, but "Duck typing" is usually
used to describe dynamic type systems.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ isJSON(class {})
// @ts-expect-error
isJSON(undefined)
// @ts-expect-error
isJSON(new BigInt(143))
isJSON(BigInt(143))
// @ts-expect-error
isJSON(isJSON)
```
Expand Down Expand Up @@ -93,7 +93,7 @@ isJSON(class {})
// @ts-expect-error
isJSON(undefined)
// @ts-expect-error
isJSON(new BigInt(143))
isJSON(BigInt(143))
// @ts-expect-error
isJSON(isJSON)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Imagine if we were passing this value through several other functions before rea
type checking alerted us to a problem!

```ts twoslash
// @errors: 2531 2339 2532
// @errors: 2531 2339 2532 18048
type JSONPrimitive = string | number | boolean | null
type JSONObject = { [k: string]: JSONValue }
type JSONArray = JSONValue[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ However, `unknown` is different from `any` in a very important way:
> applying a type guard
```ts twoslash
// @errors: 2571
// @errors: 2571 18046
let myUnknown: unknown = 14
myUnknown.it.is.possible.to.access.any.deep.property
// ^?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ operator just tells TypeScript to ignore that possibility.
If the value _does_ turn out to be missing, you will get the familiar `cannot call foo on undefined` family of errors at runtime:

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
type GroceryCart = {
fruits?: { name: string; qty: number }[]
vegetables?: { name: string; qty: number }[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ order: 1

## About the Instructor

- Sr. Staff Engineer @ [LinkedIn](https://linkedin.com)
- Works in the **Developer Productivity and Happiness** org
- Main focus: **Infra UX**
- **TypeScript Infra Lead**
- Developer Platform lead @ [Stripe](https://stripe.com)
- One of Stripe's Product Architects

## Top Goals for this course

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ improved type safety
```

```ts twoslash
// @errors: 2322
// @errors: 2322 2561
class WebpackCompiler {
constructor(options: {
amd?: false | { [index: string]: any }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ has different property names than the type being "iterated over" during the mapp
Note the use of the `as` keyword in the index signature
```ts twoslash
// @errors: 2345
// @errors: 2345 2561
interface DataState {
digits: number[]
names: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ d.rhubarb.join(", ") // 💥
My advice was to explicitly type it as

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
type Dict<T> = { [K: string]: T | undefined }
const d: Dict<string[]> = {}
d.rhubarb.join(", ") // 💥
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ printColor({
**No, this will not compile**.

```ts twoslash
// @errors: 2345
// @errors: 2345 2353
interface Color {
red: number
green: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const otherLibrary = new Library()
```ts {4}
class AsyncManager {
constructor(arg: 0 | 4 | string) {
// @ts-ignore
if (arg > 0 || arg <= 0) {
new Promise((resolve, reject) => {
arg
Expand All @@ -95,6 +96,7 @@ class AsyncManager {
<summary>Click for answer</summary>

```ts twoslash
// @errors: 2365
class AsyncManager {
constructor(arg: 0 | 4 | string) {
if (arg > 0 || arg <= 0) {
Expand Down
41 changes: 23 additions & 18 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"gatsby-plugin-manifest": "^3.1.0",
"gatsby-plugin-react-helmet": "^4.1.0",
"gatsby-plugin-sass": "^4.1.0",
"gatsby-plugin-sharp": "^3.1.2",
"gatsby-plugin-sharp": "^3.0.0",
"gatsby-plugin-typography": "^3.1.0",
"gatsby-remark-autolink-headers": "^4.3.0",
"gatsby-remark-copy-linked-files": "^4.2.1",
Expand All @@ -25,33 +25,38 @@
"gatsby-source-filesystem": "^3.1.0",
"gatsby-transformer-remark": "^3.0.0",
"gatsby-transformer-sharp": "^3.1.0",
"prismjs": "^1.19.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"prismjs": "^1.29.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-typography": "^0.16.19",
"react-typography": "^0.16.23",
"replace-in-file": "^7.0.1",
"sass": "^1.32.8",
"typeface-merriweather": "1.1.13",
"typeface-montserrat": "1.1.13",
"typography": "^0.16.19",
"typography-theme-wordpress-2016": "^0.16.19"
},
"devDependencies": {
"@babel/core": "^7.4.0-0",
"@babel/preset-typescript": "^7.16.7",
"@types/jest": "^27.0.0",
"@types/lodash": "^4.14.170",
"@types/node": "16",
"@types/pkg-up": "^3.1.0",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/react-helmet": "^6.1.0",
"@types/react-test-renderer": "^17.0.1",
"@types/react": "18",
"@types/react-dom": "18",
"@types/react-helmet": "^6.1.7",
"@types/react-test-renderer": "^18.0.3",
"@types/sharp": "^0.30.0",
"@types/typography": "^0.16.3",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"babel-jest": "^26.6.3",
"babel-preset-gatsby": "^2.9.1",
"eslint": "^7.23.0",
"eslint-plugin-react": "^7.29.4",
"babel-preset-gatsby": "^3.12.0",
"core-js": "^3.0.0",
"eslint": "^8.50.0",
"eslint-plugin-react": "^7.33.2",
"gatsby-plugin-google-gtag": "^3.7.1",
"gatsby-plugin-google-tagmanager": "^3.7.1",
"gatsby-remark-custom-blocks": "^3.6.0",
Expand All @@ -64,8 +69,8 @@
"markdownlint-cli": "^0.31.1",
"pkg-up": "^3.1.0",
"prettier": "^2.2.1",
"react-test-renderer": "^17.0.2",
"typescript": "^4.3.2"
"react-test-renderer": "^18.2.0",
"typescript": "~5.2.0"
},
"homepage": "https://github.com/mike-north/typescript-fundamentals-v3#readme",
"keywords": [
Expand All @@ -90,7 +95,7 @@
"typecheck": "tsc -P . --noEmit"
},
"volta": {
"node": "14.16.0",
"yarn": "1.22.10"
"node": "20.8.0",
"yarn": "1.22.19"
}
}
Loading

0 comments on commit b42114b

Please sign in to comment.