Skip to content

[Bug]: toPrimitive() does not use the typeof() function #16219

@DiFuks

Description

@DiFuks

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

Correct

Correct - modules false

Incorrect - modules systemjs

Configuration file name

No response

Configuration

{
	"presets": [
		[
			"@babel/preset-env",
			{
				"targets": ["chrome 22", "last 12 years"],
				"modules": "systemjs"
			}
		]
	]
}

Current and expected behavior

For SystemJS, Babel does not replace the typeof operator with the @babel/helpers typeof function in toPrimitive in certain scenarios.

At the same time, in the browser, I get the error '@@toPrimitive must return a primitive value' because the Symbol from the polyfill is treated as an object, not as 'symbol'

Environment

"@babel/cli": "7.23.4",
"@babel/core": "7.23.7",
"@babel/preset-env": "7.23.8",
OS: macOS 14.2.1
Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
Yarn: 4.0.2 - ~/.nvm/versions/node/v18.15.0/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm

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