掘友等级
获得徽章 8
开始做移动端,原有的项目框架是 React Native,有没有过来人讲一下有什么坑
@每日英语7
Item 7: Think of Types as Sets of Values
- Think of types as sets of values(the type's domain). These sets can either be finite(e.g., boolean or literal types) or infinite(e.g., number or string)
- 思考值设置的类型(类型的有限范围)。这些设置不单可以是有限的(boolean 或者 文字类型)而且可以说无限的(number 或者 string)
- TypeScript types form intersecting sets rather than a strict hierarchy. Two types can overlap without either being a subtype of the other.
- TS 的类型构建与相交的设置而不是严肃的登记制。两种类型可以重叠而不需要一方称为另外一方的子类型
- Remember that an object can still belong to a type even if it has additional properties that were not mentioned in the type declaration
- 记住一个对象仍然属于它之前配置了类型,即便它有了额外的在类型声明中没有被提及的属性
- Type operations apply to a set's domain. The intersection of A and B is the intersection of A's domain and B's domain. For object types, this means that values in A & B have the properties of both A and B
- 类型运行适用于设置的领域。A 和 B 的交集就是 A 领域和 B 领域的交集。对于一个对象类型的值,这意味着这个值在 A & B 类型中,就需要同时拥有 A 和 B 的属性
@每日英语6
Item6: Use Your Editor to Interrogate and Explore the Type System
- Take advantage of the Typescript language services by using an editor that can use them.
- 通过使用编辑器在 TS 语言系统中获取优势,编辑器可以使用 TS 语言系统;
- Use your editor to build an intuition for how the type system works and how Typescript infers types.
- 使用你的编辑器去构建一个直觉,类型是怎么样运行的,TS 怎样推断出类型的。
- Know how to jump into type declaration files to see how they model behavior
- 知道怎么条件类型断言文件去查看它们如何塑造行为。
@每日英语5
Limit Use of the any type
The any type effectively silences the type checker and Typescript language services. It can mask real problems, harm developer experience, and undermine confidence in the type system. Avoid using it when you can!
@每日英语4
Get Comfortable with Structural Typing
- Understanding that Javascript is duck typed and Typescript uses structural typing to model this: values assignable to your interfaces might have properties beyond those explicitly listed in your type declaration. Types are not "sealed".
- Be aware that classes also follow structural typing rules. You may not have an instance of the class you expect.
- Use structural typing to facilitate unit testing.
@每日英语3Understand That Code Generation Is Independent Of Types
- Code generation is independent of type system. This means that Typescript types cannot affect the runtime behavior or performance of your code.
- It is possible for a program with type errors to build code
- Typescript types are not available at runtime. To query a type at runtime, you need some way to reconstruct it. Tagged unions and property are common ways to do this. Some constructs, such as class, introduce both a Typescript type and a value that is available at runtime.
@每日英语2
Know Which Typescript Options You're Using
- The Typescript compiler includes several settings which affect core aspects of the language
- TS 编译器包含了很多可以影响 ts 核心方面的设置
- Configure Typescript using tsconfig.json rather than command-line options
- 使用 tsconfig.json 来配置 TS 而不是命令行属性
- Turn on noImplicitAny unless you are transitioning a Javascript project to Typescript;
- 除非你正在从JS 转移到 TS,否则打开 noImplicitAny 配置
- Use strictNullChecks to prevent "undefined is no an object" style runtime error
- 使用 strictNullChecks 配置来保护 "undefined 不是对象"这类型的运行时错误
- Aim to enable strict to get the most thorough checking that Typescript can offer
- 以 TS 能够提供的,可以使得项目能得到更严厉彻底的检测为目标;
@每日英语1
Understand the Relationship between Typescript and Javascript
- Typescript is a superset of Javascript. In other words, all Javascript programs are already Typescript programs. Typescript has some syntax of its own, so Typescript programs are not, in general, valid Javascript programs.
- Typescript adds a type system that models Javascript's runtime behavior and tries to spot code which will throw exceptions at runtime. But you shouldn't expect it to flag every exception. It is possible for code to pass the type checker but still throw at runtime.
- While Typescript's type system largely models Javascript behavior, there are some constructs that Javascript allows but Typescript chooses to bar, such as calling functions with the wrong number of arguments. This is largely a matter of taste.
为自己组推一波啊,杭州字节,抖音-小程序IDE侧,硬性应该就是本科,组内大佬说了基本不会乱问,都是基于你简历开问,所以有需要的可以加 V: ZYSQ_LYX ;如果不 care 年终,其实现在年末面试比较好,竞争少
下一页