Skip to content

Commit 931eafa

Browse files
committed
Final revision
1 parent ade6eb1 commit 931eafa

20 files changed

Lines changed: 145 additions & 72 deletions

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- run: gulp publish
2929

3030
# Deploy if we can
31-
- run: npx now site/ --token=$NOW_ACCESS_TOKEN --name=typescript-playbook-$PR_NUMBER
31+
- run: npx now site/ --token=$NOW_ACCESS_TOKEN --name=typescript-site-$PR_NUMBER
3232
env:
3333
NOW_ACCESS_TOKEN: ${{ secrets.NOW_ACCESS_TOKEN }}
3434
PR_NUMBER: ${{ github.event.pull_request.number }}

Examples/en/JavaScript/External APIs/TypeScript + Node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//// { order: 3, isJavaScript: true }
22

3-
// Node is a very popular JavaScript runtime built on v8,
3+
// Node.js is a very popular JavaScript runtime built on v8,
44
// the JavaScript engine which powers Chrome. You can use it
55
// to build servers, front-end clients and anything in-between.
66

Examples/en/JavaScript/External APIs/TypeScript + React.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// First we'll look at how generic interfaces are used to map
1818
// React components. This is a faux-React functional component:
1919

20-
2120
type FauxactFunctionComponent<Props extends {}> =
2221
(props: Props, context?: any) => FauxactFunctionComponent<any> | null | JSX.Element
2322

Examples/en/JavaScript/External APIs/TypeScript + Web.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ document.body.appendChild(popover);
7272
// on the x in the top right of the popup.
7373

7474
// This example shows how you can work with the DOM API
75-
// in TypeScript - but it only shows a subset of working
76-
// with the browser's APIs which TypeScript supports
75+
// in JavaScript - but using TypeScript to provide great
76+
// tooling support.
7777

78-
// There is an extended example for TypeScript with the
79-
// WebGL example available here: example:typescript---webgl
78+
// There is an extended example for TypeScript tooling with
79+
// WebGL available here: example:typescript---webgl

Examples/en/JavaScript/External APIs/TypeScript + WebGL.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//// { order: 5 }
22

3-
// Create a HTML canvas which uses WebGL to render spinning
4-
// confetti, let's walk through the code to understand how it works
3+
// This example create a HTML canvas which uses WebGL to
4+
// render spinning confetti using JavaScript. We're going
5+
// to walk through the code to understand how it works, and
6+
// see how TypeScript's tooling provides useful insight.
57

68
// This example builds off: example:working-with-the-dom
79

@@ -37,8 +39,7 @@ const gl = canvas.getContext("webgl")
3739
// array of vertices (numbers)
3840

3941
// You can see the large set of attributes at the top of the shader,
40-
// these are passed in from
41-
//
42+
// these are passed into the compiled shader further down the example.
4243

4344
// There's a great overview on how they work here:
4445
// https://webglfundamentals.org/webgl/lessons/webgl-how-it-works.html
@@ -117,9 +118,9 @@ gl.compileShader(vertexShader)
117118
// shader is another small program that runs through every
118119
// pixel in the canvas and set its color.
119120

120-
// In this case, if you play around with the numers you can see how
121+
// In this case, if you play around with the numbers you can see how
121122
// this affects the lighting in the scene, as well as the border
122-
// radius on the confetti
123+
// radius on the confetti:
123124

124125
const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER)
125126
gl.shaderSource(

Examples/en/JavaScript/Functions with JavaScript/Function Chaining.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
// Function chaining APIs are a common pattern in
55
// JavaScript, which can make your code focused
66
// with less intermediary values and easier to read
7-
// because of the spacing.
7+
// because of their nesting qualities.
88

99
// A really common API which works via chaining
1010
// is jQuery. Here is an example of jQuery
1111
// being used with the types from DefinitelyTyped
1212

1313
import $ from "jquery";
1414

15-
// Here's an example use of the jQuery API
15+
// Here's an example use of the jQuery API:
1616

1717
$("#navigation")
1818
.css("background", "red")
@@ -86,3 +86,4 @@ new AddNumbers(2).add(3).add(3);
8686

8787
// For more examples on this:
8888
//
89+
// - example:code-flow

Examples/en/JavaScript/Functions with JavaScript/Generic Functions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ function wrapInArray<Type>(input: Type): Type[] {
1515
}
1616

1717
// Note: it's common to see Type refereed to as T. This is
18-
// culturally like how people use i in a for loop to
19-
// represent index. We'll be using full names for clarity.
18+
// culturally similar to how people use i in a for loop to
19+
// represent index. T normally represents Types, so we'll
20+
// be using the full name for clarity.
2021

2122
// Our function will use inference to always keep the type
2223
// passed in the same as the type passed out (though
@@ -25,7 +26,9 @@ function wrapInArray<Type>(input: Type): Type[] {
2526
const stringArray = wrapInArray("hello generics");
2627
const numberArray = wrapInArray(123);
2728

28-
// By providing types you can ensure code fails correctly
29+
// We can verify this works as expected by checking
30+
// if we can assign a string array to a function which
31+
// should be an object array
2932
const notStringArray: string[] = wrapInArray({});
3033

3134
// You can also skip the generic inference by adding the

Examples/en/JavaScript/Functions with JavaScript/Typing Functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ const boolValue2 = boolOrNumberOrStringFunction("string")
129129
// variables in type definitions.
130130

131131
// example:generic-functions
132-
132+
// example:function-chaining

Examples/en/JavaScript/JavaScript Essentials/Code Flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ if (typeof randomIdentifier === "number") {
5353
// code types will change in different locations.
5454

5555
// To learn more about code flow analysis
56-
// - [handbook]
56+
// - example:type-guards
5757

5858
// To continue reading through examples you could jump to a few different
5959
// places now.

Examples/en/JavaScript/JavaScript Essentials/Functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const addFunction = (x, y) => {
2424
// applies to all three formats.
2525

2626
// TypeScript provides additional syntax which adds to a
27-
// function and offers hints on what the types are expected
28-
// by this function.
27+
// function definition and offers hints on what the
28+
// types are expected by this function.
2929
//
3030
// Up next is the most open version of the add function, it
3131
// says that add takes two inputs of any type: this could

0 commit comments

Comments
 (0)