Skip to content

Wrong location generated for JSX with whitespace around it when react-jsxdevΒ #61533

@AviVahl

Description

@AviVahl

πŸ”Ž Search Terms

react-jsxdev, jsxdev, location

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?jsx=5#code/KYDwDg9gTgLgBAYwgOwM7wLIE8DCEC2YcAvHABQCUJAfHAN4BQccUwMArlMuU83ADwATAJYA3OAHpqvCgwC+DIA

πŸ’» Code

export const MyComp = () => {
  return (
    <div />
  )
}

πŸ™ Actual behavior

import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
const _jsxFileName = "file:///input.tsx";
export const MyComp = () => {
    return (_jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 2, columnNumber: 11 }, this));
};

πŸ™‚ Expected behavior

import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
const _jsxFileName = "file:///input.tsx";
export const MyComp = () => {
    return (_jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 3, columnNumber: 5 }, this));
};

Additional information about the issue

Babel has correct location:
https://babeljs.io/repl/#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=KYDwDg9gTgLgBAYwgOwM7wLIE8DCEC2YcAvHABQCUJAfHAN4BQccUwMArlMuU83ADwATAJYA3OAHpqvCgwC-DIA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=react%2Cstage-2&prettier=false&targets=&version=7.27.0&externalPlugins=%40babel%2Fplugin-transform-react-jsx-development%407.25.9&assumptions=%7B%7D

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions