nmsn

Results 104 issues of nmsn

- T:代表 Type,定义泛型时通常用作第一个类型变量名称 - K:代表 Key,表示对象中的键类型; - V:代表 Value,表示对象中的值类型; - E:代表 Element,表示的元素类型;

TypeScript

- `.ts` 使用 `typescript` 开发使用的文件类型 - `.d.ts` ts 的声明文件 - `declare` 声明修饰符 当我们想使用 `typescript` 开发时只需要使用 `.ts` 后缀文件开发即可,不需要特别编写 `.d.ts` 文件或者使用 `declare` 修饰符。 当我们使用 `tsc --declaration` 或者在 `tsconfig.json` 中配置 `declaration:true` 时会生成 `xxx.ts`...

TypeScript

https://stackoverflow.com/questions/42260218/jest-setup-syntaxerror-unexpected-token-export

Jest

来源:https://nodejs.org/dist/latest-v8.x/docs/api/process.html#process_process_env ```js process.env.test = null; console.log(process.env.test); // => 'null' process.env.test = undefined; console.log(process.env.test); // => 'undefined' ```

Node

> 来源:https://github.com/SunshowerC/blog/issues/8 - main : 定义了 npm 包的入口文件,browser 环境和 node 环境均可使用 - module : 定义 npm 包的 ESM 规范的入口文件,browser 环境和 node 环境均可使用 - browser : 定义 npm 包在 browser 环境下的入口文件

JavaScript

> 来源:https://medium.com/@martin_hotell/10-typescript-pro-tips-patterns-with-or-without-react-5799488d6680 Don't ``` SkaterBoy.tsx userAccessHandlers.ts ``` Do ``` skater-boy.tsx user-access-handlers.ts ``` 1. 可读性更好 文中说 my-half-fixed-deduped-dir-resolver vs MyHalfFixedDedupedDirResolver,我觉得差不多 3. git 更友好(git 默认不区分文件名大小写) 我觉得这个才是关键点 5. 一致性(存疑) > consistency (I don’t have...

React

> 来源:https://react-typescript-cheatsheet.netlify.app/docs/basic/troubleshooting/types 1. 获取组件 props ```tsx import { Button } from "library"; // but doesn't export ButtonProps! oh no! type ButtonProps = React.ComponentProps; // no problem! grab your own! type...

TypeScript
React

> 来源:https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/default_props/ 不推荐使用 defaultProps 来定义组件的默认值, 而是使用对象默认值 ```tsx type GreetProps = { age?: number }; const Greet = ({ age = 21 }: GreetProps) => // etc ``` 使用 defaultProps 会存在这样的问题:...

TypeScript

## 类型判断 `typeof` 处理一些基础类型的数据 `string | number | bigint | boolean | symbol | undefined | object | function` ```ts type Val = string | number; const getValType = (val:...

TypeScript

## ReactElement ReactElement 是含有 props 和 type 属性的对象: ```ts interface ReactElement { type: T; props: P; key: Key | null; } ``` ## ReactNode ReactNode 则是多种类型的集合: ```ts type ReactText =...

React