Deno 和 TypeScipt 一起使用
Deno 可以直接运行 TypeScript 的 TS 文件,在我们学习 TypeScript 的时候可以使用 Deno 作用运行时。
Deno VSCode 插件
Deno 官方出了 vscode 插件,来帮我们更好的使用 deno。但是有点就是,deno 项目和node 项目打开的时候,deno会进行检查,提出提示。目前还是以node为主,deno为辅,将Deno插件禁用,仅仅在需要的项目里打开。
deno 中的 TypeScript 默认配置
{
"compilerOptions": {
"allowJs": false,
"allowUmdGlobalAccess": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"assumeChangesOnlyAffectDirectDependencies": false,
"checkJs": false,
"disableSizeLimit": false,
"generateCpuProfile": "profile.cpuprofile",
"jsx": "react",
"jsxFactory": "React.createElement",
"lib": [],
"noFallthroughCasesInSwitch": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitUseStrict": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveConstEnums": false,
"removeComments": false,
"resolveJsonModule": true,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"suppressExcessPropertyErrors": false,
"suppressImplicitAnyIndexErrors": false,
"useDefineForClassFields": false
}
}
我们看到并没有将装饰器包含在里面,当我们需要装饰器的支持的时候,自定一个 tsconfig.json 然后使用,将配置随命令行一起使用:
# --config
deno run --config ./tsconfig.json ./src/main.ts
# -c 简短的写法
deno run --config ./tsconfig.json ./src/index.ts