diff --git a/docs/codeReference/react/withVideoLearn.md b/docs/codeReference/react/withVideoLearn.md new file mode 100644 index 00000000..abb79ae4 --- /dev/null +++ b/docs/codeReference/react/withVideoLearn.md @@ -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 + +关于组件 + diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/explicit_return_types.ts b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/explicit_return_types.ts new file mode 100644 index 00000000..6038d606 --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/explicit_return_types.ts @@ -0,0 +1,3 @@ +function singSongsRecursive(song: string[], count: number = 0): number { + return song.length ? singSongsRecursive(song.slice(1), count + 1) : count; +} diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/function_types.ts b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/function_types.ts new file mode 100644 index 00000000..a483ad63 --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/function_types.ts @@ -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; +}; diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/note.md b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/note.md new file mode 100644 index 00000000..5ffb749e --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/note.md @@ -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 笨重的 \ No newline at end of file diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/parameter_type_interfaces.ts b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/parameter_type_interfaces.ts new file mode 100644 index 00000000..005558fd --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/parameter_type_interfaces.ts @@ -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}`); + }); +} diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/rest_parameters.ts b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/rest_parameters.ts new file mode 100644 index 00000000..1d388893 --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/5_functions/rest_parameters.ts @@ -0,0 +1,8 @@ +function singAllTheSongs(singer: string, ...songs: string[]) { + for (const song of songs) { + console.log(`《${song}》 by ${singer}`); + } +} + +singAllTheSongs("ajn404"); +singAllTheSongs("ajn403", "我", "我记得"); diff --git a/docs/codeReference/typescript/Systematization/books/learningTypescript/intersectionTypes/1_danger_of_insertion_tyoes.ts b/docs/codeReference/typescript/Systematization/books/learningTypescript/intersectionTypes/1_danger_of_insertion_tyoes.ts new file mode 100644 index 00000000..bb6157c0 --- /dev/null +++ b/docs/codeReference/typescript/Systematization/books/learningTypescript/intersectionTypes/1_danger_of_insertion_tyoes.ts @@ -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