Skip to content

Formatting error when JSX element contains invalid JS identifier #4636

Closed

Description

@myitcv

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?

Activity

  1. added
    Fixed
    on Sep 4, 2015
  2. myitcv commented on Sep 6, 2015

    @myitcv
    Author

    Vladimir Matveev (@vladima) - thanks for the quick fix. Works as expected.

  3. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFixed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions