Skip to content

[Bug]: @babel/preset-typescript compile ts file error #15796

@Cola-Zhang

Description

@Cola-Zhang

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

export namespace ui.answer.box {
	export class BoxDialogUI {
	
	}
   
	export class RewardDialogUI {
	}
}
export namespace ui.answer.common {
	export class ActOpenDialogUI {
	
	}
}

Configuration file name

No response

Configuration

file name: TestUI.ts

Current and expected behavior

babel --presets @babel/preset-typescript TestUI.ts

TypeError: /Users/zhangbaokun/Documents/game-subpackage-test/src/app/TestUI.ts: Property body of TSModuleDeclaration expected node to be of a type ["TSModuleBlock","TSModuleDeclaration"] but instead got "BlockStatement"

Environment

System:
OS: macOS 13.4.1
Binaries:
Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.19.3/bin/npm
npmPackages:
@babel/cli: ^7.22.9 => 7.22.9
@babel/core: ^7.22.9 => 7.22.9
@babel/plugin-syntax-dynamic-import: ^7.8.3 => 7.8.3
@babel/plugin-transform-modules-commonjs: ^7.21.5 => 7.21.5
@babel/plugin-transform-modules-umd: ^7.22.5 => 7.22.5
@babel/plugin-transform-runtime: ^7.21.4 => 7.21.4
@babel/preset-env: ^7.21.5 => 7.21.5
@babel/preset-react: ^7.22.5 => 7.22.5
@babel/preset-typescript: ^7.22.5 => 7.22.5
@babel/runtime: ^7.21.5 => 7.21.5
babel-loader: ^9.1.2 => 9.1.2
webpack: ^5.82.1 => 5.82.1

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA 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