Skip to content

TS: re-exported types are not stripped properly #10618

@TrejGun

Description

@TrejGun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions