emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 875 forks source link

TypeScript: `json-parse-error \u0000 is not allowed` error when auto-completing object fields #4010

Closed TheMC47 closed 1 year ago

TheMC47 commented 1 year ago

Thank you for the bug report

Bug description

Completion for object fields is not working. Emacs hangs, and I get the following warning:

(json-parse-error \u0000 is not allowed without JSON_ALLOW_NUL near '"11\u0000bar\u0000"' <callback> 1 98 98)

The following screenshot is an example where this happens

image

Emacs: 28.2 (native compilation)

Emacs hangs and I get the warning in the * Warnings * buffer

Steps to reproduce

  1. Use this file:
    
    type Foo = {
    bar: number;
    };

const x: Foo = { ba, };

2. Prompt for completion `M-x company-complete-common`

### Expected behavior

I get a suggestion to complete `bar`

### Which Language Server did you use?

ts-ls

### OS

Linux

### Error callstack

```emacs-lisp
# `toggle-debug-on-error`:

Debugger entered--Lisp error: (quit)
  accept-process-output(nil 9.954810619354248)
  lsp-request("textDocument/completion" (:textDocument (:uri "file:///home/yecinem/test/main.ts") :position (:line 5 :character 4) :context #<hash-table equal 1/65 0x155a935d44b9>))
  lsp-request-while-no-input("textDocument/completion" (:textDocument (:uri "file:///home/yecinem/test/main.ts") :position (:line 5 :character 4) :context #<hash-table equal 1/65 0x155a935d44b9>))
  #f(compiled-function () #<bytecode -0xa0539c363d76759>)()
  #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>)("" nil t)
  completion-pcm--all-completions("" (point) #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil)
  completion-basic-all-completions("" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 0)
  lsp-completion-passthrough-all-completions("ba" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 2)
  #f(compiled-function (style) #<bytecode 0x11baa1bb1f41453b>)(lsp-passthrough)
  completion--some(#f(compiled-function (style) #<bytecode 0x11baa1bb1f41453b>) (lsp-passthrough basic partial-completion orderless))
  completion--nth-completion(2 "ba" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 2 (metadata (category . lsp-capf) (display-sort-function . identity) (cycle-sort-function . identity)))
  #<subr completion-all-completions>("ba" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 2 (metadata (category . lsp-capf) (display-sort-function . identity) (cycle-sort-function . identity)))
  apply(#<subr completion-all-completions> ("ba" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 2 (metadata (category . lsp-capf) (display-sort-function . identity) (cycle-sort-function . identity))))
  completion-all-completions("ba" #f(compiled-function (probe pred action) #<bytecode 0xf90175de5f52f2f>) nil 2 (metadata (category . lsp-capf) (display-sort-function . identity) (cycle-sort-function . identity)))
  #<subr company-capf--candidates>("ba")
  apply(#<subr company-capf--candidates> "ba")
  (let ((orderless-match-faces [completions-common-part]) (completion-styles +vertico-company-completion-styles)) (apply fn args))
  +vertico--company-capf--candidates-a(#<subr company-capf--candidates> "ba")
  apply(+vertico--company-capf--candidates-a #<subr company-capf--candidates> "ba")
  company-capf--candidates("ba")
  company-capf(candidates "ba")
  company--multi-backend-adapter-candidates((company-capf company-yasnippet) "ba" (:separate company-capf company-yasnippet))
  company--multi-backend-adapter((:separate company-capf company-yasnippet) candidates "ba")
  apply(company--multi-backend-adapter (:separate company-capf company-yasnippet) (candidates "ba"))
  company-call-backend-raw(candidates "ba")
  company--fetch-candidates("ba")
  company-calculate-candidates("ba" nil)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-manual-begin()
  company-complete-common()
  funcall-interactively(company-complete-common)
  command-execute(company-complete-common)

*lsp-log*

Command "/home/yecinem/.emacs.d/.local/etc/lsp/npm/typescript-language-server/bin/typescript-language-server --tsserver-path /home/yecinem/.emacs.d/.local/etc/lsp/npm/typescript/bin/tsserver --stdio" is present on the path.
Command "deno lsp" is not present on the path.
Command "/home/yecinem/.emacs.d/.local/etc/lsp/npm/typescript-language-server/bin/typescript-language-server --tsserver-path /home/yecinem/.emacs.d/.local/etc/lsp/npm/typescript/bin/tsserver --stdio" is present on the path.
Command "deno lsp" is not present on the path.
Found the following clients for /home/yecinem/test/main.ts: (server-id ts-ls, priority -2)
The following clients were selected based on priority: (server-id ts-ls, priority -2)
Using Typescript version (user-setting) 5.0.2 from path "/home/yecinem/.emacs.d/.local/etc/lsp/npm/typescript/lib/node_modules/typescript/lib/tsserver.js"

lsp-workspace-show-log

[Trace - 01:06:17 PM] Sending request 'textDocument/hover - (6)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 4,
    "character": 15
  }
}

[Trace - 01:06:17 PM] Sending request 'textDocument/codeAction - (7)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 4,
      "character": 15
    },
    "end": {
      "line": 4,
      "character": 15
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 4,
            "character": 6
          },
          "end": {
            "line": 4,
            "character": 7
          }
        },
        "message": "Property 'bar' is missing in type '{}' but required in type 'Foo'.",
        "severity": 1,
        "code": 2741,
        "source": "typescript",
        "relatedInformation": [
          {
            "location": {
              "uri": "file:///home/yecinem/test/main.ts",
              "range": {
                "start": {
                  "line": 1,
                  "character": 2
                },
                "end": {
                  "line": 1,
                  "character": 5
                }
              }
            },
            "message": "'bar' is declared here."
          }
        ],
        "tags": []
      }
    ]
  }
}

[Trace - 01:06:17 PM] Sending request 'textDocument/documentHighlight - (8)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 4,
    "character": 15
  }
}

[Trace - 01:06:17 PM] Received response 'textDocument/hover - (6)' in 6ms.
Result: {
  "contents": []
}

[Trace - 01:06:17 PM] Received response 'textDocument/documentHighlight - (8)' in 28ms.
Result: []

[Trace - 01:06:17 PM] Received response 'textDocument/codeAction - (7)' in 29ms.
Result: []

[Trace - 01:06:19 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts",
    "version": 1
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 4,
          "character": 16
        },
        "end": {
          "line": 4,
          "character": 16
        }
      },
      "rangeLength": 0,
      "text": "\n"
    }
  ]
}

[Trace - 01:06:19 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts",
    "version": 2
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 0
        },
        "end": {
          "line": 5,
          "character": 0
        }
      },
      "rangeLength": 0,
      "text": "\n"
    }
  ]
}

[Trace - 01:06:19 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/yecinem/test/main.ts",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 4,
          "character": 6
        },
        "end": {
          "line": 4,
          "character": 7
        }
      },
      "message": "Property 'bar' is missing in type '{}' but required in type 'Foo'.",
      "severity": 1,
      "code": 2741,
      "source": "typescript",
      "relatedInformation": [
        {
          "location": {
            "uri": "file:///home/yecinem/test/main.ts",
            "range": {
              "start": {
                "line": 1,
                "character": 2
              },
              "end": {
                "line": 1,
                "character": 5
              }
            }
          },
          "message": "'bar' is declared here."
        }
      ],
      "tags": []
    }
  ]
}

[Trace - 01:06:19 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts",
    "version": 3
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 0
        },
        "end": {
          "line": 5,
          "character": 0
        }
      },
      "rangeLength": 0,
      "text": "  "
    }
  ]
}

[Trace - 01:06:20 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/yecinem/test/main.ts",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 4,
          "character": 6
        },
        "end": {
          "line": 4,
          "character": 7
        }
      },
      "message": "Property 'bar' is missing in type '{}' but required in type 'Foo'.",
      "severity": 1,
      "code": 2741,
      "source": "typescript",
      "relatedInformation": [
        {
          "location": {
            "uri": "file:///home/yecinem/test/main.ts",
            "range": {
              "start": {
                "line": 1,
                "character": 2
              },
              "end": {
                "line": 1,
                "character": 5
              }
            }
          },
          "message": "'bar' is declared here."
        }
      ],
      "tags": []
    }
  ]
}

[Trace - 01:06:20 PM] Sending request 'textDocument/codeAction - (9)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 2
    }
  },
  "context": {
    "diagnostics": []
  }
}

[Trace - 01:06:20 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 9
}

[Trace - 01:06:20 PM] Received response 'nil - (9)' in 0ms.
Result: []

[Trace - 01:06:22 PM] Sending request 'textDocument/codeAction - (10)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 2
    }
  },
  "context": {
    "diagnostics": []
  }
}

[Trace - 01:06:22 PM] Received response 'textDocument/codeAction - (10)' in 30ms.
Result: []

[Trace - 01:06:25 PM] Sending request 'textDocument/codeAction - (11)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 2
    }
  },
  "context": {
    "diagnostics": []
  }
}

[Trace - 01:06:25 PM] Received response 'textDocument/codeAction - (11)' in 5ms.
Result: []

[Trace - 01:06:25 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts",
    "version": 4
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 2
        }
      },
      "rangeLength": 0,
      "text": "b"
    }
  ]
}

[Trace - 01:06:25 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts",
    "version": 5
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 3
        },
        "end": {
          "line": 5,
          "character": 3
        }
      },
      "rangeLength": 0,
      "text": "a"
    }
  ]
}

[Trace - 01:06:25 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/yecinem/test/main.ts",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 3
        }
      },
      "message": "Type '{ b: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'b' does not exist in type 'Foo'.",
      "severity": 1,
      "code": 2322,
      "source": "typescript",
      "tags": []
    },
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 3
        }
      },
      "message": "No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer.",
      "severity": 1,
      "code": 18004,
      "source": "typescript",
      "tags": []
    }
  ]
}

[Trace - 01:06:26 PM] Sending request 'textDocument/completion - (12)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 4
  },
  "context": {
    "triggerKind": 1
  }
}

[Trace - 01:06:26 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/yecinem/test/main.ts",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 3
        }
      },
      "message": "Type '{ b: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'b' does not exist in type 'Foo'.",
      "severity": 1,
      "code": 2322,
      "source": "typescript",
      "tags": []
    },
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 3
        }
      },
      "message": "No value exists in scope for the shorthand property 'b'. Either declare one or provide an initializer.",
      "severity": 1,
      "code": 18004,
      "source": "typescript",
      "tags": []
    }
  ]
}

[Trace - 01:06:26 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 12
}

[Trace - 01:06:26 PM] Sending request 'textDocument/completion - (13)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 4
  },
  "context": {
    "triggerKind": 1
  }
}

[Trace - 01:06:26 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 13
}

[Trace - 01:06:26 PM] Sending request 'textDocument/completion - (14)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 4
  },
  "context": {
    "triggerKind": 1
  }
}

[Trace - 01:06:26 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 14
}

[Trace - 01:06:26 PM] Sending request 'textDocument/completion - (15)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 4
  },
  "context": {
    "triggerKind": 1
  }
}

[Trace - 01:06:26 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 15
}

[Trace - 01:06:26 PM] Sending request 'textDocument/completion - (16)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 4
  },
  "context": {
    "triggerKind": 1
  }
}

[Trace - 01:06:26 PM] Received response 'nil - (13)' in 0ms.
Result: {
  "items": [],
  "isIncomplete": null
}

[Trace - 01:06:26 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/yecinem/test/main.ts",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 4
        }
      },
      "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
      "severity": 1,
      "code": 2322,
      "source": "typescript",
      "tags": []
    },
    {
      "range": {
        "start": {
          "line": 5,
          "character": 2
        },
        "end": {
          "line": 5,
          "character": 4
        }
      },
      "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
      "severity": 1,
      "code": 18004,
      "source": "typescript",
      "tags": []
    }
  ]
}

[Trace - 01:07:29 PM] Sending request 'textDocument/codeAction - (17)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 4
    },
    "end": {
      "line": 5,
      "character": 4
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:29 PM] Received response 'textDocument/codeAction - (17)' in 16ms.
Result: []

[Trace - 01:07:30 PM] Sending request 'textDocument/codeAction - (18)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 4
    },
    "end": {
      "line": 5,
      "character": 4
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:30 PM] Received response 'textDocument/codeAction - (18)' in 24ms.
Result: []

[Trace - 01:07:32 PM] Sending request 'textDocument/codeAction - (19)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:32 PM] Sending request 'textDocument/documentHighlight - (20)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:32 PM] Sending request 'textDocument/hover - (21)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:32 PM] Received response 'textDocument/documentHighlight - (20)' in 17ms.
Result: [
  {
    "kind": 2,
    "range": {
      "start": {
        "line": 5,
        "character": 2
      },
      "end": {
        "line": 5,
        "character": 4
      }
    }
  }
]

[Trace - 01:07:32 PM] Received response 'textDocument/hover - (21)' in 41ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "\n\n(property) ba: any\n```\n"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 4
    }
  }
}

[Trace - 01:07:32 PM] Received response 'textDocument/codeAction - (19)' in 87ms.
Result: []

[Trace - 01:07:32 PM] Sending request 'textDocument/codeAction - (22)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:32 PM] Received response 'textDocument/codeAction - (22)' in 12ms.
Result: []

[Trace - 01:07:33 PM] Sending request 'textDocument/codeAction - (23)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:33 PM] Received response 'textDocument/codeAction - (23)' in 28ms.
Result: []

[Trace - 01:07:35 PM] Sending request 'textDocument/codeAction - (24)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:35 PM] Received response 'textDocument/codeAction - (24)' in 6ms.
Result: []

[Trace - 01:07:37 PM] Sending request 'textDocument/codeAction - (25)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 7,
      "character": 0
    },
    "end": {
      "line": 7,
      "character": 0
    }
  },
  "context": {
    "diagnostics": []
  }
}

[Trace - 01:07:37 PM] Sending request 'textDocument/documentHighlight - (26)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 7,
    "character": 0
  }
}

[Trace - 01:07:37 PM] Sending request 'textDocument/hover - (27)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 7,
    "character": 0
  }
}

[Trace - 01:07:37 PM] Received response 'textDocument/documentHighlight - (26)' in 5ms.
Result: []

[Trace - 01:07:37 PM] Received response 'textDocument/hover - (27)' in 5ms.
Result: {
  "contents": []
}

[Trace - 01:07:37 PM] Received response 'textDocument/codeAction - (25)' in 11ms.
Result: []

[Trace - 01:07:44 PM] Sending request 'textDocument/codeAction - (28)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:44 PM] Sending request 'textDocument/documentHighlight - (29)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:44 PM] Sending request 'textDocument/hover - (30)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:44 PM] Received response 'textDocument/documentHighlight - (29)' in 8ms.
Result: [
  {
    "kind": 2,
    "range": {
      "start": {
        "line": 5,
        "character": 2
      },
      "end": {
        "line": 5,
        "character": 4
      }
    }
  }
]

[Trace - 01:07:44 PM] Received response 'textDocument/hover - (30)' in 8ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "\n```typescript\n(property) ba: any\n```\n"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 4
    }
  }
}

[Trace - 01:07:44 PM] Received response 'textDocument/codeAction - (28)' in 20ms.
Result: []

[Trace - 01:07:45 PM] Sending request 'textDocument/codeAction - (31)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 4
    },
    "end": {
      "line": 5,
      "character": 4
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:45 PM] Received response 'textDocument/codeAction - (31)' in 7ms.
Result: []

[Trace - 01:07:59 PM] Sending request 'textDocument/hover - (32)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:59 PM] Sending request 'textDocument/codeAction - (33)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 3
    },
    "end": {
      "line": 5,
      "character": 3
    }
  },
  "context": {
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.",
        "severity": 1,
        "code": 2322,
        "source": "typescript",
        "tags": []
      },
      {
        "range": {
          "start": {
            "line": 5,
            "character": 2
          },
          "end": {
            "line": 5,
            "character": 4
          }
        },
        "message": "No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.",
        "severity": 1,
        "code": 18004,
        "source": "typescript",
        "tags": []
      }
    ]
  }
}

[Trace - 01:07:59 PM] Sending request 'textDocument/documentHighlight - (34)'.
Params: {
  "textDocument": {
    "uri": "file:///home/yecinem/test/main.ts"
  },
  "position": {
    "line": 5,
    "character": 3
  }
}

[Trace - 01:07:59 PM] Received response 'textDocument/hover - (32)' in 8ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "\n```typescript\n(property) ba: any\n```\n"
  },
  "range": {
    "start": {
      "line": 5,
      "character": 2
    },
    "end": {
      "line": 5,
      "character": 4
    }
  }
}

[Trace - 01:07:59 PM] Received response 'textDocument/documentHighlight - (34)' in 13ms.
Result: [
  {
    "kind": 2,
    "range": {
      "start": {
        "line": 5,
        "character": 2
      },
      "end": {
        "line": 5,
        "character": 4
      }
    }
  }
]

[Trace - 01:07:59 PM] Received response 'textDocument/codeAction - (33)' in 16ms.
Result: []

*Warnings*

’’’
Content-Length: 389

{"jsonrpc":"2.0","id":12,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}
’’’
with message (json-parse-error \u0000 is not allowed without JSON_ALLOW_NUL near '"11\u0000bar\u0000"' <callback> 1 98 98) Disable showing Disable logging
Warning (lsp-mode): Failed to parse the following chunk:
’’’
Content-Length: 389

{"jsonrpc":"2.0","id":14,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":15,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":16,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 669

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/yecinem/test/main.ts","diagnostics":[{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.","severity":1,"code":2322,"source":"typescript","tags":[]},{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.","severity":1,"code":18004,"source":"typescript","tags":[]}]}}
’’’
with message (json-parse-error \u0000 is not allowed without JSON_ALLOW_NUL near '"11\u0000bar\u0000"' <callback> 1 98 98) Disable showing Disable logging
Warning (lsp-mode): Failed to parse the following chunk:
’’’
Content-Length: 389

{"jsonrpc":"2.0","id":14,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":15,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":16,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 669

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/yecinem/test/main.ts","diagnostics":[{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.","severity":1,"code":2322,"source":"typescript","tags":[]},{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.","severity":1,"code":18004,"source":"typescript","tags":[]}]}}
’’’
with message (json-parse-error \u0000 is not allowed without JSON_ALLOW_NUL near '"11\u0000bar\u0000"' <callback> 1 98 98) Disable showing Disable logging
Warning (lsp-mode): Failed to parse the following chunk:
’’’
Content-Length: 389

{"jsonrpc":"2.0","id":14,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":15,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 389

{"jsonrpc":"2.0","id":16,"result":{"items":[{"label":"bar","kind":5,"sortText":"11\u0000bar\u0000","data":{"file":"/home/yecinem/test/main.ts","line":6,"offset":5,"entryNames":["bar"]},"textEdit":{"newText":"bar","insert":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"replace":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}}}}],"isIncomplete":false}}Content-Length: 669

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/yecinem/test/main.ts","diagnostics":[{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"Type '{ ba: any; }' is not assignable to type 'Foo'.\n  Object literal may only specify known properties, and 'ba' does not exist in type 'Foo'.","severity":1,"code":2322,"source":"typescript","tags":[]},{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":4}},"message":"No value exists in scope for the shorthand property 'ba'. Either declare one or provide an initializer.","severity":1,"code":18004,"source":"typescript","tags":[]}]}}
’’’
with message (json-parse-error \u0000 is not allowed without JSON_ALLOW_NUL near '"11\u0000bar\u0000"' <callback> 1 98 98) Disable showing Disable logging

Anything else?

➜ doom version
GNU Emacs     v28.2            nil
Doom core     v3.0.0-pre       HEAD -> master 4e105a95 2023-03-22 18:29:38 -0400
Doom modules  v23.03.0-pre     HEAD -> master 4e105a95 2023-03-22 18:29:38 -0400

…
yyoncho commented 1 year ago

This is emacs bug, fixed in emacs 29. For older versions, you can use the workaround from here: https://github.com/emacs-lsp/lsp-mode/issues/2681#issuecomment-1214902146

TheMC47 commented 1 year ago

Thanks, this comment https://github.com/typescript-language-server/typescript-language-server/issues/559#issuecomment-1259470791 actually solves the problem.