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

wrong js code when using ts constructor assignment #11061

Open
wan2land opened this issue Jan 28, 2020 · 2 comments
Open

wrong js code when using ts constructor assignment #11061

wan2land opened this issue Jan 28, 2020 · 2 comments
Assignees

Comments

@wan2land
Copy link

@wan2land wan2land commented Jan 28, 2020

Bug Report

  • I would like to work on a fix!

Current Behavior
If a module imported from TypeScript has the same name as a constructor parameter, a bug occurs.

Input Code

import { messaging } from 'firebase-admin'

export class Something {
  constructor(
  	public messaging: messaging.Messaging
  ) {
  }
}

Expected behavior/code

Expected,

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Something = void 0;

class Something {
  constructor(messaging) {
    this.messaging = messaging;
  }

}

exports.Something = Something;

But actual,

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Something = void 0;

var _firebaseAdmin = require("firebase-admin");

class Something {
  constructor(_firebaseAdmin.messaging) { // Whoops!
    this.messaging = messaging;
  }

}

exports.Something = Something;

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: .babelrc
{
  "presets": [
    ["@babel/env", {
      "targets": "maintained node versions",
      "useBuiltIns": "usage",
      "corejs": 3
    }],
    "@babel/typescript"
  ]
}

Environment

  System:
    OS: macOS 10.15.2
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
  npmPackages:
    @babel/cli: ^7.8.3 => 7.8.3
    @babel/core: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-class-properties: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-decorators: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-object-rest-spread: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-optional-chaining: ^7.8.3 => 7.8.3
    @babel/preset-env: ^7.8.3 => 7.8.3
    @babel/preset-typescript: ^7.8.3 => 7.8.3
    eslint: ^6.2.2 => 6.2.2
    jest: ^24.9.0 => 24.9.0
  • Babel version(s): 7.8.3
  • Node/npm version: node 10.16.3 / npm 6.9.0
  • OS: macOS 10.15.2
  • Monorepo: no
  • How you are using Babel: cli

Possible Solution

Additional context/Screenshots
.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Jan 28, 2020

Hey @wan2land! 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."

@sidntrivedi012

This comment has been minimized.

Copy link
Contributor

@sidntrivedi012 sidntrivedi012 commented Feb 10, 2020

I would like to help out to fix this. Please assign it to me. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.