├── .gitignore
├── CB834301747.jpeg
├── QuanZhanXiuLian.png
├── README.md
├── blog-gitbook
├── .gitignore
├── README.md
├── SUMMARY.md
├── _book
│ ├── .gitignore
│ ├── _config.yml
│ ├── gitbook
│ │ ├── fonts
│ │ │ └── fontawesome
│ │ │ │ ├── FontAwesome.otf
│ │ │ │ ├── fontawesome-webfont.eot
│ │ │ │ ├── fontawesome-webfont.svg
│ │ │ │ ├── fontawesome-webfont.ttf
│ │ │ │ ├── fontawesome-webfont.woff
│ │ │ │ └── fontawesome-webfont.woff2
│ │ ├── gitbook-plugin-anchor-navigation-ex
│ │ │ ├── lib
│ │ │ │ ├── config.js
│ │ │ │ ├── log.js
│ │ │ │ └── plugin.js
│ │ │ └── style
│ │ │ │ └── plugin.css
│ │ ├── gitbook-plugin-baidu-tongji
│ │ │ └── plugin.js
│ │ ├── gitbook-plugin-copy-code-button
│ │ │ └── toggle.js
│ │ ├── gitbook-plugin-donate
│ │ │ ├── plugin.css
│ │ │ └── plugin.js
│ │ ├── gitbook-plugin-expandable-chapters
│ │ │ ├── expandable-chapters.css
│ │ │ └── expandable-chapters.js
│ │ ├── gitbook-plugin-fontsettings
│ │ │ ├── fontsettings.js
│ │ │ └── website.css
│ │ ├── gitbook-plugin-github-buttons
│ │ │ ├── plugin.js
│ │ │ └── plugin.js.map
│ │ ├── gitbook-plugin-search-pro
│ │ │ ├── jquery.mark.min.js
│ │ │ ├── search.css
│ │ │ └── search.js
│ │ ├── gitbook-plugin-splitter
│ │ │ ├── splitter.css
│ │ │ └── splitter.js
│ │ ├── gitbook-plugin-tbfed-pagefooter
│ │ │ └── footer.css
│ │ ├── gitbook.js
│ │ ├── images
│ │ │ ├── apple-touch-icon-precomposed-152.png
│ │ │ └── favicon.ico
│ │ ├── style.css
│ │ └── theme.js
│ ├── index.html
│ ├── search_plus_index.json
│ └── views
│ │ ├── README.md
│ │ ├── algorithms
│ │ ├── js-10algo.html
│ │ └── js-time-space.html
│ │ ├── component
│ │ └── gitalk.md
│ │ ├── github
│ │ ├── follow.html
│ │ └── star.html
│ │ └── vue
│ │ └── vue-ts.html
├── _config.yml
├── book.json
└── views
│ ├── README.md
│ ├── algorithms
│ ├── js-10algo.md
│ └── js-time-space.md
│ ├── component
│ └── gitalk.md
│ ├── github
│ ├── follow.md
│ └── star.md
│ ├── public
│ └── assets
│ │ ├── favicon.ico
│ │ ├── favicon2.ico
│ │ ├── logo.jpg
│ │ ├── user-logo.jpeg
│ │ └── yejintianming.png
│ └── vue
│ └── vue-ts.md
├── blog-vuepress
├── .gitignore
├── README.md
├── builds
│ ├── addComponents.js
│ ├── delComponents.js
│ └── findMarkdown.js
├── delay.sh
├── docs
│ ├── .vuepress
│ │ ├── components
│ │ │ └── comment.vue
│ │ ├── config.js
│ │ ├── css
│ │ │ └── gittalk.css
│ │ ├── enhanceApp.js
│ │ ├── public
│ │ │ └── assets
│ │ │ │ ├── favicon.ico
│ │ │ │ ├── favicon2.ico
│ │ │ │ ├── logo.jpg
│ │ │ │ ├── user-logo.jpeg
│ │ │ │ └── yejintianming.png
│ │ ├── styles
│ │ │ └── index.styl
│ │ ├── templates
│ │ │ ├── dev.html
│ │ │ └── ssr.html
│ │ └── utils.js
│ ├── README.md
│ ├── en
│ │ └── README.md
│ ├── guide
│ │ └── README.md
│ └── views
│ │ ├── README.md
│ │ ├── algorithms
│ │ └── 10algo.md
│ │ ├── github
│ │ ├── follow.md
│ │ └── star.md
│ │ └── vue
│ │ └── vue-ts.md
├── package-lock.json
├── package.json
└── yarn.lock
├── data-structure-and-algorithms
├── 0. arr.html
├── 1. singly-linked-list.html
├── 10. binary-search-tree.html
├── 11. bubble-sort.html
├── 12. insertion-sort.html
├── 13. selection-sort.html
├── 14. merge-sort.html
├── 15. quick-sort.html
├── 16. shell-sort.html
├── 17. heap-sort.html
├── 18. bocket-sort.html
├── 19. counting-sort.html
├── 2. doubly-linked-list.html
├── 20. radix-sort.html
├── 3. circular-linked-list.html
├── 4. stack.html
├── 5. queue.html
├── 6. min-priority-queue.html
├── 7. max-priority-queue.html
└── 9. hot-potato.html
├── images
├── CB834301747.jpeg
├── FrontEndGitHub.png
├── FrontEndGitHubLogo.png
├── backend-map.png
├── devops-map.png
└── frontend-map.png
├── interview
└── fe-interview.md
├── resume
├── resume.md
└── resume.pdf
└── typescript-in-action
├── README.md
├── mindmap
├── 全部课程.jpg
├── 基础篇.jpg
├── 实战篇.jpg
└── 工程篇.jpg
├── ppt
└── 《TypeScript开发实战》课件.pdf
└── sourcecode
├── project-migration
├── stage-0
│ ├── .babelrc
│ ├── .gitignore
│ ├── README.md
│ ├── build
│ │ ├── webpack.base.config.js
│ │ ├── webpack.config.js
│ │ ├── webpack.dev.config.js
│ │ └── webpack.pro.config.js
│ ├── package.json
│ └── src
│ │ ├── components
│ │ └── Hello.jsx
│ │ ├── index.jsx
│ │ ├── tpl
│ │ └── index.html
│ │ └── utils
│ │ └── a.js
├── stage-1
│ ├── .babelrc
│ ├── .gitignore
│ ├── README.md
│ ├── build
│ │ ├── webpack.base.config.js
│ │ ├── webpack.config.js
│ │ ├── webpack.dev.config.js
│ │ └── webpack.pro.config.js
│ ├── package.json
│ ├── src
│ │ ├── components
│ │ │ ├── Hello.jsx
│ │ │ └── Hi.tsx
│ │ ├── index.jsx
│ │ ├── tpl
│ │ │ └── index.html
│ │ └── utils
│ │ │ ├── a.js
│ │ │ └── b.ts
│ └── tsconfig.json
├── stage-2
│ ├── .babelrc
│ ├── .gitignore
│ ├── README.md
│ ├── build
│ │ ├── webpack.base.config.js
│ │ ├── webpack.config.js
│ │ ├── webpack.dev.config.js
│ │ └── webpack.pro.config.js
│ ├── package.json
│ ├── renameJS.ts
│ ├── src
│ │ ├── components
│ │ │ ├── Hello.tsx
│ │ │ └── Hi.tsx
│ │ ├── index.tsx
│ │ ├── tpl
│ │ │ └── index.html
│ │ └── utils
│ │ │ ├── a.ts
│ │ │ └── b.ts
│ └── tsconfig.json
└── stage-3
│ ├── .babelrc
│ ├── .gitignore
│ ├── README.md
│ ├── build
│ ├── webpack.base.config.js
│ ├── webpack.config.js
│ ├── webpack.dev.config.js
│ └── webpack.pro.config.js
│ ├── package.json
│ ├── renameJS.ts
│ ├── src
│ ├── components
│ │ ├── Hello.tsx
│ │ └── Hi.tsx
│ ├── index.tsx
│ ├── tpl
│ │ └── index.html
│ └── utils
│ │ ├── a.ts
│ │ └── b.ts
│ └── tsconfig.json
├── prototype
├── data
│ ├── document.js
│ └── styles.css
├── employee.html
├── files
│ ├── employee
│ │ ├── data.js
│ │ └── styles.css
│ └── systerm
│ │ ├── data.js
│ │ └── styles.css
├── images
│ └── employee
│ │ ├── u10.png
│ │ ├── u11.png
│ │ ├── u14.png
│ │ ├── u15.png
│ │ ├── u18.png
│ │ ├── u22.png
│ │ ├── u29.png
│ │ └── u7.png
├── index.html
├── plugins
│ ├── debug
│ │ └── styles
│ │ │ ├── debug.css
│ │ │ └── images
│ │ │ ├── reset.svg
│ │ │ ├── reset_hover.svg
│ │ │ ├── variables_hover.png
│ │ │ ├── variables_hover.svg
│ │ │ ├── variables_off.png
│ │ │ ├── variables_off.svg
│ │ │ ├── variables_on.png
│ │ │ └── variables_on.svg
│ ├── page_notes
│ │ └── styles
│ │ │ ├── images
│ │ │ ├── back.png
│ │ │ ├── back.svg
│ │ │ ├── back_hover.png
│ │ │ ├── back_hover.svg
│ │ │ ├── footnotes.png
│ │ │ ├── footnotes.svg
│ │ │ ├── footnotes_hover.png
│ │ │ ├── footnotes_hover.svg
│ │ │ ├── footnotes_on.png
│ │ │ ├── footnotes_on.svg
│ │ │ ├── forward.png
│ │ │ ├── forward.svg
│ │ │ ├── forward_hover.png
│ │ │ ├── forward_hover.svg
│ │ │ ├── notes_hover.png
│ │ │ ├── notes_hover.svg
│ │ │ ├── notes_off.png
│ │ │ ├── notes_off.svg
│ │ │ ├── notes_on.png
│ │ │ └── notes_on.svg
│ │ │ └── page_notes.css
│ ├── recordplay
│ │ ├── recordplay.js
│ │ └── styles
│ │ │ └── recordplay.css
│ └── sitemap
│ │ └── styles
│ │ ├── images
│ │ ├── 079_page_16.png
│ │ ├── 086_case_16.png
│ │ ├── 225_responsive_16.png
│ │ ├── 228_togglenotes_16.png
│ │ ├── 229_variables_16.png
│ │ ├── 231_event_16.png
│ │ ├── 232_search_16.png
│ │ ├── 233_hyperlink_16.png
│ │ ├── 235_folderclosed_16.png
│ │ ├── 236_folderopen_16.png
│ │ ├── adaptivecheck.png
│ │ ├── flow.png
│ │ ├── flow.svg
│ │ ├── folder_closed.png
│ │ ├── folder_closed.svg
│ │ ├── folder_open.png
│ │ ├── folder_open.svg
│ │ ├── hotspots.png
│ │ ├── hotspots.svg
│ │ ├── hotspots_hover.png
│ │ ├── hotspots_hover.svg
│ │ ├── hotspots_on.png
│ │ ├── hotspots_on.svg
│ │ ├── images.html
│ │ ├── minus.gif
│ │ ├── note.png
│ │ ├── note.svg
│ │ ├── page.png
│ │ ├── page.svg
│ │ ├── plus.gif
│ │ ├── share.png
│ │ ├── share.svg
│ │ ├── share_hover.png
│ │ ├── share_hover.svg
│ │ ├── share_on.png
│ │ ├── share_on.svg
│ │ ├── sitemap_hover.png
│ │ ├── sitemap_hover.svg
│ │ ├── sitemap_off.png
│ │ ├── sitemap_off.svg
│ │ ├── sitemap_on.png
│ │ ├── sitemap_on.svg
│ │ ├── views.png
│ │ ├── views.svg
│ │ ├── views_hover.png
│ │ ├── views_hover.svg
│ │ ├── views_on.png
│ │ └── views_on.svg
│ │ └── sitemap.css
├── prototype.rp
├── resources
│ ├── Other.html
│ ├── chrome
│ │ ├── allow-access.png
│ │ ├── axure-chrome-extension.crx
│ │ ├── axure_logo.png
│ │ ├── chrome.html
│ │ ├── details.png
│ │ ├── extensions.png
│ │ ├── safari.html
│ │ ├── safari_advanced.png
│ │ ├── safari_restrictions.png
│ │ ├── splitter.gif
│ │ └── splitter.png
│ ├── css
│ │ ├── axure_rp_page.css
│ │ ├── default.css
│ │ ├── images
│ │ │ ├── images.html
│ │ │ ├── newwindow.gif
│ │ │ ├── note.gif
│ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png
│ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png
│ │ │ ├── ui-bg_glass_65_ffffff_1x400.png
│ │ │ ├── ui-bg_glass_75_dadada_1x400.png
│ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png
│ │ │ ├── ui-bg_glass_75_ffffff_1x400.png
│ │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png
│ │ │ ├── ui-bg_inset-soft_95_fef1ec_1x100.png
│ │ │ ├── ui-icons_222222_256x240.png
│ │ │ ├── ui-icons_2e83ff_256x240.png
│ │ │ ├── ui-icons_454545_256x240.png
│ │ │ ├── ui-icons_888888_256x240.png
│ │ │ └── ui-icons_cd0a0a_256x240.png
│ │ ├── jquery-ui-themes.css
│ │ └── reset.css
│ ├── expand.html
│ ├── images
│ │ ├── 259_close_12rollover1.png
│ │ ├── 259_close_12rollover2.png
│ │ ├── 260_collapse_12rollover1.png
│ │ ├── 260_collapse_12rollover2.png
│ │ ├── 261_expand_12rollover1.png
│ │ ├── 261_expand_12rollover2.png
│ │ ├── close.png
│ │ ├── close.svg
│ │ ├── close_hover.png
│ │ ├── close_hover.svg
│ │ ├── divider.png
│ │ ├── divider.svg
│ │ ├── expand.png
│ │ ├── expand.svg
│ │ ├── expand_hover.png
│ │ ├── expand_hover.svg
│ │ ├── images.html
│ │ └── transparent.gif
│ ├── reload.html
│ └── scripts
│ │ ├── jquery-1.7.1.min.js
│ │ ├── jquery-ui-1.8.10.custom.min.js
│ │ ├── messagecenter.js
│ │ ├── player
│ │ ├── axplayer.js
│ │ └── splitter.js
│ │ ├── prototypePost.js
│ │ ├── prototypePre.js
│ │ ├── startPost.js
│ │ └── startPre.js
├── start.html
├── start_c_1.html
├── start_g_0.html
└── systerm.html
├── ts-babel
├── .babelrc
├── .gitignore
├── README.md
├── package.json
├── src
│ ├── index.ts
│ └── math.ts
├── test
│ └── math.test.ts
└── tsconfig.json
├── ts-base
├── .eslintrc.json
├── .gitignore
├── README.md
├── build
│ ├── webpack.base.config.js
│ ├── webpack.config.js
│ ├── webpack.dev.config.js
│ └── webpack.pro.config.js
├── jest.config.js
├── package.json
├── src
│ ├── index.ts
│ ├── math.ts
│ ├── part1.base
│ │ ├── 05.datatype.ts
│ │ ├── 06.enum.ts
│ │ ├── 07-08.interface.ts
│ │ ├── 09.function.ts
│ │ ├── 10-11.class.ts
│ │ ├── 12.class-interface.ts
│ │ ├── 13-14.generics.ts
│ │ ├── 15.inference.ts
│ │ ├── 16.compatible.ts
│ │ ├── 17.guards.ts
│ │ ├── 18.advanced-1.ts
│ │ ├── 19.advanced-2.ts
│ │ ├── 20.advanced-3.ts
│ │ └── 21.advanced-4.ts
│ ├── part2.project
│ │ ├── 01.module
│ │ │ ├── es6
│ │ │ │ ├── a.ts
│ │ │ │ ├── b.ts
│ │ │ │ ├── c.ts
│ │ │ │ └── d.ts
│ │ │ └── node
│ │ │ │ ├── a.node.ts
│ │ │ │ ├── b.node.ts
│ │ │ │ └── c.node.ts
│ │ ├── 02.namespace
│ │ │ ├── a.ts
│ │ │ └── b.ts
│ │ ├── 03.merge
│ │ │ └── merge.ts
│ │ ├── 04.libs
│ │ │ ├── global-lib.d.ts
│ │ │ ├── global-lib.js
│ │ │ ├── index.ts
│ │ │ ├── module-lib.d.ts
│ │ │ ├── module-lib.js
│ │ │ ├── umd-lib.d.ts
│ │ │ └── umd-lib.js
│ │ ├── 06.tsconfig
│ │ │ └── tsconfig.json
│ │ └── 07.project-references
│ │ │ ├── new
│ │ │ ├── src
│ │ │ │ ├── client
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── tsconfig.json
│ │ │ │ ├── common
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── tsconfig.json
│ │ │ │ └── server
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── tsconfig.json
│ │ │ ├── test
│ │ │ │ ├── client.test.ts
│ │ │ │ ├── server.test.ts
│ │ │ │ └── tsconfig.json
│ │ │ └── tsconfig.json
│ │ │ └── old
│ │ │ ├── src
│ │ │ ├── client
│ │ │ │ └── index.ts
│ │ │ ├── common
│ │ │ │ └── index.ts
│ │ │ └── server
│ │ │ │ └── index.ts
│ │ │ ├── test
│ │ │ ├── client.test.ts
│ │ │ └── server.test.ts
│ │ │ └── tsconfig.json
│ └── tpl
│ │ └── index.html
├── test
│ └── math.test.ts
└── tsconfig.json
├── ts-express
├── .gitignore
├── README.md
├── app.ts
├── bin
│ └── server.ts
├── config
│ └── db.ts
├── copyStatic.ts
├── employee.sql
├── models
│ └── query.ts
├── package.json
├── public
│ └── stylesheets
│ │ └── style.css
├── routes
│ ├── employee.ts
│ ├── excel-export.d.ts
│ ├── index.ts
│ └── users.ts
├── tsconfig.json
└── views
│ ├── error.jade
│ ├── index.jade
│ └── layout.jade
├── ts-react-app
├── .gitignore
├── README.md
├── config-overrides.js
├── mock
│ └── employee
│ │ └── getEmployee.json
├── package.json
├── public
│ ├── favicon.ico
│ └── index.html
├── src
│ ├── components
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── demo
│ │ │ ├── Hello.tsx
│ │ │ ├── HelloClass.tsx
│ │ │ ├── HelloHOC.tsx
│ │ │ └── HelloHooks.tsx
│ │ ├── employee
│ │ │ ├── QueryForm.tsx
│ │ │ ├── colums.tsx
│ │ │ ├── index.css
│ │ │ └── index.tsx
│ │ └── setting
│ │ │ ├── index.css
│ │ │ └── index.tsx
│ ├── constants
│ │ └── urls.ts
│ ├── index.tsx
│ ├── interface
│ │ └── employee.ts
│ ├── react-app-env.d.ts
│ ├── routers
│ │ └── index.tsx
│ ├── setupProxy.js
│ └── utils
│ │ └── request.ts
└── tsconfig.json
├── ts-react
├── .gitignore
├── README.md
├── build
│ ├── webpack.base.config.js
│ ├── webpack.config.js
│ ├── webpack.dev.config.js
│ └── webpack.pro.config.js
├── package.json
├── src
│ ├── components
│ │ └── Hello.tsx
│ ├── index.tsx
│ └── tpl
│ │ └── index.html
└── tsconfig.json
├── ts-redux
├── .gitignore
├── README.md
├── config-overrides.js
├── mock
│ └── employee
│ │ ├── createEmployee.json
│ │ ├── deleteEmployee.json
│ │ ├── getEmployee.json
│ │ └── updateEmployee.json
├── package.json
├── public
│ ├── favicon.ico
│ └── index.html
├── src
│ ├── components
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── employee
│ │ │ ├── InfoModal.tsx
│ │ │ ├── QueryForm.tsx
│ │ │ ├── colums.tsx
│ │ │ ├── index.css
│ │ │ └── index.tsx
│ │ └── setting
│ │ │ ├── index.css
│ │ │ └── index.tsx
│ ├── constants
│ │ ├── actions.ts
│ │ ├── options.ts
│ │ └── urls.ts
│ ├── index.tsx
│ ├── interface
│ │ └── employee.ts
│ ├── react-app-env.d.ts
│ ├── redux
│ │ ├── employee
│ │ │ └── index.ts
│ │ ├── rootReducer.ts
│ │ └── store.ts
│ ├── routers
│ │ └── index.tsx
│ ├── setupProxy.js
│ └── utils
│ │ └── request.ts
└── tsconfig.json
├── ts-vue
├── .gitignore
├── README.md
├── build
│ ├── webpack.base.config.js
│ ├── webpack.config.js
│ ├── webpack.dev.config.js
│ └── webpack.pro.config.js
├── package.json
├── src
│ ├── components
│ │ └── Hello.vue
│ ├── index.ts
│ ├── tpl
│ │ └── index.html
│ └── vue-shims.d.ts
└── tsconfig.json
└── vue-employee-query
├── .gitignore
├── README.md
├── build
├── webpack.base.config.js
├── webpack.config.js
├── webpack.dev.config.js
└── webpack.pro.config.js
├── dist
└── employee-query.js
├── package.json
├── src
├── components
│ └── EmployeeQuery.vue
├── index.ts
├── main.ts
├── tpl
│ └── index.html
└── vue-shims.d.ts
├── tsconfig.json
└── types
└── employee-query.d.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 |
--------------------------------------------------------------------------------
/CB834301747.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/CB834301747.jpeg
--------------------------------------------------------------------------------
/QuanZhanXiuLian.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/QuanZhanXiuLian.png
--------------------------------------------------------------------------------
/blog-gitbook/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /vuepress/node_modules
6 |
7 |
8 |
--------------------------------------------------------------------------------
/blog-gitbook/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | * [简介](README.md)
4 | * [GitHub 吸星大法](./views/github/follow.md)
5 | * [GitHub 挖宝技巧](./views/github/star.md)
6 |
8 | * Vue.js
9 | * [Vue + TS + El 搭建博客及踩坑记](./views/vue/vue-ts.md)
10 | * JavaScript 数据结构与算法之美
11 | * [时间和空间复杂度](./views/algorithms/js-time-space.md)
12 | * [十大经典排序算法](./views/algorithms/js-10algo.md)
13 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /vuepress/node_modules
6 |
7 |
8 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/fonts/fontawesome/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/fonts/fontawesome/FontAwesome.otf
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-anchor-navigation-ex/lib/log.js:
--------------------------------------------------------------------------------
1 | var colors = require('colors');
2 | colors.setTheme({
3 | silly: 'rainbow',
4 | input: 'grey',
5 | verbose: 'cyan',
6 | prompt: 'grey',
7 | info: 'green',
8 | data: 'grey',
9 | help: 'cyan',
10 | warn: 'yellow',
11 | debug: 'blue',
12 | error: 'red'
13 | });
14 |
15 | module.exports = colors;
16 |
17 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-baidu-tongji/plugin.js:
--------------------------------------------------------------------------------
1 | require(["gitbook"], function(gitbook) {
2 | gitbook.events.bind("start", function(e, config) {
3 | config["baidu-tongji"] = config["baidu-tongji"] || {};
4 | var hm = document.createElement('script');
5 | hm.src =config["baidu-tongji"].url+'?' + config["baidu-tongji"].token;
6 | var s = document.getElementsByTagName('script')[0];
7 | s.parentNode.insertBefore(hm, s);
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css:
--------------------------------------------------------------------------------
1 | .book .book-summary .chapter > .articles {
2 | overflow: hidden;
3 | max-height: 0px;
4 | }
5 |
6 | .book .book-summary .chapter.expanded > .articles {
7 | max-height: 9999px;
8 | }
9 |
10 | .book .book-summary .exc-trigger {
11 | position: absolute;
12 | left: 12px;
13 | top: 12px;
14 | }
15 |
16 | .book .book-summary ul.summary li a,
17 | .book .book-summary ul.summary li span {
18 | padding-left: 30px;
19 | cursor: pointer;
20 | }
21 |
22 | .book .book-summary .exc-trigger:before {
23 | content: "\f054";
24 | }
25 |
26 | .book .book-summary .expanded > a .exc-trigger:before,
27 | .book .book-summary .expanded > span .exc-trigger:before {
28 | content: "\f078";
29 | }
30 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-search-pro/search.css:
--------------------------------------------------------------------------------
1 | /*
2 | This CSS only styled the search results section, not the search input
3 | It defines the basic interraction to hide content when displaying results, etc
4 | */
5 | #book-search-input {
6 | background: inherit;
7 | }
8 | #book-search-results .search-results {
9 | display: none;
10 | }
11 | #book-search-results .search-results ul.search-results-list {
12 | list-style-type: none;
13 | padding-left: 0;
14 | }
15 | #book-search-results .search-results ul.search-results-list li {
16 | margin-bottom: 1.5rem;
17 | padding-bottom: 0.5rem;
18 | /* Highlight results */
19 | }
20 | #book-search-results .search-results ul.search-results-list li p em {
21 | background-color: rgba(255, 220, 0, 0.4);
22 | font-style: normal;
23 | }
24 | #book-search-results .search-results .no-results {
25 | display: none;
26 | }
27 | #book-search-results.open .search-results {
28 | display: block;
29 | }
30 | #book-search-results.open .search-noresults {
31 | display: none;
32 | }
33 | #book-search-results.no-results .search-results .has-results {
34 | display: none;
35 | }
36 | #book-search-results.no-results .search-results .no-results {
37 | display: block;
38 | }
39 | #book-search-results span.search-highlight-keyword {
40 | background: #ff0;
41 | }
42 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-splitter/splitter.css:
--------------------------------------------------------------------------------
1 | .divider-content-summary {
2 | position: absolute;
3 | top: 0;
4 | right: 0;
5 | height: 100%;
6 | width: 5px;
7 | display: table;
8 | cursor: col-resize;
9 | color: #ccc;
10 | -webkit-transition: color 350ms ease;
11 | -moz-transition: color 350ms ease;
12 | -o-transition: color 350ms ease;
13 | transition: color 350ms ease
14 | }
15 | .divider-content-summary:hover {
16 | color: #444;
17 | }
18 | .divider-content-summary__icon {
19 | display: table-cell;
20 | vertical-align: middle;
21 | text-align: center;
22 | }
23 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/gitbook-plugin-tbfed-pagefooter/footer.css:
--------------------------------------------------------------------------------
1 | .page-footer {
2 | margin-top: 50px;
3 | border-top: 1px solid #ccc;
4 | overflow: hidden;
5 | padding: 10px 0;
6 | font-size: 12px;
7 | color: #808080;
8 | }
9 | .page-footer a {
10 | color: #808080!important;
11 | text-decoration: underline!important;
12 | }
13 | .footer-modification {
14 | float: right;
15 | }
16 |
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/images/apple-touch-icon-precomposed-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/images/apple-touch-icon-precomposed-152.png
--------------------------------------------------------------------------------
/blog-gitbook/_book/gitbook/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/_book/gitbook/images/favicon.ico
--------------------------------------------------------------------------------
/blog-gitbook/_book/views/README.md:
--------------------------------------------------------------------------------
1 | # 大前端知识大集合
2 |
3 | 大前端知识大集合。
--------------------------------------------------------------------------------
/blog-gitbook/_book/views/component/gitalk.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
--------------------------------------------------------------------------------
/blog-gitbook/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/blog-gitbook/views/README.md:
--------------------------------------------------------------------------------
1 | # 大前端知识大集合
2 |
3 | 大前端知识大集合。
--------------------------------------------------------------------------------
/blog-gitbook/views/component/gitalk.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
--------------------------------------------------------------------------------
/blog-gitbook/views/public/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/views/public/assets/favicon.ico
--------------------------------------------------------------------------------
/blog-gitbook/views/public/assets/favicon2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/views/public/assets/favicon2.ico
--------------------------------------------------------------------------------
/blog-gitbook/views/public/assets/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/views/public/assets/logo.jpg
--------------------------------------------------------------------------------
/blog-gitbook/views/public/assets/user-logo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/views/public/assets/user-logo.jpeg
--------------------------------------------------------------------------------
/blog-gitbook/views/public/assets/yejintianming.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-gitbook/views/public/assets/yejintianming.png
--------------------------------------------------------------------------------
/blog-vuepress/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /vuepress/node_modules
6 |
7 |
8 |
--------------------------------------------------------------------------------
/blog-vuepress/builds/addComponents.js:
--------------------------------------------------------------------------------
1 | // addComponents.js
2 | const fs = require("fs");
3 | const findMarkdown = require("./findMarkdown");
4 | const rootDir = "./docs";
5 |
6 | findMarkdown(rootDir, writeComponents);
7 |
8 | function writeComponents(dir) {
9 | if (!/README/.test(dir)) {
10 | fs.appendFile(dir, `\n \n \n `, err => {
11 | if (err) throw err;
12 | console.log(`add components to ${dir}`);
13 | });
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/blog-vuepress/builds/delComponents.js:
--------------------------------------------------------------------------------
1 | // delComponents.js
2 | const fs = require("fs");
3 | const findMarkdown = require("./findMarkdown");
4 | const rootDir = "./docs";
5 |
6 | findMarkdown(rootDir, delComponents);
7 |
8 | function delComponents(dir) {
9 | fs.readFile(dir, "utf-8", (err, content) => {
10 | if (err) throw err;
11 |
12 | fs.writeFile(
13 | dir,
14 | content.replace(/\n \n \n /g, ""),
15 | err => {
16 | if (err) throw err;
17 | console.log(`del components from ${dir}`);
18 | }
19 | );
20 | });
21 | }
22 |
--------------------------------------------------------------------------------
/blog-vuepress/builds/findMarkdown.js:
--------------------------------------------------------------------------------
1 | // findMarkdown.js
2 | const fs = require("fs");
3 |
4 | function findMarkdown(dir, callback) {
5 | fs.readdir(dir, function(err, files) {
6 | if (err) throw err;
7 | files.forEach(fileName => {
8 | let innerDir = `${dir}/${fileName}`;
9 | if (fileName.indexOf(".") !== 0) {
10 | fs.stat(innerDir, function(err, stat) {
11 | if (stat.isDirectory()) {
12 | findMarkdown(innerDir, callback);
13 | } else {
14 | // 跳过readme 文件,当然你也可以自行修改
15 | if (/\.md$/.test(fileName) && !/README/.test(fileName))
16 | callback(innerDir);
17 | }
18 | });
19 | }
20 | });
21 | });
22 | }
23 | module.exports = findMarkdown;
24 |
--------------------------------------------------------------------------------
/blog-vuepress/delay.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | # 确保脚本抛出遇到的错误
4 | set -e
5 |
6 | # 生成静态文件
7 | npm run build:md
8 |
9 | # 进入生成的文件夹
10 | cd docs/.vuepress/dist
11 |
12 | # 如果是发布到自定义域名
13 | # echo 'www.example.com' > CNAME
14 |
15 | #创建.nojekyll 防止Github Pages build错误
16 | touch .nojekyll
17 |
18 |
19 | git init
20 | git add -A
21 | git commit -m 'deploy'
22 |
23 | # 如果发布到 https://.github.io
24 | # git push -f git@github.com:/.github.io.git master
25 |
26 | # 如果发布到 https://.github.io/
27 | git push -f https://github.com/biaochenxuying/blog.git master:gh-pages
28 | # git push -f git@github.com:biaochenxuying/blog.git master:gh-pages
29 |
30 | cd -
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/enhanceApp.js:
--------------------------------------------------------------------------------
1 | import { copy, integrateGitalk, baiduTongJi } from './utils';
2 |
3 | export default ({
4 | Vue, // VuePress 正在使用的 Vue 构造函数
5 | options, // 附加到根实例的一些选项
6 | router, // 当前应用的路由实例
7 | siteData // 站点元数据
8 | }) => {
9 | Vue.mixin({
10 | mounted: function () {
11 | if (!window.init) {
12 | copy()
13 | window.init = 1;
14 | }
15 | // setTimeout(() => {
16 | // if (!window.init) {
17 | // // baiduTongJi(router, () => { document.getElementById('referrer').setAttribute("content", "never"); })
18 | // document.getElementById('referrer').setAttribute("content", "never");
19 | // window.init = 1;
20 | // }
21 | // }, 500)
22 | }
23 | });
24 |
25 | }
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/public/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-vuepress/docs/.vuepress/public/assets/favicon.ico
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/public/assets/favicon2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-vuepress/docs/.vuepress/public/assets/favicon2.ico
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/public/assets/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-vuepress/docs/.vuepress/public/assets/logo.jpg
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/public/assets/user-logo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-vuepress/docs/.vuepress/public/assets/user-logo.jpeg
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/public/assets/yejintianming.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/blog-vuepress/docs/.vuepress/public/assets/yejintianming.png
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/styles/index.styl:
--------------------------------------------------------------------------------
1 | .getting-started .outbound,
2 | .nav-links .outbound {
3 | display: none !important;
4 | }
5 |
6 | .getting-started a img {
7 | margin-right: 8px !important;
8 | }
9 |
10 | .getting-started a img.no-margin {
11 | margin-right: 0px !important;
12 | }
13 |
14 | //global
15 | p code {
16 | // color: #e96900!important;
17 | // background-color: #f8f8f8!important;
18 | // margin: 0 2px!important;
19 | // padding: 0.25rem 0.4rem!important;
20 | }
21 |
22 | .page p img {
23 | /* 图片居中 */
24 | margin: 0 auto;
25 | display: flex;
26 | }
27 |
28 | .page p a img {
29 | margin: 0;
30 | display: inline-block;
31 | }
32 |
33 | blockquote {
34 | font-size: 15px !important;
35 | color: #858585 !important;
36 | border-left: 0.25rem solid #42b983 !important;
37 | font-weight: 1000 !important;
38 | }
39 |
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/templates/dev.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 全栈修炼
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/blog-vuepress/docs/.vuepress/templates/ssr.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | {{ title }}
9 |
10 | {{{ userHeadTags }}}
11 | {{{ pageMeta }}}
12 | {{{ renderResourceHints() }}}
13 | {{{ renderStyles() }}}
14 |
15 |
16 |
17 | {{{ renderScripts() }}}
18 |
19 |
--------------------------------------------------------------------------------
/blog-vuepress/docs/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | home: true
3 | heroImage: /assets/logo.jpg
4 | heroText: 夜尽天明
5 | tagline: 芳华正茂始少年,时光正好,未来可期 !
6 | actionText: 开始围观 →
7 | actionLink: /guide/
8 | sidebarDepth: 2
9 | features:
10 | - title: 大前端
11 | details: 大前端技术为主,主要以 Vue + TypeScript 技术栈为主。
12 | - title: 读书、笔记
13 | details: 读万卷书,行万里路,遇见最好的自己。
14 | - title: 理财
15 | details: 人人都应该懂点理财知识,越早懂得越好。
16 | footer: MIT Licensed | Copyright © 2019-present biaochenxuying
17 | ---
18 |
--------------------------------------------------------------------------------
/blog-vuepress/docs/en/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | home: true
3 | heroImage: /assets/logo.jpg
4 | heroText: Full stack exercise
5 | tagline: Full stack exercise
6 | actionText: get start →
7 | actionLink: /zh/guide/
8 | sidebarDepth: 2
9 | features:
10 | - title: Large front end
11 | details: Large front-end technology。
12 | - title: Reading and notes
13 | details: Read thousands of books, travel thousands of miles, meet the best of their own.
14 | - title: Conduct financial transactions
15 | details: Everyone should know something about financial management。
16 | footer: MIT Licensed | Copyright © 2019-present biaochenxuying
17 | ---
--------------------------------------------------------------------------------
/blog-vuepress/docs/views/README.md:
--------------------------------------------------------------------------------
1 | # 大前端知识大集合
2 |
3 | 大前端知识大集合。
--------------------------------------------------------------------------------
/blog-vuepress/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "blog",
3 | "version": "1.0.0",
4 | "description": "blog",
5 | "main": "index.js",
6 | "scripts": {
7 | "dev": "vuepress dev docs",
8 | "dev:md": "node ./builds/addComponents.js && vuepress dev docs && node ./builds/delComponents.js",
9 | "docs:dev": "vuepress dev docs",
10 | "build": "vuepress build docs",
11 | "build:md": "node ./builds/addComponents.js && vuepress build docs && node ./builds/delComponents.js",
12 | "docs:build": "vuepress build docs",
13 | "delay": "bash delay.sh",
14 | "test": "echo \"Error: no test specified\" && exit 1"
15 | },
16 | "author": "biaochenxuying",
17 | "license": "ISC",
18 | "devDependencies": {
19 | "@vuepress/plugin-active-header-links": "^1.2.0",
20 | "@vuepress/plugin-back-to-top": "^1.2.0",
21 | "@vuepress/plugin-google-analytics": "^1.2.0",
22 | "@vuepress/plugin-medium-zoom": "^1.2.0",
23 | "@vuepress/plugin-nprogress": "^1.2.0",
24 | "@vuepress/plugin-pwa": "^1.2.0",
25 | "vuepress": "^1.2.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/data-structure-and-algorithms/0. arr.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | JavaScript 数据结构与算法之美 - 数组
8 |
9 |
10 |
30 |
31 |
--------------------------------------------------------------------------------
/data-structure-and-algorithms/13. selection-sort.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | JavaScript 数据结构与算法之美 - 选择排序
8 |
9 |
10 |
40 |
41 |
--------------------------------------------------------------------------------
/images/CB834301747.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/CB834301747.jpeg
--------------------------------------------------------------------------------
/images/FrontEndGitHub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/FrontEndGitHub.png
--------------------------------------------------------------------------------
/images/FrontEndGitHubLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/FrontEndGitHubLogo.png
--------------------------------------------------------------------------------
/images/backend-map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/backend-map.png
--------------------------------------------------------------------------------
/images/devops-map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/devops-map.png
--------------------------------------------------------------------------------
/images/frontend-map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/images/frontend-map.png
--------------------------------------------------------------------------------
/resume/resume.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/resume/resume.pdf
--------------------------------------------------------------------------------
/typescript-in-action/README.md:
--------------------------------------------------------------------------------
1 | 极客时间上的《TypeScript 开发实战》课程资源
2 | =====================
3 |
4 | * mindmap:思维导图
5 | * ppt:课件
6 | * sourcecode:源代码
7 |
--------------------------------------------------------------------------------
/typescript-in-action/mindmap/全部课程.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/mindmap/全部课程.jpg
--------------------------------------------------------------------------------
/typescript-in-action/mindmap/基础篇.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/mindmap/基础篇.jpg
--------------------------------------------------------------------------------
/typescript-in-action/mindmap/实战篇.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/mindmap/实战篇.jpg
--------------------------------------------------------------------------------
/typescript-in-action/mindmap/工程篇.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/mindmap/工程篇.jpg
--------------------------------------------------------------------------------
/typescript-in-action/ppt/《TypeScript开发实战》课件.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/ppt/《TypeScript开发实战》课件.pdf
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/env",
4 | "@babel/preset-react"
5 | ],
6 | "plugins": [
7 | "@babel/proposal-class-properties",
8 | "@babel/proposal-object-rest-spread"
9 | ]
10 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/README.md:
--------------------------------------------------------------------------------
1 | 实战篇 渐进式迁移策略
2 | ===============
3 |
4 | JavaScript 原始工程
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: {
5 | 'app': './src/index.jsx'
6 | },
7 | output: {
8 | filename: '[name].[chunkhash:8].js'
9 | },
10 | resolve: {
11 | extensions: ['.js', '.jsx']
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.jsx?$/,
17 | use: [{
18 | loader: 'babel-loader'
19 | }],
20 | exclude: /node_modules/
21 | }
22 | ]
23 | },
24 | plugins: [
25 | new HtmlWebpackPlugin({
26 | template: './src/tpl/index.html'
27 | })
28 | ],
29 | optimization: {
30 | splitChunks: {
31 | chunks: 'all'
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map',
3 | devServer: {
4 | port: 8080
5 | }
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "project-migration",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.jsx",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js"
9 | },
10 | "keywords": [
11 | "TypeScript"
12 | ],
13 | "author": "liangxiao",
14 | "license": "ISC",
15 | "devDependencies": {
16 | "@babel/core": "^7.5.5",
17 | "@babel/plugin-proposal-class-properties": "^7.5.5",
18 | "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
19 | "@babel/preset-env": "^7.5.5",
20 | "@babel/preset-react": "^7.0.0",
21 | "babel-loader": "^8.0.6",
22 | "clean-webpack-plugin": "^3.0.0",
23 | "html-webpack-plugin": "^3.2.0",
24 | "webpack": "^4.39.2",
25 | "webpack-cli": "^3.3.2",
26 | "webpack-dev-server": "^3.5.1",
27 | "webpack-merge": "^4.2.1"
28 | },
29 | "dependencies": {
30 | "react": "^16.9.0",
31 | "react-dom": "^16.9.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/src/components/Hello.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | class Hello extends Component {
5 | state = {
6 | count: 0
7 | }
8 | static defaultProps = {
9 | firstName: '',
10 | lastName: ''
11 | }
12 | render() {
13 | return (
14 | <>
15 | 你点击了 {this.state.count} 次
16 |
19 | >
20 | )
21 | }
22 | }
23 | Hello.propTypes = {
24 | name: PropTypes.string.isRequired,
25 | firstName: PropTypes.string,
26 | lastName: PropTypes.string
27 | }
28 |
29 | export default Hello;
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/src/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import Hello from './components/Hello';
5 |
6 | import { add } from './utils/a';
7 |
8 | add(1, 1)
9 |
10 | ReactDOM.render(
11 |
12 |
13 |
,
14 | document.querySelectorAll('.app')[0]
15 | );
16 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Project Migration
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-0/src/utils/a.js:
--------------------------------------------------------------------------------
1 | export function add(x, y) {
2 | return x + y
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/env",
4 | "@babel/preset-react",
5 | "@babel/preset-typescript"
6 | ],
7 | "plugins": [
8 | "@babel/proposal-class-properties",
9 | "@babel/proposal-object-rest-spread"
10 | ]
11 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/README.md:
--------------------------------------------------------------------------------
1 | 实战篇 渐进式迁移策略
2 | ===============
3 |
4 | JavaScript + TypeScript 共存策略
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: {
5 | 'app': './src/index.jsx'
6 | },
7 | output: {
8 | filename: '[name].[chunkhash:8].js'
9 | },
10 | resolve: {
11 | extensions: ['.js', '.jsx', '.ts', '.tsx']
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.(j|t)sx?$/,
17 | use: [{
18 | loader: 'babel-loader'
19 | }],
20 | exclude: /node_modules/
21 | }
22 | ]
23 | },
24 | plugins: [
25 | new HtmlWebpackPlugin({
26 | template: './src/tpl/index.html'
27 | })
28 | ],
29 | optimization: {
30 | splitChunks: {
31 | chunks: 'all'
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map',
3 | devServer: {
4 | port: 8080
5 | }
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "project-migration",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.jsx",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js",
9 | "type-check": "tsc --watch"
10 | },
11 | "keywords": [
12 | "TypeScript"
13 | ],
14 | "author": "liangxiao",
15 | "license": "ISC",
16 | "devDependencies": {
17 | "@babel/core": "^7.5.5",
18 | "@babel/plugin-proposal-class-properties": "^7.5.5",
19 | "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
20 | "@babel/preset-env": "^7.5.5",
21 | "@babel/preset-react": "^7.0.0",
22 | "@babel/preset-typescript": "^7.3.3",
23 | "@types/react": "^16.9.2",
24 | "@types/react-dom": "^16.8.5",
25 | "babel-loader": "^8.0.6",
26 | "clean-webpack-plugin": "^3.0.0",
27 | "html-webpack-plugin": "^3.2.0",
28 | "ts-loader": "^6.0.4",
29 | "typescript": "^3.5.3",
30 | "webpack": "^4.39.2",
31 | "webpack-cli": "^3.3.2",
32 | "webpack-dev-server": "^3.5.1",
33 | "webpack-merge": "^4.2.1"
34 | },
35 | "dependencies": {
36 | "react": "^16.9.0",
37 | "react-dom": "^16.9.0"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/components/Hello.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | class Hello extends Component {
5 | state = {
6 | count: 0
7 | }
8 | static defaultProps = {
9 | firstName: '',
10 | lastName: ''
11 | }
12 | render() {
13 | return (
14 | <>
15 | 你点击了 {this.state.count} 次
16 |
19 | >
20 | )
21 | }
22 | }
23 | Hello.propTypes = {
24 | name: PropTypes.string.isRequired,
25 | firstName: PropTypes.string,
26 | lastName: PropTypes.string
27 | }
28 |
29 | export default Hello;
30 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/components/Hi.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | interface Props {
4 | name: string;
5 | firstName?: string;
6 | lastName?: string;
7 | }
8 | interface State {
9 | count: number
10 | }
11 |
12 | class Hi extends Component {
13 | state = {
14 | count: 0
15 | }
16 | static defaultProps = {
17 | firstName: '',
18 | lastName: ''
19 | }
20 | render() {
21 | return (
22 | <>
23 | 你点击了 {this.state.count} 次
24 |
27 | >
28 | )
29 | }
30 | }
31 |
32 | export default Hi;
33 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import Hello from './components/Hello';
5 | import Hi from './components/Hi';
6 |
7 | import { add } from './utils/a';
8 | import { sub } from './utils/b';
9 |
10 | add(1, 1)
11 | sub(1, 1)
12 |
13 | ReactDOM.render(
14 |
15 |
16 |
17 |
,
18 | document.querySelectorAll('.app')[0]
19 | );
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Project Migration
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/utils/a.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @param {number} x - x
3 | * @param {number} y - y
4 | */
5 | export function add(x, y) {
6 | return x + y
7 | }
8 |
9 | // add(1, '2')
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-1/src/utils/b.ts:
--------------------------------------------------------------------------------
1 | export function sub(x: number, y: number) {
2 | return x - y
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/env",
4 | "@babel/preset-react",
5 | "@babel/preset-typescript"
6 | ],
7 | "plugins": [
8 | "@babel/proposal-class-properties",
9 | "@babel/proposal-object-rest-spread"
10 | ]
11 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/README.md:
--------------------------------------------------------------------------------
1 | 实战篇 渐进式迁移策略
2 | ===============
3 |
4 | JavaScript to TypeScript 宽松策略
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: {
5 | 'app': './src/index.tsx'
6 | },
7 | output: {
8 | filename: '[name].[chunkhash:8].js'
9 | },
10 | resolve: {
11 | extensions: ['.js', '.jsx', '.ts', '.tsx']
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.(j|t)sx?$/,
17 | use: [{
18 | loader: 'babel-loader'
19 | }],
20 | exclude: /node_modules/
21 | }
22 | ]
23 | },
24 | plugins: [
25 | new HtmlWebpackPlugin({
26 | template: './src/tpl/index.html'
27 | })
28 | ],
29 | optimization: {
30 | splitChunks: {
31 | chunks: 'all'
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map',
3 | devServer: {
4 | port: 8080
5 | }
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "project-migration",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.tsx",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js",
9 | "type-check": "tsc --watch",
10 | "rename-js": "ts-node renameJS.ts"
11 | },
12 | "keywords": [
13 | "TypeScript"
14 | ],
15 | "author": "liangxiao",
16 | "license": "ISC",
17 | "devDependencies": {
18 | "@babel/core": "^7.5.5",
19 | "@babel/plugin-proposal-class-properties": "^7.5.5",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
21 | "@babel/preset-env": "^7.5.5",
22 | "@babel/preset-react": "^7.0.0",
23 | "@babel/preset-typescript": "^7.3.3",
24 | "@types/react": "^16.9.2",
25 | "@types/react-dom": "^16.8.5",
26 | "@types/shelljs": "^0.8.5",
27 | "babel-loader": "^8.0.6",
28 | "clean-webpack-plugin": "^3.0.0",
29 | "html-webpack-plugin": "^3.2.0",
30 | "shelljs": "^0.8.3",
31 | "ts-loader": "^6.0.4",
32 | "ts-node": "^8.3.0",
33 | "typescript": "^3.5.3",
34 | "webpack": "^4.39.2",
35 | "webpack-cli": "^3.3.2",
36 | "webpack-dev-server": "^3.5.1",
37 | "webpack-merge": "^4.2.1"
38 | },
39 | "dependencies": {
40 | "react": "^16.9.0",
41 | "react-dom": "^16.9.0"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/renameJS.ts:
--------------------------------------------------------------------------------
1 | import * as shelljs from 'shelljs';
2 |
3 | shelljs.find('src')
4 | .filter(file => file.match(/\.jsx?$/))
5 | .forEach(file => {
6 | let newName = file.replace(/\.j(sx?)$/, '.t$1');
7 | shelljs.mv(file, newName);
8 | });
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/components/Hello.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | class Hello extends Component {
5 | state = {
6 | count: 0
7 | }
8 | static defaultProps = {
9 | firstName: '',
10 | lastName: ''
11 | }
12 | render() {
13 | return (
14 | <>
15 | 你点击了 {this.state.count} 次
16 |
19 | >
20 | )
21 | }
22 | }
23 | Hello.propTypes = {
24 | name: PropTypes.string.isRequired,
25 | firstName: PropTypes.string,
26 | lastName: PropTypes.string
27 | }
28 |
29 | export default Hello;
30 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/components/Hi.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | interface Props {
4 | name: string;
5 | firstName?: string;
6 | lastName?: string;
7 | }
8 | interface State {
9 | count: number
10 | }
11 |
12 | class Hi extends Component {
13 | state = {
14 | count: 0
15 | }
16 | static defaultProps = {
17 | firstName: '',
18 | lastName: ''
19 | }
20 | render() {
21 | return (
22 | <>
23 | 你点击了 {this.state.count} 次
24 |
27 | >
28 | )
29 | }
30 | }
31 |
32 | export default Hi;
33 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import Hello from './components/Hello';
5 | import Hi from './components/Hi';
6 |
7 | import { add } from './utils/a';
8 | import { sub } from './utils/b';
9 |
10 | add(1, 1)
11 | sub(1, 1)
12 |
13 | ReactDOM.render(
14 |
15 |
16 |
17 |
,
18 | document.querySelectorAll('.app')[0]
19 | );
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Project Migration
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/utils/a.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @param {number} x - x
3 | * @param {number} y - y
4 | */
5 | export function add(x, y) {
6 | return x + y
7 | }
8 |
9 | // add(1, '2')
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-2/src/utils/b.ts:
--------------------------------------------------------------------------------
1 | export function sub(x: number, y: number) {
2 | return x - y
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/env",
4 | "@babel/preset-react",
5 | "@babel/preset-typescript"
6 | ],
7 | "plugins": [
8 | "@babel/proposal-class-properties",
9 | "@babel/proposal-object-rest-spread"
10 | ]
11 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/README.md:
--------------------------------------------------------------------------------
1 | 实战篇 渐进式迁移策略
2 | ===============
3 |
4 | TypeScript 严格策略
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: {
5 | 'app': './src/index.tsx'
6 | },
7 | output: {
8 | filename: '[name].[chunkhash:8].js'
9 | },
10 | resolve: {
11 | extensions: ['.js', '.jsx', '.ts', '.tsx']
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.(j|t)sx?$/,
17 | use: [{
18 | loader: 'babel-loader'
19 | }],
20 | exclude: /node_modules/
21 | }
22 | ]
23 | },
24 | plugins: [
25 | new HtmlWebpackPlugin({
26 | template: './src/tpl/index.html'
27 | })
28 | ],
29 | optimization: {
30 | splitChunks: {
31 | chunks: 'all'
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map',
3 | devServer: {
4 | port: 8080
5 | }
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "project-migration",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.tsx",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js",
9 | "type-check": "tsc --watch",
10 | "rename-js": "ts-node renameJS.ts"
11 | },
12 | "keywords": [
13 | "TypeScript"
14 | ],
15 | "author": "liangxiao",
16 | "license": "ISC",
17 | "devDependencies": {
18 | "@babel/core": "^7.5.5",
19 | "@babel/plugin-proposal-class-properties": "^7.5.5",
20 | "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
21 | "@babel/preset-env": "^7.5.5",
22 | "@babel/preset-react": "^7.0.0",
23 | "@babel/preset-typescript": "^7.3.3",
24 | "@types/react": "^16.9.2",
25 | "@types/react-dom": "^16.8.5",
26 | "@types/shelljs": "^0.8.5",
27 | "babel-loader": "^8.0.6",
28 | "clean-webpack-plugin": "^3.0.0",
29 | "html-webpack-plugin": "^3.2.0",
30 | "shelljs": "^0.8.3",
31 | "ts-loader": "^6.0.4",
32 | "ts-node": "^8.3.0",
33 | "typescript": "^3.5.3",
34 | "webpack": "^4.39.2",
35 | "webpack-cli": "^3.3.2",
36 | "webpack-dev-server": "^3.5.1",
37 | "webpack-merge": "^4.2.1"
38 | },
39 | "dependencies": {
40 | "react": "^16.9.0",
41 | "react-dom": "^16.9.0"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/renameJS.ts:
--------------------------------------------------------------------------------
1 | import * as shelljs from 'shelljs';
2 |
3 | shelljs.find('src')
4 | .filter(file => file.match(/\.jsx?$/))
5 | .forEach(file => {
6 | let newName = file.replace(/\.j(sx?)$/, '.t$1');
7 | shelljs.mv(file, newName);
8 | });
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/components/Hello.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | interface Props {
4 | name: string;
5 | firstName?: string;
6 | lastName?: string;
7 | }
8 | interface State {
9 | count: number
10 | }
11 |
12 | class Hello extends Component {
13 | state = {
14 | count: 0
15 | }
16 | static defaultProps = {
17 | firstName: '',
18 | lastName: ''
19 | }
20 | render() {
21 | return (
22 | <>
23 | 你点击了 {this.state.count} 次
24 |
27 | >
28 | )
29 | }
30 | }
31 |
32 | export default Hello;
33 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/components/Hi.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | interface Props {
4 | name: string;
5 | firstName?: string;
6 | lastName?: string;
7 | }
8 | interface State {
9 | count: number
10 | }
11 |
12 | class Hi extends Component {
13 | state = {
14 | count: 0
15 | }
16 | static defaultProps = {
17 | firstName: '',
18 | lastName: ''
19 | }
20 | render() {
21 | return (
22 | <>
23 | 你点击了 {this.state.count} 次
24 |
27 | >
28 | )
29 | }
30 | }
31 |
32 | export default Hi;
33 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import Hello from './components/Hello';
5 | import Hi from './components/Hi';
6 |
7 | import { add } from './utils/a';
8 | import { sub } from './utils/b';
9 |
10 | add(1, 1)
11 | sub(1, 1)
12 |
13 | ReactDOM.render(
14 |
15 |
16 |
17 |
,
18 | document.querySelectorAll('.app')[0]
19 | );
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Project Migration
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/utils/a.ts:
--------------------------------------------------------------------------------
1 | export function add(x: number, y: number) {
2 | return x + y
3 | }
4 |
5 | // add(1, '2')
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/project-migration/stage-3/src/utils/b.ts:
--------------------------------------------------------------------------------
1 | export function sub(x: number, y: number) {
2 | return x - y
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u10.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u11.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u14.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u15.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u18.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u22.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u29.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/images/employee/u7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/images/employee/u7.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/reset.svg:
--------------------------------------------------------------------------------
1 |
2 |
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/reset_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_off.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/debug/styles/images/variables_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/back_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/footnotes_on.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/forward_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_off.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_off.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/page_notes/styles/images/notes_on.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/079_page_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/079_page_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/086_case_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/086_case_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/225_responsive_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/225_responsive_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/228_togglenotes_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/228_togglenotes_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/229_variables_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/229_variables_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/231_event_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/231_event_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/232_search_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/232_search_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/233_hyperlink_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/233_hyperlink_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/235_folderclosed_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/235_folderclosed_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/236_folderopen_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/236_folderopen_16.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/adaptivecheck.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/adaptivecheck.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/flow.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_closed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_closed.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_closed.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_open.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/folder_open.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/hotspots_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/minus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/minus.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/note.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/note.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/page.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/page.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/plus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/plus.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/share_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_off.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/sitemap_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_on.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/plugins/sitemap/styles/images/views_on.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/prototype.rp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/prototype.rp
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/Other.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/allow-access.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/allow-access.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/axure-chrome-extension.crx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/axure-chrome-extension.crx
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/axure_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/axure_logo.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/details.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/extensions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/extensions.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/safari_advanced.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/safari_advanced.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/safari_restrictions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/safari_restrictions.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/splitter.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/splitter.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/chrome/splitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/chrome/splitter.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/newwindow.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/newwindow.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/note.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/note.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_flat_0_aaaaaa_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_flat_0_aaaaaa_40x100.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_glass_75_ffffff_1x400.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/css/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/css/reset.css:
--------------------------------------------------------------------------------
1 | html,body,div,span,
2 | applet,object,iframe,
3 | h1,h2,h3,h4,h5,h6,p,blockquote,pre,
4 | a,abbr,acronym,address,big,cite,code,
5 | del,dfn,em,font,img,ins,kbd,q,s,samp,
6 | small,strike,strong,sub,sup,tt,var,
7 | dd,dl,dt,li,ol,ul,
8 | fieldset,form,label,legend,
9 | table,caption,tbody,tfoot,thead,tr,th,td {
10 | margin: 0;
11 | padding: 0;
12 | border: 0;
13 | }
14 | table {
15 | border-collapse: collapse;
16 | border-spacing: 0;
17 | }
18 | ol,ul {
19 | list-style: none;
20 | }
21 | q:before,q:after,
22 | blockquote:before,blockquote:after {
23 | content: "";
24 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/259_close_12rollover1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/259_close_12rollover1.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/259_close_12rollover2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/259_close_12rollover2.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/260_collapse_12rollover1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/260_collapse_12rollover1.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/260_collapse_12rollover2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/260_collapse_12rollover2.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/261_expand_12rollover1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/261_expand_12rollover1.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/261_expand_12rollover2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/261_expand_12rollover2.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/close.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/close.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/close_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/close_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/close_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/divider.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/divider.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/divider.svg:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/expand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/expand.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/expand.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/expand_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/expand_hover.png
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/expand_hover.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/images/transparent.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/prototype/resources/images/transparent.gif
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/resources/reload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/start_c_1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/prototype/start_g_0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/env",
4 | "@babel/preset-typescript"
5 | ],
6 | "plugins": [
7 | "@babel/proposal-class-properties",
8 | "@babel/proposal-object-rest-spread"
9 | ]
10 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/README.md:
--------------------------------------------------------------------------------
1 | 工程篇(08、10节)代码
2 | =====================
3 |
4 | Babel + TypeScript + Jest
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts_babel",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.ts",
6 | "scripts": {
7 | "build": "babel src --out-dir dist --extensions \".ts,.tsx\"",
8 | "type-check": "tsc --watch",
9 | "test": "jest"
10 | },
11 | "keywords": [
12 | "TypeScript",
13 | "Babel"
14 | ],
15 | "author": "liangxiao",
16 | "license": "ISC",
17 | "devDependencies": {
18 | "@babel/cli": "^7.4.4",
19 | "@babel/core": "^7.4.5",
20 | "@babel/plugin-proposal-class-properties": "^7.4.4",
21 | "@babel/plugin-proposal-object-rest-spread": "^7.4.4",
22 | "@babel/preset-env": "^7.4.5",
23 | "@babel/preset-typescript": "^7.3.3",
24 | "@types/jest": "^24.0.15",
25 | "@types/node": "^12.7.2",
26 | "babel-jest": "^24.8.0",
27 | "jest": "^24.8.0",
28 | "typescript": "^3.5.2"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/src/index.ts:
--------------------------------------------------------------------------------
1 | class A {
2 | a: number = 1
3 | }
4 |
5 | let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }
6 | let n = { x, y, ...z }
7 |
8 | // n = 1
9 |
10 | // 1
11 | // namespace N {
12 | // export const n = 1
13 | // }
14 |
15 | // 2
16 | // let s = {}
17 | let s = {} as A
18 | s.a = 1
19 |
20 | // 3
21 | // const enum E { A, B }
22 |
23 | // 4
24 | // export = s
25 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/src/math.ts:
--------------------------------------------------------------------------------
1 | function add(a: number, b: number) {
2 | return a + b;
3 | }
4 |
5 | function sub(a: number, b: number) {
6 | return a - b;
7 | }
8 |
9 | module.exports = {
10 | add,
11 | sub
12 | }
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-babel/test/math.test.ts:
--------------------------------------------------------------------------------
1 | const math = require('../src/math');
2 |
3 | test('add: 1 + 2 = 3', () => {
4 | expect(math.add(1, 2)).toBe(3);
5 | });
6 |
7 | test('sub: 1 - 2 = -1', () => {
8 | expect(math.sub(1, 2)).toBe(-1);
9 | });
10 |
11 | // let x: number = '1'
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "@typescript-eslint/parser",
3 | "plugins": ["@typescript-eslint"],
4 | "parserOptions": {
5 | "project": "./tsconfig.json"
6 | },
7 | "extends": [
8 | "plugin:@typescript-eslint/recommended"
9 | ],
10 | "rules": {
11 | "@typescript-eslint/no-inferrable-types": "off"
12 | }
13 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/README.md:
--------------------------------------------------------------------------------
1 | 基础篇、工程篇代码
2 | ===============
3 |
4 | 注意:src 中为独立的代码片段,多个文件之间会有变量重名。如果要运行其中的代码,请复制到 index.ts 中,或用 import 导入。
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: './src/index.ts',
5 | output: {
6 | filename: 'app.js'
7 | },
8 | resolve: {
9 | extensions: ['.js', '.ts', '.tsx']
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.tsx?$/i,
15 | use: [{
16 | loader: 'ts-loader'
17 | }],
18 | exclude: /node_modules/
19 | }
20 | ]
21 | },
22 | plugins: [
23 | new HtmlWebpackPlugin({
24 | template: './src/tpl/index.html'
25 | })
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map'
3 | }
4 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: 'ts-jest',
3 | testEnvironment: 'node',
4 | };
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts_base",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.ts",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js",
9 | "lint": "eslint src --ext .js,.ts",
10 | "test": "jest"
11 | },
12 | "keywords": [
13 | "TypeScript"
14 | ],
15 | "author": "liangxiao",
16 | "license": "ISC",
17 | "devDependencies": {
18 | "@types/jest": "^24.0.15",
19 | "@types/jquery": "^3.3.29",
20 | "@types/source-map": "^0.5.2",
21 | "@typescript-eslint/eslint-plugin": "^1.10.2",
22 | "@typescript-eslint/parser": "^1.10.2",
23 | "awesome-typescript-loader": "^5.2.1",
24 | "clean-webpack-plugin": "^3.0.0",
25 | "eslint": "^5.16.0",
26 | "fork-ts-checker-webpack-plugin": "^1.3.7",
27 | "html-webpack-plugin": "^3.2.0",
28 | "jest": "^24.8.0",
29 | "ts-jest": "^24.0.2",
30 | "ts-loader": "^6.0.2",
31 | "typescript": "^3.5.1",
32 | "webpack": "^4.32.2",
33 | "webpack-cli": "^3.3.2",
34 | "webpack-dev-server": "^3.5.1",
35 | "webpack-merge": "^4.2.1"
36 | },
37 | "dependencies": {
38 | "jquery": "^3.4.1",
39 | "moment": "^2.24.0"
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/index.ts:
--------------------------------------------------------------------------------
1 | let hello: string = 'Hello TypeScript'
2 | document.querySelectorAll('.app')[0].innerHTML = hello
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/math.ts:
--------------------------------------------------------------------------------
1 | function add(a: number, b: number) {
2 | return a + b;
3 | }
4 |
5 | function sub(a: number, b: number) {
6 | return a - b;
7 | }
8 |
9 | module.exports = {
10 | add,
11 | sub
12 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/05.datatype.ts:
--------------------------------------------------------------------------------
1 | // 原始类型
2 | let bool: boolean = true
3 | let num: number | undefined | null = 123
4 | let str: string = 'abc'
5 | // str = 123
6 |
7 | // 数组
8 | let arr1: number[] = [1, 2, 3]
9 | let arr2: Array = [1, 2, 3, '4']
10 |
11 | // 元组
12 | let tuple: [number, string] = [0, '1']
13 | // tuple.push(2)
14 | // console.log(tuple)
15 | // tuple[2]
16 |
17 | // 函数
18 | let add = (x: number, y: number) => x + y
19 | let compute: (x: number, y: number) => number
20 | compute = (a, b) => a + b
21 |
22 | // 对象
23 | let obj: { x: number, y: number } = { x: 1, y: 2 }
24 | obj.x = 3
25 |
26 | // symbol
27 | let s1: symbol = Symbol()
28 | let s2 = Symbol()
29 | // console.log(s1 === s2)
30 |
31 | // undefined, null
32 | let un: undefined = undefined
33 | let nu: null = null
34 | num = undefined
35 | num = null
36 |
37 | // void
38 | let noReturn = () => {}
39 |
40 | // any
41 | let x
42 | x = 1
43 | x = []
44 | x = () => {}
45 |
46 | // never
47 | let error = () => {
48 | throw new Error('error')
49 | }
50 | let endless = () => {
51 | while(true) {}
52 | }
53 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/06.enum.ts:
--------------------------------------------------------------------------------
1 | // 数字枚举
2 | enum Role {
3 | Reporter = 1,
4 | Developer,
5 | Maintainer,
6 | Owner,
7 | Guest
8 | }
9 | // console.log(Role.Reporter)
10 | // console.log(Role)
11 |
12 | // 字符串枚举
13 | enum Message {
14 | Success = '恭喜你,成功了',
15 | Fail = '抱歉,失败了'
16 | }
17 |
18 | // 异构枚举
19 | enum Answer {
20 | N,
21 | Y = 'Yes'
22 | }
23 |
24 | // 枚举成员
25 | // Role.Reporter = 0
26 | enum Char {
27 | // const member
28 | a,
29 | b = Char.a,
30 | c = 1 + 3,
31 | // computed member
32 | d = Math.random(),
33 | e = '123'.length,
34 | f = 4
35 | }
36 |
37 | // 常量枚举
38 | const enum Month {
39 | Jan,
40 | Feb,
41 | Mar,
42 | Apr = Month.Mar + 1,
43 | // May = () => 5
44 | }
45 | let month = [Month.Jan, Month.Feb, Month.Mar]
46 |
47 | // 枚举类型
48 | enum E { a, b }
49 | enum F { a = 0, b = 1 }
50 | enum G { a = 'apple', b = 'banana' }
51 |
52 | let e: E = 3
53 | let f: F = 3
54 | // console.log(e === f)
55 |
56 | let e1: E.a = 3
57 | let e2: E.b = 3
58 | let e3: E.a = 3
59 | // console.log(e1 === e2)
60 | // console.log(e1 === e3)
61 |
62 | let g1: G = G.a
63 | let g2: G.a = G.a
64 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/07-08.interface.ts:
--------------------------------------------------------------------------------
1 | interface List {
2 | readonly id: number;
3 | name: string;
4 | // [x: string]: any;
5 | age?: number;
6 | }
7 | interface Result {
8 | data: List[]
9 | }
10 | function render(result: Result) {
11 | result.data.forEach((value) => {
12 | console.log(value.id, value.name)
13 | if (value.age) {
14 | console.log(value.age)
15 | }
16 | // value.id++
17 | })
18 | }
19 | let result = {
20 | data: [
21 | {id: 1, name: 'A', sex: 'male'},
22 | {id: 2, name: 'B', age: 10}
23 | ]
24 | }
25 | render(result)
26 |
27 | interface StringArray {
28 | [index: number]: string
29 | }
30 | let chars: StringArray = ['a', 'b']
31 |
32 | interface Names {
33 | [x: string]: any;
34 | // y: number;
35 | [z: number]: number;
36 | }
37 |
38 | // let add: (x: number, y: number) => number
39 | // interface Add {
40 | // (x: number, y: number): number
41 | // }
42 | type Add = (x: number, y: number) => number
43 | let add: Add = (a: number, b: number) => a + b
44 |
45 | interface Lib {
46 | (): void;
47 | version: string;
48 | doSomething(): void;
49 | }
50 |
51 | function getLib() {
52 | let lib = (() => {}) as Lib
53 | lib.version = '1.0.0'
54 | lib.doSomething = () => {}
55 | return lib;
56 | }
57 | let lib1 = getLib()
58 | lib1()
59 | let lib2 = getLib()
60 | lib2.doSomething()
61 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/09.function.ts:
--------------------------------------------------------------------------------
1 | // 函数定义
2 | function add1(x: number, y: number) {
3 | return x + y
4 | }
5 |
6 | let add2: (x: number, y: number) => number
7 |
8 | type add3 = (x: number, y: number) => number
9 |
10 | interface add4 {
11 | (x: number, y: number): number
12 | }
13 |
14 | add1(1, 2, 3)
15 |
16 | function add5(x: number, y?: number) {
17 | return y ? x + y : x
18 | }
19 | add5(1)
20 |
21 | function add6(x: number, y = 0, z: number, q = 1) {
22 | return x + y + z + q
23 | }
24 | add6(1, undefined, 3)
25 |
26 | function add7(x: number, ...rest: number[]) {
27 | return x + rest.reduce((pre, cur) => pre + cur);
28 | }
29 | add7(1, 2, 3, 4, 5)
30 |
31 | function add8(...rest: number[]): number;
32 | function add8(...rest: string[]): string;
33 | function add8(...rest: any[]) {
34 | let first = rest[0];
35 | if (typeof first === 'number') {
36 | return rest.reduce((pre, cur) => pre + cur);
37 | }
38 | if (typeof first === 'string') {
39 | return rest.join('');
40 | }
41 | }
42 | console.log(add8(1, 2))
43 | console.log(add8('a', 'b', 'c'))
44 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/12.class-interface.ts:
--------------------------------------------------------------------------------
1 | interface Human {
2 | name: string;
3 | eat(): void;
4 | }
5 |
6 | class Asian implements Human {
7 | constructor(name: string) {
8 | this.name = name;
9 | }
10 | name: string
11 | eat() {}
12 | age: number = 0
13 | sleep() {}
14 | }
15 |
16 | interface Man extends Human {
17 | run(): void
18 | }
19 |
20 | interface Child {
21 | cry(): void
22 | }
23 |
24 | interface Boy extends Man, Child {}
25 |
26 | let boy: Boy = {
27 | name: '',
28 | run() {},
29 | eat() {},
30 | cry() {}
31 | }
32 |
33 | class Auto {
34 | state = 1
35 | // private state2 = 1
36 | }
37 | interface AutoInterface extends Auto {
38 |
39 | }
40 | class C implements AutoInterface {
41 | state1 = 1
42 | }
43 | class Bus extends Auto implements AutoInterface {
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/13-14.generics.ts:
--------------------------------------------------------------------------------
1 | function log(value: T): T {
2 | console.log(value);
3 | return value;
4 | }
5 | log(['a', ',b', 'c'])
6 | log(['a', ',b', 'c'])
7 |
8 | // type Log = (value: T) => T
9 | // let myLog: Log = log
10 |
11 | // interface Log {
12 | // (value: T): T
13 | // }
14 | // let myLog: Log = log
15 | // myLog(1)
16 |
17 | class Log {
18 | run(value: T) {
19 | console.log(value)
20 | return value
21 | }
22 | }
23 | let log1 = new Log()
24 | log1.run(1)
25 | let log2 = new Log()
26 | log2.run({ a: 1 })
27 |
28 | interface Length {
29 | length: number
30 | }
31 | function logAdvance(value: T): T {
32 | console.log(value, value.length);
33 | return value;
34 | }
35 | logAdvance([1])
36 | logAdvance('123')
37 | logAdvance({ length: 3 })
38 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/15.inference.ts:
--------------------------------------------------------------------------------
1 | let a = 1;
2 | let b = [1, null, 'a']
3 | let c = {x: 1, y: 'a'}
4 |
5 | let d = (x = 1) => x + 1
6 |
7 | window.onkeydown = (event) => {
8 | // console.log(event.button)
9 | }
10 |
11 | interface Foo {
12 | bar: number
13 | }
14 | // let foo = {} as Foo
15 | // let foo = {}
16 | let foo: Foo = {
17 | bar: 1
18 | }
19 | // foo.bar = 1
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/18.advanced-1.ts:
--------------------------------------------------------------------------------
1 | interface DogInterface {
2 | run(): void
3 | }
4 | interface CatInterface {
5 | jump(): void
6 | }
7 | let pet: DogInterface & CatInterface = {
8 | run() {},
9 | jump() {}
10 | }
11 |
12 | let a: number | string = 1
13 | let b: 'a' | 'b' | 'c'
14 | let c: 1 | 2 | 3
15 |
16 | class Dog implements DogInterface {
17 | run() {}
18 | eat() {}
19 | }
20 | class Cat implements CatInterface {
21 | jump() {}
22 | eat() {}
23 | }
24 | enum Master { Boy, Girl }
25 | function getPet(master: Master) {
26 | let pet = master === Master.Boy ? new Dog() : new Cat();
27 | // pet.run()
28 | // pet.jump()
29 | pet.eat()
30 | return pet
31 | }
32 |
33 | interface Square {
34 | kind: "square";
35 | size: number;
36 | }
37 | interface Rectangle {
38 | kind: "rectangle";
39 | width: number;
40 | height: number;
41 | }
42 | interface Circle {
43 | kind: "circle";
44 | radius: number;
45 | }
46 | type Shape = Square | Rectangle | Circle
47 | function area(s: Shape) {
48 | switch (s.kind) {
49 | case "square":
50 | return s.size * s.size;
51 | case "rectangle":
52 | return s.height * s.width;
53 | case 'circle':
54 | return Math.PI * s.radius ** 2
55 | default:
56 | return ((e: never) => {throw new Error(e)})(s)
57 | }
58 | }
59 | console.log(area({kind: 'circle', radius: 1}))
60 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/19.advanced-2.ts:
--------------------------------------------------------------------------------
1 | let obj = {
2 | a: 1,
3 | b: 2,
4 | c: 3
5 | }
6 |
7 | // function getValues(obj: any, keys: string[]) {
8 | // return keys.map(key => obj[key])
9 | // }
10 | function getValues(obj: T, keys: K[]): T[K][] {
11 | return keys.map(key => obj[key])
12 | }
13 | console.log(getValues(obj, ['a', 'b']))
14 | // console.log(getValues(obj, ['d', 'e']))
15 |
16 | // keyof T
17 | interface Obj {
18 | a: number;
19 | b: string;
20 | }
21 | let key: keyof Obj
22 |
23 | // T[K]
24 | let value: Obj['a']
25 |
26 | // T extends U
27 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/20.advanced-3.ts:
--------------------------------------------------------------------------------
1 | interface Obj {
2 | a: string;
3 | b: number;
4 | }
5 | type ReadonlyObj = Readonly
6 |
7 | type PartialObj = Partial
8 |
9 | type PickObj = Pick
10 |
11 | type RecordObj = Record<'x' | 'y', Obj>
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part1.base/21.advanced-4.ts:
--------------------------------------------------------------------------------
1 | // T extends U ? X : Y
2 |
3 | type TypeName =
4 | T extends string ? "string" :
5 | T extends number ? "number" :
6 | T extends boolean ? "boolean" :
7 | T extends undefined ? "undefined" :
8 | T extends Function ? "function" :
9 | "object";
10 | type T1 = TypeName
11 | type T2 = TypeName
12 |
13 | // (A | B) extends U ? X : Y
14 | // (A extends U ? X : Y) | (B extends U ? X : Y)
15 | type T3 = TypeName
16 |
17 | type Diff = T extends U ? never : T
18 | type T4 = Diff<"a" | "b" | "c", "a" | "e">
19 | // Diff<"a", "a" | "e"> | Diff<"b", "a" | "e"> | Diff<"c", "a" | "e">
20 | // never | "b" | "c"
21 | // "b" | "c"
22 |
23 | type NotNull = Diff
24 | type T5 = NotNull
25 |
26 | // Exclude
27 | // NonNullable
28 |
29 | // Extract
30 | type T6 = Extract<"a" | "b" | "c", "a" | "e">
31 |
32 | // ReturnType
33 | type T8 = ReturnType<() => string>
34 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/es6/a.ts:
--------------------------------------------------------------------------------
1 | // 单独导出
2 | export let a = 1
3 |
4 | // 批量导出
5 | let b = 2
6 | let c = 3
7 | export { b, c }
8 |
9 | // 导出接口
10 | export interface P {
11 | x: number;
12 | y: number;
13 | }
14 |
15 | // 导出函数
16 | export function f() {}
17 |
18 | // 导出时起别名
19 | function g() {}
20 | export { g as G }
21 |
22 | // 默认导出,无需函数名
23 | export default function () {
24 | console.log("I'm default")
25 | }
26 |
27 | // 引入外部模块,重新导出
28 | export { str as hello } from './b'
29 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/es6/b.ts:
--------------------------------------------------------------------------------
1 | // 导出常量
2 | export const str = 'Hello'
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/es6/c.ts:
--------------------------------------------------------------------------------
1 | import { a, b, c } from './a'; // 批量导入
2 | import { P } from './a'; // 导入接口
3 | import { f as F } from './a'; // 导入时起别名
4 | import * as All from './a'; // 导入模块中的所有成员,绑定在 All 上
5 | import myFunction from './a'; // 不加{},导入默认
6 |
7 | console.log(a, b, c)
8 |
9 | let p: P = {
10 | x: 1,
11 | y: 1
12 | }
13 |
14 | console.log(All)
15 |
16 | myFunction()
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/es6/d.ts:
--------------------------------------------------------------------------------
1 | export = function () {
2 | console.log("I'm default")
3 | }
4 | // export let a = 1
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/node/a.node.ts:
--------------------------------------------------------------------------------
1 | let a = {
2 | x: 1,
3 | y: 2
4 | }
5 |
6 | // 整体导出
7 | module.exports = a
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/node/b.node.ts:
--------------------------------------------------------------------------------
1 | // exports === module.exports
2 | // 导出多个变量
3 | // module.exports = {}
4 | exports.c = 3
5 | exports.d = 4
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/01.module/node/c.node.ts:
--------------------------------------------------------------------------------
1 | let c1 = require('./a.node')
2 | let c2 = require('./b.node')
3 | let c3 = require('../es6/a')
4 | import c4 = require('../es6/d')
5 |
6 | console.log(c1)
7 | console.log(c2)
8 | // c3()
9 | // console.log(c3)
10 | // c3.default()
11 | c4()
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/02.namespace/a.ts:
--------------------------------------------------------------------------------
1 | namespace Shape {
2 | const pi = Math.PI
3 | export function cricle(r: number) {
4 | return pi * r ** 2
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/02.namespace/b.ts:
--------------------------------------------------------------------------------
1 | ///
2 | namespace Shape {
3 | export function square(x: number) {
4 | return x * x
5 | }
6 | }
7 |
8 | console.log(Shape.cricle(2))
9 | console.log(Shape.square(2))
10 |
11 | import cricle = Shape.cricle
12 | console.log(cricle(2))
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/03.merge/merge.ts:
--------------------------------------------------------------------------------
1 | interface A {
2 | x: number;
3 | // y: string;
4 | foo(bar: number): number; // 5
5 | foo(bar: 'a'): string; // 2
6 | }
7 |
8 | interface A {
9 | y: number;
10 | foo(bar: string): string; // 3
11 | foo(bar: string[]): string[]; // 4
12 | foo(bar: 'b'): string; // 1
13 | }
14 |
15 | let a: A = {
16 | x: 1,
17 | y: 2,
18 | foo(bar: any) {
19 | return bar
20 | }
21 | }
22 |
23 | class C {}
24 | namespace C {
25 | export let state = 1
26 | }
27 | console.log(C.state)
28 |
29 | function Lib() {}
30 | namespace Lib {
31 | export let version = '1.0'
32 | }
33 | console.log(Lib.version)
34 |
35 | enum Color {
36 | Red,
37 | Yellow,
38 | Blue
39 | }
40 | namespace Color {
41 | export function mix() {}
42 | }
43 | console.log(Color)
44 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/global-lib.d.ts:
--------------------------------------------------------------------------------
1 | declare function globalLib(options: globalLib.Options): void;
2 |
3 | declare namespace globalLib {
4 | const version: string;
5 | function doSomething(): void;
6 | interface Options {
7 | [key: string]: any
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/global-lib.js:
--------------------------------------------------------------------------------
1 | function globalLib(options) {
2 | console.log(options);
3 | }
4 |
5 | globalLib.version = '1.0.0';
6 |
7 | globalLib.doSomething = function() {
8 | console.log('globalLib do something');
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/index.ts:
--------------------------------------------------------------------------------
1 | import $ from 'jquery'
2 |
3 | $('.app').css('color', 'red')
4 |
5 | globalLib({x: 1})
6 | globalLib.doSomething()
7 |
8 | import moduleLib from './module-lib'
9 | moduleLib({y: 2})
10 | moduleLib.doSomething()
11 |
12 | import umdLib from './umd-lib'
13 | umdLib.doSomething()
14 |
15 | // 模块插件
16 | import m from 'moment';
17 | declare module 'moment' {
18 | export function myFunction(): void;
19 | }
20 | m.myFunction = () => {}
21 |
22 | // 全局插件
23 | declare global {
24 | namespace globalLib {
25 | function doAnyting(): void
26 | }
27 | }
28 | globalLib.doAnyting = () => {}
29 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/module-lib.d.ts:
--------------------------------------------------------------------------------
1 | declare function moduleLib(options: Options): void
2 |
3 | interface Options {
4 | [key: string]: any
5 | }
6 |
7 | declare namespace moduleLib {
8 | const version: string
9 | function doSomething(): void
10 | }
11 |
12 | export = moduleLib
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/module-lib.js:
--------------------------------------------------------------------------------
1 | const version = '1.0.0';
2 |
3 | function doSomething() {
4 | console.log('moduleLib do something');
5 | }
6 |
7 | function moduleLib(options) {
8 | console.log(options);
9 | }
10 |
11 | moduleLib.version = version;
12 | moduleLib.doSomething = doSomething;
13 |
14 | module.exports = moduleLib;
15 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/umd-lib.d.ts:
--------------------------------------------------------------------------------
1 | declare namespace umdLib {
2 | const version: string
3 | function doSomething(): void
4 | }
5 |
6 | export as namespace umdLib
7 |
8 | export = umdLib
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/04.libs/umd-lib.js:
--------------------------------------------------------------------------------
1 | (function (root, factory) {
2 | if (typeof define === "function" && define.amd) {
3 | define(factory);
4 | } else if (typeof module === "object" && module.exports) {
5 | module.exports = factory();
6 | } else {
7 | root.umdLib = factory();
8 | }
9 | }(this, function() {
10 | return {
11 | version: '1.0.0',
12 | doSomething() {
13 | console.log('umdLib do something');
14 | }
15 | }
16 | }));
17 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/client/index.ts:
--------------------------------------------------------------------------------
1 | import { getTime } from '../common'
2 |
3 | console.log(`Client Time: ${getTime()}`)
4 |
5 | class Client {}
6 |
7 | export = Client
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/client/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/client",
5 | },
6 | "references": [
7 | { "path": "../common" }
8 | ]
9 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/common/index.ts:
--------------------------------------------------------------------------------
1 | export function getTime() {
2 | let time = new Date();
3 | return `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
4 | }
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/common/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/common",
5 | }
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/server/index.ts:
--------------------------------------------------------------------------------
1 | import { getTime } from '../common'
2 |
3 | console.log(`Server Time: ${getTime()}`)
4 |
5 | class Server {}
6 |
7 | export = Server
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/src/server/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/server",
5 | },
6 | "references": [
7 | { "path": "../common" }
8 | ]
9 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/test/client.test.ts:
--------------------------------------------------------------------------------
1 | import Client = require('../src/client')
2 |
3 | let c = new Client()
4 |
5 | // do test
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/test/server.test.ts:
--------------------------------------------------------------------------------
1 | import Server = require('../src/server')
2 |
3 | let c = new Server()
4 |
5 | // do test
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "references": [
4 | { "path": "../src/client" },
5 | { "path": "../src/server" }
6 | ]
7 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/new/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "composite": true,
7 | "declaration": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/src/client/index.ts:
--------------------------------------------------------------------------------
1 | import { getTime } from '../common'
2 |
3 | console.log(`Client Time: ${getTime()}`)
4 |
5 | class Client {}
6 |
7 | export = Client
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/src/common/index.ts:
--------------------------------------------------------------------------------
1 | export function getTime() {
2 | let time = new Date();
3 | return `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
4 | }
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/src/server/index.ts:
--------------------------------------------------------------------------------
1 | import { getTime } from '../common'
2 |
3 | console.log(`Server Time: ${getTime()}`)
4 |
5 | class Server {}
6 |
7 | export = Server
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/test/client.test.ts:
--------------------------------------------------------------------------------
1 | import Client = require('../src/client')
2 |
3 | let c = new Client()
4 |
5 | // do test
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/test/server.test.ts:
--------------------------------------------------------------------------------
1 | import Server = require('../src/server')
2 |
3 | let c = new Server()
4 |
5 | // do test
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/part2.project/07.project-references/old/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "./dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TypeScript in Action
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-base/test/math.test.ts:
--------------------------------------------------------------------------------
1 | const math = require('../src/math');
2 |
3 | test('add: 1 + 2 = 3', () => {
4 | expect(math.add(1, 2)).toBe(3);
5 | });
6 |
7 | test('sub: 1 - 2 = -1', () => {
8 | expect(math.sub(1, 2)).toBe(-1);
9 | });
10 |
11 | // let x: number = '1'
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(Node)代码
2 | ===============
3 |
4 | 启动步骤:
5 | 1. npm run build
6 | 2. npm start(npm run watch)
7 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/app.ts:
--------------------------------------------------------------------------------
1 | import createError from 'http-errors';
2 | import express from 'express';
3 | import path from 'path';
4 | import cookieParser from 'cookie-parser';
5 | import logger from 'morgan';
6 |
7 | import indexRouter from './routes/index';
8 | import usersRouter from './routes/users';
9 | import employeeRouter from './routes/employee';
10 |
11 | let app = express();
12 |
13 | // view engine setup
14 | app.set('views', path.join(__dirname, 'views'));
15 | app.set('view engine', 'jade');
16 |
17 | app.use(logger('dev'));
18 | app.use(express.json());
19 | app.use(express.urlencoded({ extended: false }));
20 | app.use(cookieParser());
21 | app.use(express.static(path.join(__dirname, 'public')));
22 |
23 | app.use('/', indexRouter);
24 | app.use('/users', usersRouter);
25 | app.use('/api/employee', employeeRouter);
26 |
27 | // catch 404 and forward to error handler
28 | app.use(function(req, res, next) {
29 | next(createError(404));
30 | });
31 |
32 | // error handler
33 | app.use(function(err, req, res, next) {
34 | // set locals, only providing error in development
35 | res.locals.message = err.message;
36 | res.locals.error = req.app.get('env') === 'development' ? err : {};
37 |
38 | // render the error page
39 | res.status(err.status || 500);
40 | res.render('error');
41 | } as express.ErrorRequestHandler);
42 |
43 | export default app;
44 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/config/db.ts:
--------------------------------------------------------------------------------
1 | const dbConfig = {
2 | host: '127.0.0.1',
3 | port: 3306,
4 | user: 'ts',
5 | password: 'typescript',
6 | database: 'employee_system'
7 | };
8 |
9 | export default dbConfig;
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/copyStatic.ts:
--------------------------------------------------------------------------------
1 | import * as shell from 'shelljs';
2 |
3 | shell.cp('-R', 'public', 'dist');
4 | shell.cp('-R', 'views', 'dist');
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/models/query.ts:
--------------------------------------------------------------------------------
1 | import mysql from 'mysql';
2 | import dbConfig from '../config/db';
3 |
4 | const pool = mysql.createPool(dbConfig);
5 |
6 | const query = (sql: string) => {
7 | return new Promise((resolve, reject) => {
8 | pool.getConnection((error, connection) => {
9 | if (error) {
10 | reject(error);
11 | } else {
12 | connection.query(sql, (error, results) => {
13 | if (error) {
14 | reject(error);
15 | } else {
16 | resolve(results);
17 | }
18 | connection.release();
19 | })
20 | }
21 | });
22 | });
23 | };
24 |
25 | export default query;
26 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts-express",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "start": "node ./dist/bin/server.js",
7 | "watch": "nodemon ./dist/bin/server.js",
8 | "build-ts": "tsc",
9 | "copy-static": "ts-node copyStatic.ts",
10 | "build": "npm run build-ts && npm run copy-static"
11 | },
12 | "dependencies": {
13 | "cookie-parser": "~1.4.4",
14 | "debug": "~2.6.9",
15 | "excel-export": "^0.5.1",
16 | "express": "~4.16.1",
17 | "http-errors": "~1.6.3",
18 | "jade": "~1.11.0",
19 | "morgan": "~1.9.1",
20 | "mysql": "^2.17.1"
21 | },
22 | "devDependencies": {
23 | "@types/cookie-parser": "^1.4.1",
24 | "@types/debug": "^4.1.5",
25 | "@types/express": "^4.17.0",
26 | "@types/http-errors": "^1.6.1",
27 | "@types/morgan": "^1.7.36",
28 | "@types/mysql": "^2.15.6",
29 | "@types/node": "^12.7.2",
30 | "@types/shelljs": "^0.8.5",
31 | "nodemon": "^1.19.1",
32 | "shelljs": "^0.8.3",
33 | "ts-node": "^8.3.0",
34 | "typescript": "^3.5.3"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/public/stylesheets/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 50px;
3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4 | }
5 |
6 | a {
7 | color: #00B7FF;
8 | }
9 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/routes/excel-export.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'excel-export' {
2 | export function execute(config: Config): void;
3 | export interface Config {
4 | cols: { caption: string, type: string }[];
5 | rows: any[];
6 | }
7 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/routes/index.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | const router = express.Router();
3 |
4 | /* GET home page. */
5 | router.get('/', function(req, res, next) {
6 | res.render('index', { title: 'TypeScript' });
7 | });
8 |
9 | export default router;
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/routes/users.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | const router = express.Router();
3 |
4 | /* GET users listing. */
5 | router.get('/', function(req, res, next) {
6 | res.send('respond with a resource');
7 | });
8 |
9 | export default router;
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/views/error.jade:
--------------------------------------------------------------------------------
1 | extends layout
2 |
3 | block content
4 | h1= message
5 | h2= error.status
6 | pre #{error.stack}
7 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/views/index.jade:
--------------------------------------------------------------------------------
1 | extends layout
2 |
3 | block content
4 | h1= title
5 | p Welcome to #{title}
6 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-express/views/layout.jade:
--------------------------------------------------------------------------------
1 | doctype html
2 | html
3 | head
4 | title= title
5 | link(rel='stylesheet', href='/stylesheets/style.css')
6 | body
7 | block content
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(React 01-05节)代码
2 | ===============
3 |
4 | create-react-app 创建
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/config-overrides.js:
--------------------------------------------------------------------------------
1 | const { override, fixBabelImports } = require('customize-cra');
2 |
3 | module.exports = override(
4 | fixBabelImports('import', {
5 | libraryName: 'antd',
6 | libraryDirectory: 'es',
7 | style: 'css'
8 | })
9 | );
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/mock/employee/getEmployee.json:
--------------------------------------------------------------------------------
1 | {
2 | "flag": 0,
3 | "data": [
4 | {
5 | "id": 1,
6 | "key": 1,
7 | "name": "小明",
8 | "department": "技术部",
9 | "hiredate": "2019-07-01",
10 | "level": "1级"
11 | }, {
12 | "id": 2,
13 | "key": 2,
14 | "name": "小莉",
15 | "department": "产品部",
16 | "hiredate": "2017-07-01",
17 | "level": "2级"
18 | }
19 | ],
20 | "msg": "Error"
21 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts-react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@types/jest": "24.0.15",
7 | "@types/node": "12.6.8",
8 | "@types/react": "16.8.23",
9 | "@types/react-dom": "16.8.5",
10 | "antd": "^3.20.7",
11 | "axios": "^0.19.0",
12 | "react": "^16.9.0",
13 | "react-dom": "^16.9.0",
14 | "react-router-dom": "^5.0.1",
15 | "react-scripts": "3.0.1",
16 | "typescript": "3.5.3"
17 | },
18 | "scripts": {
19 | "start": "react-app-rewired start",
20 | "build": "react-app-rewired build",
21 | "test": "react-app-rewired test",
22 | "eject": "react-app-rewired eject",
23 | "server": "cd mock && hs -p 4000 -a localhost"
24 | },
25 | "eslintConfig": {
26 | "extends": "react-app"
27 | },
28 | "browserslist": {
29 | "production": [
30 | ">0.2%",
31 | "not dead",
32 | "not op_mini all"
33 | ],
34 | "development": [
35 | "last 1 chrome version",
36 | "last 1 firefox version",
37 | "last 1 safari version"
38 | ]
39 | },
40 | "devDependencies": {
41 | "@types/react-router-dom": "^4.3.4",
42 | "babel-plugin-import": "^1.12.0",
43 | "customize-cra": "^0.4.1",
44 | "http-proxy-middleware": "^0.19.1",
45 | "http-server": "^0.11.1",
46 | "react-app-rewired": "^2.1.3"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/ts-react-app/public/favicon.ico
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | TypeScript in Action
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/App.css:
--------------------------------------------------------------------------------
1 | .menu {
2 | line-height: 64px;
3 | }
4 | .contentWrap {
5 | padding: 0 50px;
6 | }
7 | .content {
8 | background: #fff;
9 | padding: 24px;
10 | min-height: 480px;
11 | }
12 | .footer {
13 | text-align: center;
14 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/App.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Route, Link } from 'react-router-dom';
3 | import { Layout, Menu, ConfigProvider } from 'antd';
4 | import zh_CN from 'antd/lib/locale-provider/zh_CN';
5 |
6 | import Employee from './employee';
7 | import Setting from './setting';
8 | import './App.css';
9 |
10 | const { Header, Content, Footer } = Layout;
11 |
12 | const App = ({ match }: any) => {
13 | let defaultKey = match.url.replace('/', '') || 'employee';
14 | return
15 |
16 |
17 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | }
38 |
39 | export default App;
40 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/demo/Hello.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Button } from 'antd';
3 |
4 | interface Greeting {
5 | name: string;
6 | firstName: string;
7 | lastName: string;
8 | }
9 |
10 | const Hello = (props: Greeting) =>
11 |
12 | // const Hello: React.FC = ({
13 | // name,
14 | // firstName,
15 | // lastName,
16 | // children
17 | // }) =>
18 |
19 | Hello.defaultProps = {
20 | firstName: '',
21 | lastName: ''
22 | }
23 |
24 | export default Hello;
25 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/demo/HelloClass.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Button } from 'antd';
3 |
4 | interface Greeting {
5 | name: string;
6 | firstName?: string;
7 | lastName?: string;
8 | }
9 |
10 | interface HelloState {
11 | count: number
12 | }
13 |
14 | class HelloClass extends Component {
15 | state: HelloState = {
16 | count: 0
17 | }
18 | static defaultProps = {
19 | firstName: '',
20 | lastName: ''
21 | }
22 | render() {
23 | return (
24 | <>
25 | 你点击了 {this.state.count} 次
26 |
29 | >
30 | )
31 | }
32 | }
33 |
34 | export default HelloClass;
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/demo/HelloHOC.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | import HelloClass from './HelloClass';
4 |
5 | interface Loading {
6 | loading: boolean
7 | }
8 |
9 | function HelloHOC(WrappedComponent: React.ComponentType
) {
10 | return class extends Component
{
11 | render() {
12 | const { loading, ...props } = this.props;
13 | return loading ?
Loading...
: ;
14 | }
15 | }
16 | }
17 |
18 | export default HelloHOC(HelloClass);
19 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/demo/HelloHooks.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import { Button } from 'antd';
3 |
4 | interface Greeting {
5 | name: string;
6 | firstName: string;
7 | lastName: string;
8 | }
9 |
10 | const HelloHooks = (props: Greeting) => {
11 | const [count, setCount] = useState(0);
12 | const [text, setText] = useState(null);
13 |
14 | useEffect(() => {
15 | if (count > 5) {
16 | setText('休息一下');
17 | }
18 | }, [count]);
19 |
20 | return (
21 | <>
22 | 你点击了 {count} 次 {text}
23 |
26 | >
27 | )
28 | }
29 |
30 | HelloHooks.defaultProps = {
31 | firstName: '',
32 | lastName: ''
33 | }
34 |
35 | export default HelloHooks;
36 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/employee/colums.tsx:
--------------------------------------------------------------------------------
1 | export const employeeColumns = [
2 | {
3 | title: '姓名',
4 | dataIndex: 'name',
5 | key: 'name'
6 | }, {
7 | title: '部门',
8 | dataIndex: 'department',
9 | key: 'department'
10 | }, {
11 | title: '入职时间',
12 | dataIndex: 'hiredate',
13 | key: 'hiredate'
14 | }, {
15 | title: '职级',
16 | dataIndex: 'level',
17 | key: 'level'
18 | }
19 | ];
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/employee/index.css:
--------------------------------------------------------------------------------
1 | .table {
2 | margin-top: 20px;
3 | }
4 | .toolbar {
5 | margin: 20px 0;
6 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/setting/index.css:
--------------------------------------------------------------------------------
1 | .buttonWrap {
2 | margin: 20px 0;
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/components/setting/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Checkbox , Button } from 'antd';
3 |
4 | import './index.css';
5 |
6 | const Setting = () => {
7 | return (
8 | <>
9 | 新员工入职邮件提醒
10 |
11 |
12 |
13 | >
14 | )
15 | }
16 |
17 | export default Setting;
18 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/constants/urls.ts:
--------------------------------------------------------------------------------
1 | export const GET_EMPLOYEE_URL = '/api/employee/getEmployee.action';
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | // import Hello from './components/demo/Hello';
5 | // import HelloClass from './components/demo/HelloClass';
6 | // import HelloHOC from './components/demo/HelloHOC';
7 | // import HelloHooks from './components/demo/HelloHooks';
8 | // import App from './components/App';
9 | import Root from './routers';
10 |
11 | ReactDOM.render(
12 | // ,
13 | // ,
14 | // ,
15 | // ,
16 | // ,
17 | ,
18 | document.querySelectorAll('.app')[0]
19 | );
20 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/interface/employee.ts:
--------------------------------------------------------------------------------
1 | export interface EmployeeRequest {
2 | name: string;
3 | departmentId: number | undefined;
4 | }
5 |
6 | interface EmployeeInfo {
7 | id: number;
8 | key: number;
9 | name: string;
10 | department: string;
11 | hiredate: string;
12 | level: string;
13 | }
14 |
15 | export type EmployeeResponse = EmployeeInfo[] | undefined
16 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/routers/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { BrowserRouter, Route } from 'react-router-dom';
3 |
4 | import App from '../components/App';
5 |
6 | const Root = () => (
7 |
8 |
9 |
10 | )
11 |
12 | export default Root;
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/setupProxy.js:
--------------------------------------------------------------------------------
1 | const proxy = require('http-proxy-middleware');
2 |
3 | module.exports = function(app) {
4 | app.use(proxy('/api/**/*.action', {
5 | target: 'http://localhost:4000',
6 | pathRewrite(path) {
7 | return path.replace('/api', '/').replace('.action', '.json');
8 | }
9 | }));
10 | };
11 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/src/utils/request.ts:
--------------------------------------------------------------------------------
1 | import originAxios from 'axios';
2 | import { message } from 'antd';
3 |
4 | const axios = originAxios.create({
5 | timeout: 20000
6 | });
7 |
8 | axios.interceptors.response.use(
9 | function(response) {
10 | if (response.data && response.data.flag === 1) {
11 | /*
12 | successful response:
13 | {"flag": 0, "data": ""}
14 |
15 | unsuccessful response:
16 | {"flag": 1, "msg": "server error"}
17 | */
18 | let errorMsg = response.data.msg;
19 | message.error(errorMsg);
20 | return Promise.reject(errorMsg);
21 | }
22 | return response.data;
23 | },
24 | function(error) {
25 | return Promise.reject(error);
26 | }
27 | );
28 |
29 | export function get(url: string, data: any) {
30 | return axios.get(url, {
31 | params: data
32 | });
33 | };
34 |
35 | // By default, axios serializes JavaScript objects to JSON.
36 | export function post(url: string, data: any) {
37 | return axios({
38 | method: 'post',
39 | url,
40 | data
41 | });
42 | };
43 |
44 | export default axios;
45 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "module": "esnext",
16 | "moduleResolution": "node",
17 | "resolveJsonModule": true,
18 | "isolatedModules": true,
19 | "noEmit": true,
20 | "jsx": "preserve"
21 | },
22 | "include": [
23 | "src"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(React 01节)代码
2 | ===============
3 |
4 | 手动创建
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: {
5 | 'app': './src/index.tsx'
6 | },
7 | output: {
8 | filename: '[name].[chunkhash:8].js'
9 | },
10 | resolve: {
11 | extensions: ['.js', '.ts', '.tsx']
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.tsx?$/i,
17 | use: [{
18 | loader: 'ts-loader'
19 | }],
20 | exclude: /node_modules/
21 | }
22 | ]
23 | },
24 | plugins: [
25 | new HtmlWebpackPlugin({
26 | template: './src/tpl/index.html'
27 | })
28 | ],
29 | optimization: {
30 | splitChunks: {
31 | chunks: 'all'
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map'
3 | }
4 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts_react",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.tsx",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js"
9 | },
10 | "keywords": [
11 | "TypeScript",
12 | "React"
13 | ],
14 | "author": "liangxiao",
15 | "license": "ISC",
16 | "devDependencies": {
17 | "@types/react": "^16.9.2",
18 | "@types/react-dom": "^16.8.4",
19 | "@types/source-map": "^0.5.2",
20 | "clean-webpack-plugin": "^3.0.0",
21 | "html-webpack-plugin": "^3.2.0",
22 | "ts-loader": "^6.0.2",
23 | "typescript": "^3.5.1",
24 | "webpack": "^4.39.2",
25 | "webpack-cli": "^3.3.2",
26 | "webpack-dev-server": "^3.5.1",
27 | "webpack-merge": "^4.2.1"
28 | },
29 | "dependencies": {
30 | "react": "^16.8.6",
31 | "react-dom": "^16.8.6"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/src/components/Hello.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | interface Greeting {
4 | name: string;
5 | }
6 |
7 | const Hello = (props: Greeting) => Hello {props.name}
8 |
9 | export default Hello;
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import Hello from './components/Hello';
5 |
6 | ReactDOM.render(
7 | ,
8 | document.querySelectorAll('.app')[0]
9 | );
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-react/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TypeScript in Action
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(React 06节)代码
2 | ===============
3 |
4 | create-react-app 创建
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/config-overrides.js:
--------------------------------------------------------------------------------
1 | const { override, fixBabelImports } = require('customize-cra');
2 |
3 | module.exports = override(
4 | fixBabelImports('import', {
5 | libraryName: 'antd',
6 | libraryDirectory: 'es',
7 | style: 'css'
8 | })
9 | );
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/mock/employee/createEmployee.json:
--------------------------------------------------------------------------------
1 | {
2 | "flag": 0,
3 | "data": {
4 | "id": 3,
5 | "key": 3
6 | },
7 | "msg": "Error"
8 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/mock/employee/deleteEmployee.json:
--------------------------------------------------------------------------------
1 | {
2 | "flag": 0,
3 | "msg": "Error"
4 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/mock/employee/getEmployee.json:
--------------------------------------------------------------------------------
1 | {
2 | "flag": 0,
3 | "data": [
4 | {
5 | "id": 1,
6 | "key": 1,
7 | "name": "小明",
8 | "departmentId": 1,
9 | "hiredate": "2019-07-01",
10 | "levelId": 1
11 | }, {
12 | "id": 2,
13 | "key": 2,
14 | "name": "小莉",
15 | "departmentId": 2,
16 | "hiredate": "2017-07-01",
17 | "levelId": 2
18 | }
19 | ],
20 | "msg": "Error"
21 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/mock/employee/updateEmployee.json:
--------------------------------------------------------------------------------
1 | {
2 | "flag": 0,
3 | "msg": "Error"
4 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/biaochenxuying/blog/87e37f1b557c6613c4e7cf3d444f47e364ba7f2a/typescript-in-action/sourcecode/ts-redux/public/favicon.ico
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | TypeScript in Action
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/components/App.css:
--------------------------------------------------------------------------------
1 | .menu {
2 | line-height: 64px;
3 | }
4 | .contentWrap {
5 | padding: 0 50px;
6 | }
7 | .content {
8 | background: #fff;
9 | padding: 24px;
10 | min-height: 480px;
11 | }
12 | .footer {
13 | text-align: center;
14 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/components/App.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Route, Link } from 'react-router-dom';
3 | import { Layout, Menu, ConfigProvider } from 'antd';
4 | import zh_CN from 'antd/lib/locale-provider/zh_CN';
5 |
6 | import Employee from './employee';
7 | import Setting from './setting';
8 | import './App.css';
9 |
10 | const { Header, Content, Footer } = Layout;
11 |
12 | const App = ({ match }: any) => {
13 | let defaultKey = match.url.replace('/', '') || 'employee';
14 | return
15 |
16 |
17 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | }
38 |
39 | export default App;
40 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/components/employee/index.css:
--------------------------------------------------------------------------------
1 | .table {
2 | margin-top: 20px;
3 | }
4 | .toolbar {
5 | margin: 20px 0;
6 | }
7 | .right {
8 | float: right;
9 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/components/setting/index.css:
--------------------------------------------------------------------------------
1 | .buttonWrap {
2 | margin: 20px 0;
3 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/components/setting/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Checkbox , Button } from 'antd';
3 |
4 | import './index.css';
5 |
6 | const Setting = () => {
7 | return (
8 | <>
9 | 新员工入职邮件提醒
10 |
11 |
12 |
13 | >
14 | )
15 | }
16 |
17 | export default Setting;
18 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/constants/actions.ts:
--------------------------------------------------------------------------------
1 | export const GET_EMPLOYEE = 'GET_EMPLOYEE';
2 | export const CREATE_EMPLOYEE = 'CREATE_EMPLOYEE';
3 | export const DELETE_EMPLOYEE = 'DELETE_EMPLOYEE';
4 | export const UPDATE_EMPLOYEE = 'UPDATE_EMPLOYEE';
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/constants/options.ts:
--------------------------------------------------------------------------------
1 | export const department = ['部门', '技术部', '产品部', '市场部', '运营部']
2 | export const level = ['职级', '1级', '2级', '3级', '4级', '5级']
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/constants/urls.ts:
--------------------------------------------------------------------------------
1 | export const GET_EMPLOYEE_URL = '/api/employee/getEmployee';
2 | export const CREATE_EMPLOYEE_URL = '/api/employee/createEmployee';
3 | export const DELETE_EMPLOYEE_URL = '/api/employee/deleteEmployee';
4 | export const UPDATE_EMPLOYEE_URL = '/api/employee/updateEmployee';
5 | export const DOWNLOAD_EMPLOYEE_URL = '/api/employee/downloadEmployee';
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { Provider } from 'react-redux';
4 |
5 | import Root from './routers';
6 | import store from './redux/store';
7 |
8 | ReactDOM.render(
9 |
10 |
11 | ,
12 | document.querySelectorAll('.app')[0]
13 | );
14 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/interface/employee.ts:
--------------------------------------------------------------------------------
1 | // getEmployee
2 | export interface EmployeeRequest {
3 | name?: string;
4 | departmentId?: number;
5 | }
6 | export interface EmployeeInfo {
7 | id: number;
8 | key: number;
9 | name: string;
10 | department: string;
11 | departmentId: number;
12 | hiredate: string;
13 | level: string;
14 | levelId: number;
15 | }
16 | export type EmployeeResponse = EmployeeInfo[] | undefined
17 |
18 | // createEmployee
19 | export interface CreateRequest {
20 | name: string;
21 | departmentId: number;
22 | hiredate: string;
23 | levelId: number;
24 | }
25 | export interface CreateResponse {
26 | id: number;
27 | key: number;
28 | }
29 |
30 | // updateEmployee
31 | export interface UpdateRequest {
32 | id: number;
33 | name: string;
34 | departmentId: number;
35 | hiredate: string;
36 | levelId: number;
37 | }
38 |
39 | // deleteEmployee
40 | export interface DeleteRequest {
41 | id: number;
42 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/redux/rootReducer.ts:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 |
3 | import employee from './employee';
4 |
5 | const reducers = {
6 | employee
7 | };
8 |
9 | export default combineReducers(reducers);
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/redux/store.ts:
--------------------------------------------------------------------------------
1 | import { createStore, compose, applyMiddleware } from 'redux';
2 | import thunk from 'redux-thunk';
3 |
4 | import rootReducer from './rootReducer';
5 |
6 | const store = createStore(rootReducer,
7 | compose(
8 | applyMiddleware(thunk)
9 | )
10 | );
11 |
12 | export default store;
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/routers/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { BrowserRouter, Route } from 'react-router-dom';
3 |
4 | import App from '../components/App';
5 |
6 | const Root = () => (
7 |
8 |
9 |
10 | )
11 |
12 | export default Root;
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/setupProxy.js:
--------------------------------------------------------------------------------
1 | const proxy = require('http-proxy-middleware');
2 |
3 | module.exports = function(app) {
4 | // app.use(proxy('/api', {
5 | // target: 'http://localhost:4000',
6 | // pathRewrite(path) {
7 | // return path.replace(/^\/api([^?]+)/, '$1.json');
8 | // }
9 | // }));
10 | app.use(proxy('/api', {
11 | target: 'http://localhost:4001'
12 | }));
13 | };
14 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/src/utils/request.ts:
--------------------------------------------------------------------------------
1 | import originAxios from 'axios';
2 | import { message } from 'antd';
3 |
4 | const axios = originAxios.create({
5 | timeout: 20000
6 | });
7 |
8 | axios.interceptors.response.use(
9 | function(response) {
10 | if (response.data && response.data.flag === 1) {
11 | /*
12 | successful response:
13 | {"flag": 0, "data": ""}
14 |
15 | unsuccessful response:
16 | {"flag": 1, "msg": "server error"}
17 | */
18 | let errorMsg = response.data.msg;
19 | message.error(errorMsg);
20 | return Promise.reject(errorMsg);
21 | }
22 | return response.data;
23 | },
24 | function(error) {
25 | return Promise.reject(error);
26 | }
27 | );
28 |
29 | export function get(url: string, data: any) {
30 | return axios.get(url, {
31 | params: data
32 | });
33 | };
34 |
35 | // By default, axios serializes JavaScript objects to JSON.
36 | export function post(url: string, data: any) {
37 | return axios({
38 | method: 'post',
39 | url,
40 | data
41 | });
42 | };
43 |
44 | export default axios;
45 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-redux/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "strictNullChecks": true,
15 | "forceConsistentCasingInFileNames": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "preserve"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(Vue 01节)代码
2 | ===============
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: 'cheap-module-eval-source-map'
3 | }
4 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 |
3 | module.exports = {
4 | plugins: [
5 | new CleanWebpackPlugin()
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts_base",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "./src/index.ts",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js"
9 | },
10 | "keywords": [
11 | "TypeScript",
12 | "Vue"
13 | ],
14 | "author": "liangxiao",
15 | "license": "ISC",
16 | "devDependencies": {
17 | "clean-webpack-plugin": "^3.0.0",
18 | "css-loader": "^3.2.0",
19 | "html-webpack-plugin": "^3.2.0",
20 | "ts-loader": "^6.0.2",
21 | "typescript": "^3.5.1",
22 | "vue-loader": "^15.7.1",
23 | "vue-template-compiler": "^2.6.10",
24 | "webpack": "^4.39.2",
25 | "webpack-cli": "^3.3.2",
26 | "webpack-dev-server": "^3.5.1",
27 | "webpack-merge": "^4.2.1"
28 | },
29 | "dependencies": {
30 | "vue": "^2.6.10",
31 | "vue-employee-query": "^1.0.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/src/components/Hello.vue:
--------------------------------------------------------------------------------
1 |
2 | Hello {{ name }}
3 |
4 |
5 |
15 |
16 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/src/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import Hello from './components/Hello.vue';
3 | import EmployeeQuery from 'vue-employee-query';
4 |
5 | // let app1 = new Vue({
6 | // el: '.app',
7 | // data: {
8 | // name: 'TypeScript'
9 | // },
10 | // template: `Hello {{ name }}
`
11 | // });
12 |
13 | // let app2 = new Vue({
14 | // el: '.app',
15 | // components: {
16 | // Hello
17 | // },
18 | // template: ``
19 | // });
20 |
21 | let app = new Vue({
22 | el: '.app',
23 | components: {
24 | EmployeeQuery
25 | },
26 | template: ``,
27 | data: {
28 | department: [
29 | { department: '技术部', departmentId: 1 },
30 | { department: '产品部', departmentId: 2 },
31 | { department: '市场部', departmentId: 3 },
32 | { department: '运营部', departmentId: 4 }
33 | ]
34 | },
35 | methods: {
36 | getParam: function(param: any) {
37 | console.log(param)
38 | }
39 | }
40 | });
41 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TypeScript in Action
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/ts-vue/src/vue-shims.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import Vue from 'vue'
3 | export default Vue
4 | }
5 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/README.md:
--------------------------------------------------------------------------------
1 | 实战篇(Vue 02-03节)代码
2 | ===============
3 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/build/webpack.base.config.js:
--------------------------------------------------------------------------------
1 | const VueLoaderPlugin = require('vue-loader/lib/plugin')
2 |
3 | module.exports = {
4 | output: {
5 | filename: 'employee-query.js'
6 | },
7 | resolve: {
8 | extensions: ['.js', '.ts', '.tsx', 'vue'],
9 | alias: {
10 | 'vue': 'vue/dist/vue.esm.js'
11 | }
12 | },
13 | module: {
14 | rules: [
15 | {
16 | test: /\.vue$/,
17 | loader: 'vue-loader'
18 | },
19 | {
20 | test: /\.tsx?$/,
21 | use: [{
22 | loader: 'ts-loader',
23 | options: {
24 | appendTsSuffixTo: [/\.vue$/]
25 | }
26 | }],
27 | exclude: /node_modules/
28 | },
29 | {
30 | test: /\.css$/,
31 | use: [
32 | 'vue-style-loader',
33 | 'css-loader'
34 | ]
35 | }
36 | ]
37 | },
38 | plugins: [
39 | new VueLoaderPlugin()
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/build/webpack.config.js:
--------------------------------------------------------------------------------
1 | const merge = require('webpack-merge')
2 | const baseConfig = require('./webpack.base.config')
3 | const devConfig = require('./webpack.dev.config')
4 | const proConfig = require('./webpack.pro.config')
5 |
6 | module.exports = (env, argv) => {
7 | let config = argv.mode === 'development' ? devConfig : proConfig;
8 | return merge(baseConfig, config);
9 | };
10 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/build/webpack.dev.config.js:
--------------------------------------------------------------------------------
1 | const HtmlWebpackPlugin = require('html-webpack-plugin')
2 |
3 | module.exports = {
4 | entry: './src/index.ts',
5 | devtool: 'cheap-module-eval-source-map',
6 | plugins: [
7 | new HtmlWebpackPlugin({
8 | template: './src/tpl/index.html'
9 | })
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/build/webpack.pro.config.js:
--------------------------------------------------------------------------------
1 | const { CleanWebpackPlugin } = require('clean-webpack-plugin')
2 | const nodeExternals = require('webpack-node-externals');
3 |
4 | module.exports = {
5 | entry: './src/main.ts',
6 | output: {
7 | libraryTarget: 'umd',
8 | library: 'EmployeeQuery'
9 | },
10 | externals: [nodeExternals()],
11 | plugins: [
12 | new CleanWebpackPlugin()
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-employee-query",
3 | "version": "1.0.1",
4 | "description": "",
5 | "main": "./dist/employee-query.js",
6 | "scripts": {
7 | "start": "webpack-dev-server --mode=development --config ./build/webpack.config.js",
8 | "build": "webpack --mode=production --config ./build/webpack.config.js"
9 | },
10 | "keywords": [
11 | "TypeScript",
12 | "Vue"
13 | ],
14 | "author": "liangxiao",
15 | "license": "ISC",
16 | "dependencies": {
17 | "vue": "^2.6.10",
18 | "vue-class-component": "^7.1.0",
19 | "vue-property-decorator": "^8.2.1"
20 | },
21 | "devDependencies": {
22 | "clean-webpack-plugin": "^3.0.0",
23 | "css-loader": "^3.2.0",
24 | "html-webpack-plugin": "^3.2.0",
25 | "ts-loader": "^6.0.4",
26 | "typescript": "^3.5.3",
27 | "vue-loader": "^15.7.1",
28 | "vue-template-compiler": "^2.6.10",
29 | "webpack": "^4.39.2",
30 | "webpack-cli": "^3.3.6",
31 | "webpack-dev-server": "^3.8.0",
32 | "webpack-merge": "^4.2.1",
33 | "webpack-node-externals": "^1.7.2"
34 | },
35 | "types": "./types/employee-query.d.ts"
36 | }
37 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/src/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import EmployeeQuery from './components/EmployeeQuery.vue';
3 |
4 | let app = new Vue({
5 | el: '.app',
6 | components: {
7 | EmployeeQuery
8 | },
9 | template: ``,
10 | data: {
11 | department: [
12 | { department: '技术部', departmentId: 1 },
13 | { department: '产品部', departmentId: 2 },
14 | { department: '市场部', departmentId: 3 },
15 | { department: '运营部', departmentId: 4 }
16 | ]
17 | },
18 | methods: {
19 | getParam: function(param: any) {
20 | console.log(param)
21 | }
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/src/main.ts:
--------------------------------------------------------------------------------
1 | import EmployeeQuery from './components/EmployeeQuery.vue';
2 | export default EmployeeQuery;
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/src/tpl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TypeScript in Action
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/src/vue-shims.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import Vue from 'vue';
3 | export default Vue
4 | }
--------------------------------------------------------------------------------
/typescript-in-action/sourcecode/vue-employee-query/types/employee-query.d.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 |
3 | declare class EmployeeQuery extends Vue {
4 | name: string
5 | selected: number
6 | department: { department: string, departmentId: number }[]
7 | query(): void
8 | }
9 |
10 | export as namespace EmployeeQuery
11 |
12 | export = EmployeeQuery
--------------------------------------------------------------------------------