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

TS: imported types are not stripped properly #10618

Open
TrejGun opened this issue Oct 31, 2019 · 1 comment

Comments

@TrejGun
Copy link

@TrejGun TrejGun commented Oct 31, 2019

Bug Report

Current Behavior
Imported types are not stripped for decorated method's params

Input Code

import {Controller} from "@nestjs/common";
import {MessagePattern} from "@nestjs/microservices";
import {EventLog} from "web3/types";


@Controller()
export class EthereumController {

  @MessagePattern("EVENT")
  public contract(data: EventLog): any {
    return data;
  }
}

Expected behavior/code
EventLog (web3/types) should be stripped out

Babel Configuration (.babelrc, package.json, cli command)

{
  "plugins": [
    "babel-plugin-transform-typescript-metadata",
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ],
    [
      "@babel/plugin-proposal-class-properties",
      {
        "loose": true
      }
    ],
    "babel-plugin-parameter-decorator"
  ],
  "presets": [
    [
      "@babel/env",
      {
        "targets": {
          "node": "current"
        }
      }
    ],
    "@babel/typescript"
  ]
}

It does not work even without babel-plugin-parameter-decorator

Environment

    "@babel/preset-typescript": "7.6.0",
    "@babel/preset-env": "7.6.3",
    "@babel/core": "7.6.4",
    "@babel/plugin-proposal-class-properties": "7.5.5",
    "@babel/plugin-proposal-decorators": "7.6.0",
    "babel-plugin-parameter-decorator": "1.0.10",
    "babel-plugin-transform-typescript-metadata": "0.2.2",
  • Babel version(s): ^^^
  • Node/npm version: v12.10.0
  • OS: OSX 10.14.6
  • Monorepo: Lerna
  • How you are using Babel: babel-watch

Possible Solution
I was able to work arround by redeclaring type

import {Controller} from "@nestjs/common";
import {MessagePattern} from "@nestjs/microservices";
import {EventLog} from "web3/types";


declare type IEventLog = EventLog;

@Controller()
export class EthereumController {

  @MessagePattern("EVENT")
  public contract(data: IEventLog): any {
    return data;
  }
}

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Oct 31, 2019

Hey @TrejGun! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.