Repository: TypeScript
Issue: Refactoring assertion failure with invalid object type syntax
Labels: Bug,Domain: Refactorings,Rescheduled,Old-Crawler-Detected

Another manifestation of https://github.com/microsoft/TypeScript/issues/38060.

This one comes up when you use a Flow exact object type with an optional property.

```ts
const f = function/**/ (p: {| prop?: boolean |}) { 
}
```

```ts
let obj: [| {| prop?: string |} |];
```

1. Request the "Convert to arrow function" refactoring at `/**/`,
2. Request the "Extract to type alias" refactoring from `[|` and `|]`

**Expected** no crash, or the quick fix isn't even available.
**Actual**

<details>
<summary>
First stack trace
</summary>

```
Response received: getEditsForRefactor (1516). Request took 3 ms. Success: false . Message: Error processing request. Debug Failure. False expression.
Error: Debug Failure. False expression.
    at consumeTokenAndAdvanceScanner (node_modules/typescript/lib/tsserver.js:146675:30)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146588:25)
    at node_modules/typescript/lib/tsserver.js:146538:21
    at visitNode (node_modules/typescript/lib/tsserver.js:30447:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30930:24)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at processChildNodes (node_modules/typescript/lib/tsserver.js:146652:48)
    at node_modules/typescript/lib/tsserver.js:146540:21
    at visitNodes (node_modules/typescript/lib/tsserver.js:30452:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30631:24)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at node_modules/typescript/lib/tsserver.js:146538:21
    at visitNode (node_modules/typescript/lib/tsserver.js:30447:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30543:21)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at processChildNodes (node_modules/typescript/lib/tsserver.js:146652:48)
    at node_modules/typescript/lib/tsserver.js:146540:21
    at visitNodes (node_modules/typescript/lib/tsserver.js:30452:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30605:21)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at formatSpanWorker (node_modules/typescript/lib/tsserver.js:146337:17)
    at node_modules/typescript/lib/tsserver.js:146300:140
    at Object.getFormattingScanner (node_modules/typescript/lib/tsserver.js:144927:23)
    at Object.formatNodeGivenIndentation (node_modules/typescript/lib/tsserver.js:146300:31)
    at getFormattedTextOfNode (node_modules/typescript/lib/tsserver.js:148721:45)
    at format (node_modules/typescript/lib/tsserver.js:148692:52)
    at computeNewText (node_modules/typescript/lib/tsserver.js:148695:23)
    at node_modules/typescript/lib/tsserver.js:148659:39
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at node_modules/typescript/lib/tsserver.js:148657:42
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at Object.getTextChangesFromChanges (node_modules/typescript/lib/tsserver.js:148643:27)
    at ChangeTracker.getChanges (node_modules/typescript/lib/tsserver.js:148582:45)
    at Function.ChangeTracker.with (node_modules/typescript/lib/tsserver.js:148002:32)
    at getEditInfoForConvertToArrowFunction (node_modules/typescript/lib/tsserver.js:162842:57)
    at Object.getRefactorEditsToConvertFunctionExpressions [as getEditsForAction] (node_modules/typescript/lib/tsserver.js:162729:49)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:149310:41)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:165116:32)
    at IpcIOSession.Session.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:176473:59)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (node_modules/typescript/lib/tsserver.js:174947:61)
    at node_modules/typescript/lib/tsserver.js:176856:88
    at IpcIOSession.Session.executeWithRequestId (node_modules/typescript/lib/tsserver.js:176847:28)
    at IpcIOSession.Session.executeCommand (node_modules/typescript/lib/tsserver.js:176856:33)
    at IpcIOSession.Session.onMessage (node_modules/typescript/lib/tsserver.js:176882:35)
    at process.<anonymous> (node_modules/typescript/lib/tsserver.js:179517:31)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
```
</details>

<details>
<summary>
Second stack trace
</summary>

```
Response received: getEditsForRefactor (1821). Request took 3 ms. Success: false . Message: Error processing request. length < 0
Error: length < 0
    at Object.createTextSpan (node_modules/typescript/lib/tsserver.js:12255:19)
    at Object.createTextChangeFromStartLength (node_modules/typescript/lib/tsserver.js:127152:36)
    at recordReplace (node_modules/typescript/lib/tsserver.js:146958:35)
    at applyRuleEdits (node_modules/typescript/lib/tsserver.js:147003:29)
    at node_modules/typescript/lib/tsserver.js:146785:38
    at Object.forEachRight (node_modules/typescript/lib/tsserver.js:198:30)
    at processPair (node_modules/typescript/lib/tsserver.js:146784:24)
    at processRange (node_modules/typescript/lib/tsserver.js:146768:29)
    at consumeTokenAndAdvanceScanner (node_modules/typescript/lib/tsserver.js:146688:38)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146588:25)
    at node_modules/typescript/lib/tsserver.js:146538:21
    at visitNode (node_modules/typescript/lib/tsserver.js:30447:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30614:24)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at node_modules/typescript/lib/tsserver.js:146538:21
    at visitNode (node_modules/typescript/lib/tsserver.js:30447:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30930:24)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at processChildNodes (node_modules/typescript/lib/tsserver.js:146652:48)
    at node_modules/typescript/lib/tsserver.js:146540:21
    at visitNodes (node_modules/typescript/lib/tsserver.js:30452:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30631:24)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at processChildNode (node_modules/typescript/lib/tsserver.js:146605:21)
    at node_modules/typescript/lib/tsserver.js:146538:21
    at visitNode (node_modules/typescript/lib/tsserver.js:30447:24)
    at Object.forEachChild (node_modules/typescript/lib/tsserver.js:30821:21)
    at processNode (node_modules/typescript/lib/tsserver.js:146537:20)
    at formatSpanWorker (node_modules/typescript/lib/tsserver.js:146337:17)
    at node_modules/typescript/lib/tsserver.js:146300:140
    at Object.getFormattingScanner (node_modules/typescript/lib/tsserver.js:144927:23)
    at Object.formatNodeGivenIndentation (node_modules/typescript/lib/tsserver.js:146300:31)
    at getFormattedTextOfNode (node_modules/typescript/lib/tsserver.js:148721:45)
    at format (node_modules/typescript/lib/tsserver.js:148692:52)
    at computeNewText (node_modules/typescript/lib/tsserver.js:148695:23)
    at node_modules/typescript/lib/tsserver.js:148659:39
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at node_modules/typescript/lib/tsserver.js:148657:42
    at Object.mapDefined (node_modules/typescript/lib/tsserver.js:605:30)
    at Object.getTextChangesFromChanges (node_modules/typescript/lib/tsserver.js:148643:27)
    at ChangeTracker.getChanges (node_modules/typescript/lib/tsserver.js:148582:45)
    at Function.ChangeTracker.with (node_modules/typescript/lib/tsserver.js:148002:32)
    at Object.getRefactorEditsToExtractType [as getEditsForAction] (node_modules/typescript/lib/tsserver.js:160796:62)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:149310:41)
    at Object.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:165116:32)
    at IpcIOSession.Session.getEditsForRefactor (node_modules/typescript/lib/tsserver.js:176473:59)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (node_modules/typescript/lib/tsserver.js:174947:61)
    at node_modules/typescript/lib/tsserver.js:176856:88
    at IpcIOSession.Session.executeWithRequestId (node_modules/typescript/lib/tsserver.js:176847:28)
    at IpcIOSession.Session.executeCommand (node_modules/typescript/lib/tsserver.js:176856:33)
    at IpcIOSession.Session.onMessage (node_modules/typescript/lib/tsserver.js:176882:35)
    at process.<anonymous> (node_modules/typescript/lib/tsserver.js:179517:31)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
```
</details>