指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
ts文件编译遍历太多的问题
目前问题是,nuxt3项目下,运行tsc --noEmit 之后,定义的server下的$fetch会报如下问题:
Type instantiation is excessively deep and possibly infinite.

检查发现是 typescript 里的一个参数是硬编码为5e6,解决办法是修改这个配置
sed -i.bak 's/5e6/9e6/g' ./node_modules/typescript/lib/tsc.js

官方也有人提过能不能将上面的参数做成一个配置参数,但是被微软拒绝了,如下:
https://github.com/microsoft/TypeScript/issues/34933
https://github.com/microsoft/TypeScript/pull/44997

调试问题:
可以在tsconfig.json 下加:
"traceResolution": true,
"extendedDiagnostics": true

如下:
{
  // https://nuxt.com/docs/guide/concepts/typescript
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "incremental": true,
    "types": [],
    "traceResolution": true,
    "extendedDiagnostics": true
  }
}

在terminal一下运行:
tsc --noEmit > ts-trace.log

得到如下结果:
../stores/ui/registration/registration-ticket.ts(645,5): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
../stores/ui/registration/registration-ticket.ts(646,3): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
../stores/ui/registration/registration-ticket.ts(647,49): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
Files:                         2387
Lines of Library:             49568
Lines of Definitions:        261448
Lines of TypeScript:          20852
Lines of JavaScript:          74930
Lines of JSON:                    0
Lines of Other:                   0
Identifiers:                 446642
Symbols:                     536003
Types:                       183451
Instantiations:            13455940 //但是这个数值并不是报错中的Instantiations
Memory used:                700197K
Assignability cache size:    102819
Identity cache size:           2603
Subtype cache size:            1044
Strict subtype cache size:     3269
I/O Read time:                0.17s
Parse time:                   1.97s
ResolveModule time:           1.00s
ResolveTypeReference time:    0.03s
ResolveLibrary time:          0.02s
Program time:                 3.65s
Bind time:                    1.11s
Check time:                  19.58s
I/O Write time:               0.00s
printTime time:               0.06s
Emit time:                    0.07s
Total time:                  24.40s