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

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

Open
yunqiangwu opened this issue Sep 29, 2022 · 1 comment

Comments

@yunqiangwu
Copy link

yunqiangwu commented Sep 29, 2022

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

@zzuhit
Copy link

zzuhit commented Jan 11, 2023

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

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

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

No branches or pull requests

2 participants