Skip to content

Commit cf49833

Browse files
committed
docs(typescript): add solution for typescript compile error
1 parent 4e34b9e commit cf49833

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.vitepress/theme/styles/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ body {
1010
.vp-doc li + li {
1111
text-align: justify;
1212
}
13+
14+
.vp-doc .custom-block a {
15+
text-decoration: underline;
16+
}

docs/changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ outline: 'deep'
88

99
考虑到后面还会不定期更新内容,所以翻了一下之前跟朋友的微信聊天记录整理了前期的更新记录,之后当文档有再次更新的时候也会继续整理更新记录,方便读者们查阅。
1010

11+
## 2024-04-06
12+
13+
[快速上手 TypeScript](typescript.md) 一章里的 “如何编译为 JavaScript 代码” 一节,对 build script 中新增了一个选项 `--skipLibCheck` ,关于这个改动请见 [干净的 TypeScript 项目在编译时报错 Cannot find module 'undici-types' 的原因和解决](https://chengpeiquan.com/article/typescript-error-cannot-find-module-undici-types.html) 一文。
14+
15+
感谢 [@rainmonG](https://github.com/rainmonG)[#193 (comment)](https://github.com/chengpeiquan/learning-vue3/issues/193#issuecomment-2036541817) 的反馈。
16+
1117
## 2024-02-20
1218

1319
[单组件的编写](component.md)[路由的使用](router.md)[插件的开发和使用](plugin.md)[组件之间的通信](communication.md)[全局状态管理](pinia.md) 这几张内容的最前面,补充了一个阅读提示,解答近期收到的读者反馈的一些疑惑。
@@ -40,7 +46,7 @@ outline: 'deep'
4046

4147
## 2022-11-17
4248

43-
更新了 “用 ES Module 设计模块” 中关于 [命名导出和导入](guide.md#命名导出和导入-1) 的讲解,减少在理解上的歧义,感谢 [@Yeshan-Taoist](https://github.com/Yeshan-Taoist)[#163 (commont)](https://github.com/chengpeiquan/learning-vue3/issues/163#issuecomment-1317193359) 的反馈。
49+
更新了 “用 ES Module 设计模块” 中关于 [命名导出和导入](guide.md#命名导出和导入-1) 的讲解,减少在理解上的歧义,感谢 [@Yeshan-Taoist](https://github.com/Yeshan-Taoist)[#163 (comment)](https://github.com/chengpeiquan/learning-vue3/issues/163#issuecomment-1317193359) 的反馈。
4450

4551
## 2022-11-12
4652

docs/typescript.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ foo = true // true
11791179
"dev:cjs": "node src/cjs/index.cjs",
11801180
"dev:esm": "node src/esm/index.mjs",
11811181
"dev:ts": "ts-node src/ts/index.ts",
1182-
"build": "tsc src/ts/index.ts --outDir dist",
1182+
"build": "tsc src/ts/index.ts --skipLibCheck --outDir dist",
11831183
"compile": "babel src/babel --out-dir compiled",
11841184
"serve": "node server/index.js"
11851185
},
@@ -1201,6 +1201,10 @@ foo = true // true
12011201
12021202
其中 `tsc` 是 TypeScript 用来编译文件的命令, `--outDir` 是它的一个选项,用来指定输出目录,如果不指定,则默认生成到源文件所在的目录下面。
12031203
1204+
:::tip
1205+
笔者 2024-04-06 注:在 build script 中新增了一个选项 `--skipLibCheck` ,关于这个改动请见 [干净的 TypeScript 项目在编译时报错 Cannot find module 'undici-types' 的原因和解决](https://chengpeiquan.com/article/typescript-error-cannot-find-module-undici-types.html) 一文。
1206+
:::
1207+
12041208
把之前在 [函数的重载](#函数的重载) 用过的这个例子放到 `src/ts/index.ts` 文件里,因为它是一段比较典型的、包含了多个知识点的 TypeScript 代码:
12051209
12061210
```ts
@@ -1381,7 +1385,7 @@ Welcome, Petter!
13811385
// ...
13821386
"scripts": {
13831387
// ...
1384-
"build": "tsc src/ts/index.ts --outDir dist --target es6"
1388+
"build": "tsc src/ts/index.ts --skipLibCheck --outDir dist --target es6"
13851389
}
13861390
// ...
13871391
}

0 commit comments

Comments
 (0)