microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.08k stars 12.5k forks source link

Indentation failure with unclosed JSX element #6281

Open DanielRosenwasser opened 8 years ago

DanielRosenwasser commented 8 years ago
var x =
    <div>
        <input type="text" name="name">
    </div>

namespace foo {
/**/

Press enter at /**/.

Description:

getIndentationAtPosition('C:\Users\drosen\AppData\Local\Temp\~vs8E0D.tsx', 94)

StackTrace:

Error: Debug Failure. False expression: 
   at assert (:1645:17)
   at find (:41847:13)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at find (:41843:25)
   at findPrecedingToken (:41808:9)
   at getIndentation (:44508:17)
   at getIndentationAtPosition (:50435:13)
   at Anonymous function (:52193:17)
   at simpleForwardCall (:51951:9)
   at forwardJSONCall (:51967:13)
   at forwardJSONCall (:52013:13)
   at getIndentationAtPosition (:52191:13)
DanielRosenwasser commented 8 years ago

Marking this as high priority because it actually makes VS crash for me.

vladima commented 8 years ago

Does not repro for me using the latest bits from master. Can you attach a fourslash test that shows the problem?

indentationinjsx

DanielRosenwasser commented 8 years ago

The repro wasn't apparent because I think you need a newline below the namespace. I've updated the original comment.

vladima commented 8 years ago

sure, still don't see it. indentationinjsx2

DanielRosenwasser commented 8 years ago

As discussed offline, this is not a crash (you need to have dev mode enabled), but this is still an issue.

DanielRosenwasser commented 8 years ago

More minimal repro:

var x = <div bar={10}>
/**/

Press enter at /**/

Andarist commented 1 year ago

The expected result isn't completely clear for me here and I can't assess if this is already fixed or not.