babel-plugin-import icon indicating copy to clipboard operation
babel-plugin-import copied to clipboard

babel-plugin-import 对 ts语法 ( Com as any ) 和 带装饰器的 class extends Com 支持有问题

Open yunqiangwu opened this issue 1 year ago • 1 comments

babel config:

{
  "plugins": [
    ["@babel/plugin-transform-typescript", { "legacy": true }],
    [
      "babel-plugin-import",
      {
        "libraryName": "antd",
        "libraryDirectory": "lib",
        "style": true
      },
      "c7n-pro"
    ],
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ]
}

source js:

import { observer } from 'mobx-react';
import { Button } from 'antd';

@observer
export default class TestAaa extends RichText {
  hello() {
    console.log({
      Button: (Button as any)
    });
    console.log({
      Button,
    });
    const MyButton = { ...Button };
  }
}

babel transpiled:

import "antd/lib/button/style";
import _Button from "antd/lib/button";

var _class;

import { observer } from 'mobx-react';

let TestAaa = observer(_class = class TestAaa extends RichText {
  hello() {
    console.log({
      Button: Button
    });
    console.log({
      Button: _Button
    });
    const MyButton = { ...Button };
  }

}) || _class;

export { TestAaa as default };

第 11 行代码应该是 _Button 才对, 这里却变成了 Button

相关依赖版本: image

bug online demo (重现的在线链接): bug online demo

image

yunqiangwu avatar Sep 29 '22 12:09 yunqiangwu

[ "babel-plugin-import", { "libraryName": "antd", "libraryDirectory": "lib", "style": true }, "c7n-pro" ]

中 "c7n-pro" 这个参数值 代表什么意思的呢?

zzuhit avatar Jan 11 '23 02:01 zzuhit