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

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

Closed
blockmood opened this issue Oct 19, 2023 · 4 comments
Closed
Labels
Milestone

Comments

@blockmood
Copy link

blockmood commented Oct 19, 2023

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

@kdy1
Copy link
Member

kdy1 commented Oct 19, 2023

This looks like a bug in the TypeScript language itself. It does not have a specification, but such an enum cannot be handled with isolatedModules enabled.

@kdy1 kdy1 removed their assignment Oct 20, 2023
@blockmood
Copy link
Author

@kdy1 Could you please repair it as soon as possible? It's affecting our project now

@kdy1
Copy link
Member

kdy1 commented Oct 23, 2023

@blockmood Did you pay me?

@kdy1 kdy1 modified the milestones: Planned, v1.3.95 Oct 24, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Nov 23, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants