王树贤
王树贤
### tsconfig.json 配置 #### wepy中配置使用装饰器 ```JSON { "compilerOptions": { "experimentalDecorators": true, "allowJs": true } } ``` *** #### wepy中配置使用 @ 路径简写 >https://www.typescriptlang.org/docs/handbook/module-resolution.html ```JSON { "compilerOptions": { "baseUrl": ".", "paths": {...
### typescript 声明文件 可以在这个页面搜索你需要的声明文件 >http://microsoft.github.io/TypeSearch/ *** >https://ts.xcatliu.com/basics/declaration-files.html >wx.d.ts ```typescript declare let wx:any ``` *** >微信小程序 类型声明文件库 >https://www.npmjs.com/package/@types/weixin-app >npm install --save-dev @types/weixin-app >https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/weixin-app *** >微信 网页开发 JSSDK >https://github.com/Microsoft/TypeScript-WeChat-Starter >A starter template...
> TypeScript 中使用 import 导入 commonJs 格式包 ```typescript import * as crypto from 'crypto-js' crypto.MD5(paramsFianl).toString().toUpperCase() ``` *** > 声明参数默认值 ```typescript function test(a: string, b: string, c: string = '123') {...
### TypeScript 基础类型 >Declare >https://www.tslang.cn/docs/handbook/basic-types.html ```typescript let isDone: boolean = false let decLiteral: number = 6 let name: string = "bob" let list: number[] = [1, 2, 3] let list:...
### TypeScript 类型断言 >类型断言好比其它语言里的类型转换,但是不进行特殊的数据检查和解构。 它没有运行时的影响,只是在编译阶段起作用。 >类型断言有两种形式 >“尖括号”语法 ```typescript let someValue: any = "this is a string" let strLength: number = (someValue).length ``` >as 语法 >在TypeScript里使用JSX时,只有 as语法断言是被允许的 ```typescript let someValue: any...
### error >TS2304: cannot find name require and process >https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15329 ``` Don't think it's a bug; think it's a config issue. Try adding this line at the top of main.ts:...
### TypeScript 基础 #### tsc ```bash $ tsc --outDir dirName $ tsc --outDir dirName compileName # 指定输出输入位置 $ tsc --init # tsconfig.json $ tsc -w # 动态监视 $ ts-node file...
#### 深入理解 TypeScript >https://jkchao.github.io/typescript-book-chinese/typings/enums.html
#### typescript 内置对象 >canvasEl: HTMLCanvasElement >e:MouseEvent ```ts const canvasEl= document.getElementById('main-canvas') || document.createElement('canvas') ```
#### ts >在命令行中执行 tsc --init 可以在当前目录中快速创建一个 tsconfig.json 文件. ```bash npm init -y npm install typescript -D tsc --init ``` >生成 ```tsconfig.json { "compilerOptions": { /* Basic Options */ "target": "es5",...