Skip to content

Formatting error when JSX element contains invalid JS identifier #4636

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

Closed
myitcv opened this issue Sep 4, 2015 · 1 comment
Closed

Formatting error when JSX element contains invalid JS identifier #4636

myitcv opened this issue Sep 4, 2015 · 1 comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@myitcv
Copy link

myitcv commented Sep 4, 2015

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?

@vladima vladima added the Bug A bug in TypeScript label Sep 4, 2015
@mhegazy mhegazy added this to the TypeScript 1.6.2 milestone Sep 4, 2015
@vladima vladima added the Fixed A PR has been merged for this issue label Sep 4, 2015
@myitcv
Copy link
Author

myitcv commented Sep 6, 2015

@vladima - thanks for the quick fix. Works as expected.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants