Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Formatting error when JSX element contains invalid JS identifier #4636

Copy link
Copy link
@myitcv

Description

@myitcv
Issue body actions

If tests/cases/fourslash/formattingJsxElements.ts is amended as follows (adding data-id="test" to the <div>):

/// <reference path='fourslash.ts' />

//@Filename: file.tsx
////function () {
////    return (
////        <div className="commentBox" data-id="test">
////Hello, World!/*autoformat*/
/////*indent*/
////        </div>
////    )
////}
////


format.document();
goTo.marker("autoformat");
verify.currentLineContentIs('            Hello, World!');
goTo.marker("indent");
verify.indentationIs(12);

and then run, we see a failure:

$ jake runtests tests=tests/cases/fourslash/formattingJsxElements.ts
rm -rf tests/baselines/local/
rm -rf internal/baselines/rwc/local
Running test(s): tests/cases/fourslash/formattingJsxElements.ts
mocha -R mocha-fivemat-progress-reporter -g tests/cases/fourslash/formattingJsxElements.ts --colors  -t 20000 built/local/run.js

    fourslash tests

Test failure:
fourslash test formattingJsxElements.ts runs correctly
  [․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․]

  0 passing (196ms)
  1 failing

  1) fourslash tests tests/cases/fourslash/formattingJsxElements.ts fourslash test formattingJsxElements.ts runs correctly:
     Error: Debug Failure. False expression:
      at Object.assert (eval at <anonymous> (built/local/run.js:54637:13), <anonymous>:1558:23)

This backs up what we're seeing in actual .tsx files that are being formatted with typescript-formatter, i.e. that non-valid JS identifier attributes are causing the formatter to fall over.

This feels like something the formatter should be able to handle.

Thoughts?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.