Skip to content

The type of imported TS file, with enumeration increasing to undefined #8147

@blockmood

Description

@blockmood

Describe the bug

If I import an import file into another enumeration value, it will cause problems

Input code

export enum ModalType {
  'PLACE' = 1,
  'FULLFILL',
  'ROLLBACK',
  'ARCHIVED',
  'HANDLE_CANCEL',
  'PAYMENT',
}

import { ModalType } from '../modal/interface';

export enum StatusTabType {
  'placeOrder' = ModalType.PLACE,
  'fullfilled' = ModalType.FULLFILL,
  'rollback' = ModalType.ROLLBACK,
  'archive' = ModalType.ARCHIVED,
  'moreAccount',
  'sendEmail',
  'handleCancel',
  'payment',
  'processOrders',
  'fullfillStatus',
  'cancelBy',
  'agncyType',
  'agncyCancelOrder',
  'agncymakePaid',
  'uploadTrackingNo',
}

console.log([
    StatusTabType.archive,
    StatusTabType.payment,
    StatusTabType.rollback,
    StatusTabType.fullfilled,
    StatusTabType.placeOrder,
    StatusTabType.sendEmail,
    StatusTabType.handleCancel,
  ]);

out

[4, undefined, 3, 2, 1, undefined, undefined]
But it's not a problem for me to import values without importing them


### Config

```json
const { loaderByName, removeLoaders, addAfterLoader } = require('@craco/craco');

module.exports = {
  overrideWebpackConfig: ({
    webpackConfig,
  }) => {
    addAfterLoader(webpackConfig, loaderByName('babel-loader'), {
      test: /\.(js|mjs|jsx|ts|tsx)$/,
      exclude: /(node_modules)/,
      use: {
        loader: "swc-loader",
        options: {
          jsc: {
            externalHelpers: true,
            target: 'es2015',
            parser: {
              "syntax": "typescript",
              "tsx": false,
              "decorators": false,
              "dynamicImport": false
            },
            transform: {
              react: {
                runtime: 'automatic'
              }
            },
            experimental: {
              "plugins": [
                [
                  "swc-plugin-another-transform-imports",
                  {
                    "antd": {
                      "transform": "antd/lib/${member}",
                      "skipDefaultConversion": false,
                      "preventFullImport": true,
                      "style": "antd/lib/${member}/style",
                      "memberTransformers": ["dashed_case"]
                    },
                  }
                ]
              ]
            }
          }
        },
      }
    })
    removeLoaders(webpackConfig, loaderByName('babel-loader'));
    return webpackConfig;
  },
};

Playground link (or link to the minimal reproduction)

https://github.com/blockmood/swc-enum-import-error

SWC Info output

No response

Expected behavior

[4, 8, 3, 2, 1, 6, 7]

Actual behavior

[4, undefined, 3, 2, 1, undefined, undefined]

Version

1.3.93

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions