如何学习ts?lib.es5.d.ts

    • ts改java的设计模式

    前端工种:

    • 原生、vue2、vue3、react
    • node
      • pm2启动cli ts-node
      • gulp编译
    • web

    新名词:
    swc
    esbuild
    v8-compile-cahche + sparking


    数据库连接池

    SOLID

    1. // 产品类
    2. class Product {
    3. deliver () {
    4. console.log('运输')
    5. }
    6. }
    7. class Truck extends Product {
    8. deliver () {
    9. console.log('陆运')
    10. }
    11. }
    12. class Ship extends Product {
    13. deliver () {
    14. console.log('海运')
    15. }
    16. }
    17. // 工厂类
    18. class SimpleFactory {
    19. create (type) {
    20. if (type == 'truck') {
    21. return new Truck();
    22. } else if (type == 'ship') {
    23. return new Ship();
    24. }
    25. }
    26. }
    27. let t = new SimpleFactory();
    28. t.create('truck').deliver();
    29. let s = new SimpleFactory();
    30. s.create('ship').deliver();
    31. // 陆运
    32. // 海运

    控制翻转 IoC

    1. var factory = {};
    2. factory.car = function () {
    3. console.log('car');
    4. }
    5. factory.plane = function () {
    6. console.log('plane');
    7. }
    8. factory.manage = function (create) {
    9. return new factory[create]();
    10. }
    11. let car = factory.manage('car');
    12. let plane = factory.manage('plane');
    13. // car
    14. // plane

    系统约束 command键快速跳入

    1. var a = Symbol('Jack');
    2. console.log(a.description);
    3. // Property 'description' does not exist on type 'symbol'
    4. // compiler option to 'es2019' or later
    5. console.log(a.toString()); // Symbol(Jack)
    6. function showWarning(msg: string, mode: typeof a) {
    7. console.log(mode.description);
    8. }
    1. const textEl = document.querySelector('input');
    2. // console.log(textEl.value); // Object is possibly 'null'
    3. // 常规方式, 先判断,
    4. if (textEl != null) {
    5. textEl.addEventListener('click', e => {
    6. console.log(e.clientX);
    7. })
    8. console.log(textEl.value);
    9. }
    10. // 屏蔽null
    11. const text2 = <HTMLInputElement>document.querySelector('input');
    12. console.log(text2.value);