Skip to content

[Bug]: Nested workspaces can't be defined with dot notation #13663

@GeneZharov

Description

@GeneZharov

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

// Works
namespace proj {
  namespace data {
    namespace util {
      namespace api {
        console.log("JJJJ");
      }
    }
  }
}

// Doesn't work
namespace proj.data.util.api {
  console.log("JJJJ");
}

Configuration file name

No response

Configuration

{
  "presets": [
    "@babel/preset-typescript"
  ]
}

Current and expected behavior

Nested workspaces definition with dot notation works fine with tsc but crushes Babel.

TypeError: /Users/gene/_/j/project/packages/gas/src/data/util/auth.ts: @babel/template placeholder "$1": Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "TSModuleBlock"
    at Object.validate (/Users/gene/_/j/project/node_modules/@babel/types/lib/definitions/utils.js:130:11)
    at validateField (/Users/gene/_/j/project/node_modules/@babel/types/lib/validators/validate.js:24:9)
    at validate (/Users/gene/_/j/project/node_modules/@babel/types/lib/validators/validate.js:17:3)
    at builder (/Users/gene/_/j/project/node_modules/@babel/types/lib/builders/builder.js:38:27)
    at Object.expressionStatement (/Users/gene/_/j/project/node_modules/@babel/types/lib/builders/generated/index.js:320:31)
    at applyReplacement (/Users/gene/_/j/project/node_modules/@babel/template/lib/populate.js:82:27)
    at /Users/gene/_/j/project/node_modules/@babel/template/lib/populate.js:32:7
    at Array.forEach (<anonymous>)
    at populatePlaceholders (/Users/gene/_/j/project/node_modules/@babel/template/lib/populate.js:30:43)
    at /Users/gene/_/j/project/node_modules/@babel/template/lib/literal.js:35:53 {
  code: 'BABEL_TRANSFORM_ERROR'
}

Environment

Babel version: 7.15.0
OS: macOS 11.5.1
Node: 12.22.1
Yarn: 1.22.10
npm: 6.14.12
Yarn Workspaces: 1.22.10

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: typescriptoutdatedA 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