Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义的d.ts在运行状态下被改变,结果没有生效 #6047

Closed
gds-prue opened this issue Nov 10, 2020 · 7 comments
Closed

自定义的d.ts在运行状态下被改变,结果没有生效 #6047

gds-prue opened this issue Nov 10, 2020 · 7 comments

Comments

@gds-prue
Copy link

Version

4.5.8

Reproduction link

https://github.com/gds-prue/ceshi/tree/master/vue3

Environment info

System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 10.13.0 - /usr/local/bin/node
    Yarn: 1.22.10 - ~/learning/ceshi/node_modules/.bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Browsers:
    Chrome: 86.0.4240.193
    Edge: Not Found
    Firefox: Not Found
    Safari: Not Found
  npmPackages:
    @vue/cli: ^4.5.8 => 4.5.8 
    @vue/cli-shared-utils:  4.5.8 
    @vue/cli-ui:  4.5.8 
    @vue/cli-ui-addon-webpack:  4.5.8 
    @vue/cli-ui-addon-widgets:  4.5.8 
    @vue/compiler-core:  3.0.3 
    @vue/compiler-dom:  3.0.3 
    @vue/compiler-sfc:  3.0.3 
    @vue/compiler-ssr:  3.0.3 
    @vue/reactivity:  3.0.3 
    @vue/runtime-core:  3.0.3 
    @vue/runtime-dom:  3.0.3 
    @vue/shared:  3.0.3 
    typescript:  3.9.7 
    vue:  2.6.12 (3.0.3)
    vue-cli-plugin-apollo:  0.21.3 
    vue-codemod:  0.0.4 
  npmGlobalPackages:

Steps to reproduce

  1. npm run serve 一切正常
  2. 修改/src/ceshi.module.css.d.ts 中 ceshi8 为 ceshi7 保存
  3. 修改/src/main.ts中 const a = styles.ceshi8 为 const a = styles.ceshi7;保存

What is expected?

第2步保存时报错、第3步保存时正常

What is actually happening?

第2步保存时正常、第3步保存时编译报错

@haoqunjiang
Copy link
Member

https://github.com/gds-prue/ceshi/blob/97db115dccbaa59b4d93eb71934ac84872f7e5f7/vue3/tsconfig.json#L9

v4.5 起,新生成的项目里都开启了 skipLibCheck 这个选项,所以编译期不再对 .d.ts 进行类型检查。具体原因可以看 PR 里的那些链接。

@fangbinwei
Copy link
Collaborator

fangbinwei commented Nov 10, 2020

fork-ts-checker-webpack-pluginv6版本(要求Node 10以上)中解决了这种Type-Only modules watching的问题, 测试了下有效. TypeStrong/fork-ts-checker-webpack-plugin#36 (comment)

skipLibCheck应该没有关系, skipLibCheck能够忽略声明文件中的类型错误, demo中/src/ceshi.module.css.d.ts 声明文件中并无类型错误. 这里问题在于demo里声明文件的修改没有触发ts-checker.

CLI升级插件应该能解决问题

用yarn的话可以这样应付(针对@vue/[email protected])

  "resolutions": {
    "fork-ts-checker-webpack-plugin-v5": "npm:fork-ts-checker-webpack-plugin@^6.0.0"
  }

@gds-prue
Copy link
Author

gds-prue commented Nov 11, 2020

请教下、如何关闭运行时的类型校验么。我想两种都试试,一种关闭校验、一种尝试@fangbinwei 的方法, 但是我有一个问题、我不用yarn

@HWWWWWT
Copy link

HWWWWWT commented Nov 12, 2020

大胸弟,解决了吗~, 新版webpack好像不会收集导出 Type.ts 的文件依赖

@Forever17s
Copy link

大胸弟,解决了吗~, 新版webpack好像不会收集导出 Type.ts 的文件依赖

image
亲试有效,先作为临时解决方案吧

@fangbinwei
Copy link
Collaborator

目前cli 5.0.0-apha.0已经解决这个问题, 可以尝试升级@vue/[email protected]

npm i @vue/[email protected] -D

@SmileAjh
Copy link

SmileAjh commented Oct 22, 2021

npm i @vue/[email protected] -D
这种方式在windows下有效,在mac上无效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants