Skip to content

Commit

Permalink
note
Browse files Browse the repository at this point in the history
  • Loading branch information
ajn404 committed Jul 22, 2023
1 parent 60429d1 commit 062dc81
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/codeReference/react/withVideoLearn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## react history

### html.js.css
### jq
### backbone.js
### the birth of SPA
### angular
### mvc mvvm
### react

## declarative_vs_imperative

### 声明式与命令式
## component architecture

关于组件

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function singSongsRecursive(song: string[], count: number = 0): number {
return song.length ? singSongsRecursive(song.slice(1), count + 1) : count;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//#region function types parentheses

let returnStringOrUndefined: () => string | undefined;
let mayReturnsStrings: (() => string) | undefined;
//#end region

const neverReturn = () => {
throw new Error("never never");
};

const voidReturn = () => {
// while (false) {
// return "hiihii";
// }
return;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### 函数的类型定义需要注意的问题

- optional parameters中
required parameters必须在optional parameters前面
- Rest Parameters
@[code](./rest_parameters.ts)
- never vs void

:::tip tip
void:function return nothing
never: function never return
:::


### unknown words
- cumbersome 笨重的
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//#region part1
let singer: (song: string) => string;
singer = function (song) {
return `Singing ${song.toUpperCase()}`;
};
//#endregion

{
// Functions passed as arguments to parameters with function parameter types will have their parameter types inferred as well.
let songs = ["1", "2", "3"];
songs.forEach((song, index) => {
console.log(`${song} at index:${index}`);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function singAllTheSongs(singer: string, ...songs: string[]) {
for (const song of songs) {
console.log(`《${song}》 by ${singer}`);
}
}

singAllTheSongs("ajn404");
singAllTheSongs("ajn403", "我", "我记得");
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Intersection types are a useful concept, but it’s easy to use them in ways that confuse either yourself or the TypeScript compiler.

//#region long assignability errors
type ShortPoemMBase = {
author: string;
};

type Haiku = ShortPoemMBase & {
kigo: string;
type: "haiku";
};

type Villanelle = ShortPoemMBase & {
type: "villanelle";
meter: string;
};

type ShortPoemM = Haiku | Villanelle;

const oneArt: ShortPoemM = {
author: "ajn404",
type: "villanelle",
// meter:'hihi'
};

//#endregion

//#region never
type NotPossible = number & string;
//type NotPossible = never
//#endregion

0 comments on commit 062dc81

Please sign in to comment.