导入导出

  • 用星号(*)指定一个对象,所有输出值都加载在这个对象上面
    • import * as foo from './foo';
  • 从其他模块导入后整体导出
    • export * from './foo';
  • 从其他模块导入后,部分导出

    • export { someVar } from './foo';

      动态查找

      当导入路径不是相对路径时,模块解析将会模仿 Node 模块解析策略,下面我将给出一个简单例子:
  • 当你使用 import * as foo from ‘foo’,将会按如下顺序查找模块:

    • ./node_modules/foo
    • ../node_modules/foo
    • ../../node_modules/foo
    • 直到系统的根目录
  • 当你使用 import * as foo from ‘something/foo’,将会按照如下顺序查找内容
    • ./node_modules/something/foo
    • ../node_modules/something/foo
    • ../../node_modules/something/foo
    • 直到系统的根目录

image.png
JSNext is open to interpretation - not everything proposed for the next version of JS actually makes it to browsers. TypeScript only adds support for proposals once they reach stage 3.

TODO


//css
transition 不是所有属性都支持,且只能做两个值的补间
animation 可以做多个值的补间
element.animate

实现react的keep-alive

Record
image.png

infer
unknown

ts的写法写函数算法,一般先用functional的方式写一遍,然后使用type的方式转换

type challenge
image.png

https://docs.microsoft.com/en-us/learn/modules/typescript-get-started/
https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAQwCaoHIgLYCMCmATgM4AUAHgFxg4GEA0iAntbUQJSIDeAUIooXxQQhJOUQBqZgG4eAXx48ICYnAA2+AHRq4Ac1JpMbEqQDMjAGzt20oA
image.png

?
枚举
https://docs.microsoft.com/en-us/learn/modules/typescript-declare-variable-types/4-enums