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

Decorator metadata is undefined #1421

Closed
millsp opened this issue Feb 21, 2021 · 1 comment · Fixed by #1444
Closed

Decorator metadata is undefined #1421

millsp opened this issue Feb 21, 2021 · 1 comment · Fixed by #1444
Assignees
Labels
Milestone

Comments

@millsp
Copy link

millsp commented Feb 21, 2021

Describe the bug

When using unions, or literal types, no decorator metadata is emitted.

Input code

import 'reflect-metadata';

const COL_KEY = Symbol('col');

const column = () => {
    return (object: any, key: string) => {
        Reflect.defineMetadata(COL_KEY, 'value', object, key);
    };
};

class User {
    @column() currency!: 'usd' | 'eur' | 'yen';
}

console.log(Reflect.getMetadata('design:type', User.prototype, 'currency')); // undefined
// should be String

Config

{
    "jsc": {
        "parser": {
            "syntax": "typescript",
            "tsx": false,
            "decorators": true,
            "dynamicImport": false
        },
        "transform": {
            "legacyDecorator": true,
            "decoratorMetadata": true
        }
    },
    "module": {
        "type": "commonjs"
    }
}

Expected behavior
String should have been emitted.

Version
The version of @swc/core: 1.2.47

Additional context
Add any other context about the problem here.

@millsp millsp added the C-bug label Feb 21, 2021
@kdy1 kdy1 added this to the v1.2.50 milestone Feb 27, 2021
@kdy1 kdy1 self-assigned this Mar 3, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
@kdy1 kdy1 closed this as completed in #1444 Mar 3, 2021
kdy1 added a commit that referenced this issue Mar 3, 2021
swc:
 - Respect `react` config.

swc_ecma_transforms_compat:
 - `export-namespace-from`: Preserve `use strict`. (#1423)

swc_ecma_transforms_module:
 - Inject `use strict` before imports. (#1423)

swc_ecma_transforms_proposal:
 - Emit metadata for literal types. (#1421)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 25, 2022

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 Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants