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

JSX: <svg : path /> parsed incorrectly #47219

Closed
strager opened this issue Dec 22, 2021 · 1 comment Β· Fixed by #47356
Closed

JSX: <svg : path /> parsed incorrectly #47219

strager opened this issue Dec 22, 2021 · 1 comment Β· Fixed by #47356
Labels
Bug A bug in TypeScript
Milestone

Comments

@strager
Copy link
Contributor

strager commented Dec 22, 2021

Bug Report

πŸ”Ž Search Terms

jsx tag namespace

πŸ•— Version & Regression Information

v4.5.4, v4.6.0-dev.20211221

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSX

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

import React from "react";
function MyComponent() {
  return <svg : path />;
}

πŸ™ Actual behavior

TypeScript reports errors:

Type 'true' is not assignable to type 'string | undefined'.
Identifier expected.

TypeScript compiler generates undesired JavaScript:

import React from "react";
function MyComponent() {
    return React.createElement("svg", { path: true });
}

It looks like TypeScript is interpreting svg : path similar to svg path. According to the JSX specification, whitespace is allowed around the : token.

πŸ™‚ Expected behavior

TypeScript treats the code as if it was the following:

import React from "react";
function MyComponent() {
  return <svg:path />;  // Note: no spaces around ':'.
}

generating the following JavaScript:

import React from "react";
function MyComponent() {
    return React.createElement("svg:path", null);
}

Babel, ESLint, and Flow interpret the code this way. ESBuild seems to have the same interpretation as TypeScript.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jan 4, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 4, 2022
@RyanCavanaugh
Copy link
Member

We should parse this better, but namespaced elements are not yet supported. See also #7411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants