antd-dayjs-webpack-plugin icon indicating copy to clipboard operation
antd-dayjs-webpack-plugin copied to clipboard

antd-dayjs-webpack-plugin插件替换moment之后,TypeScript声明文件还是要求传参类型为moment.Moment

Open chj-damon opened this issue 5 years ago • 13 comments

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://github.com/chj-damon/transfer-bug-reproduce

Steps to reproduce

npm start

What is expected?

传参类型不限定moment.Moment

What is actually happening?

传参类型还是moment.Moment

Environment Info
antd 4.1.5
React 16.13
System MacOS Majave
Browser Chrome 81.0.4044.113

chj-damon avatar Apr 27 '20 08:04 chj-damon

@afc163 请教下 antd 的 定义文件是写死 moment.Moment type 的, 这种情况下使用了插件替换 alias ,是不是没啥好办法解决这个问题?

iamkun avatar Apr 27 '20 09:04 iamkun

看看有没有可能 extends 覆盖 antd 提供的类型。

afc163 avatar Apr 27 '20 09:04 afc163

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

GrayFrost avatar May 06 '20 03:05 GrayFrost

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

ChiaJune avatar May 19 '20 03:05 ChiaJune

as any 吧

Lizhooh avatar Jun 19 '20 01:06 Lizhooh

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

chenyuhu avatar Aug 09 '20 14:08 chenyuhu

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

+1

hr837 avatar Aug 13 '20 10:08 hr837

+1

0408jiahuicao avatar Sep 29 '20 06:09 0408jiahuicao

Seems there's nothing we can do until antd makes some change.

iamkun avatar Sep 29 '20 07:09 iamkun

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

+1

+1 能不能考虑干脆把Moment类替换成Dayjs类编译(虽然有点笨笨)

yokiguan avatar Oct 15 '20 07:10 yokiguan

[Facepalm] 我直接把 Moment 声明改成 Dayjs 了

declare module 'moment' {
  import { Dayjs } from 'dayjs'
  namespace moment {
    type Moment = Dayjs
  }
  export = moment
  export as namespace moment
}

大家有什么好的办法也请共享下,感谢~

chayin avatar Oct 18 '20 09:10 chayin

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

qluwlh avatar Mar 05 '21 10:03 qluwlh

我也遇到这样的情况,请问要怎么解决? I have same issue. Is there any solution to resolve this issue?

+1

Ray-56 avatar Jul 22 '21 06:07 Ray-56