question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ts-ignore is broken in 3.6 when code line is broken into 2 lines

See original GitHub issue

Search Terms: @ts-ignore ts-ignore ignore multiline Code

const veryLongStructureNameWithFooInside = {
  foo: (x: number): Promise<number> => {
    return Promise.resolve(x);
  },
};
// @ts-ignore
veryLongStructureNameWithFooInside
  .foo() // Notice the line break here caused by prettier
  .then((result) => {
    console.log(result);
  })
  .catch((err) => {
    console.log(err);
  });

Expected behavior:

There should be no errors as @ts-ignore is set on the function call (works in 3.5.2)

Actual behavior:

In next version the following error occurs:

error TS2554: Expected 1 arguments, but got 0.

   .foo()
      ~~~~~

      foo: (x: number): Promise<number> => {
               ~~~~~~~~~
    An argument for 'x' was not provided.

Playground Link: playground

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
sandersncommented, Sep 5, 2019

Here’s a smaller repro:

const x = {
  foo: (x: number) => {
    return x;
  },
};
// @ts-ignore
x
.foo() // Notice the line break here caused by prettier

This is definitely a regression in 3.6, although the new behaviour seems right to me – I believe ts-ignore is defined in terms of lines, not expressions. It makes ts-ignore + prettier hard to use consistently though.

1reaction
lamontadamscommented, Sep 19, 2019

This is also affecting React tsx components broken across multiple lines, which is problematic because quite a few React components tend to have poor or unmaintained typings. Prior to 3.6 I could ts-ignore a single property assignment by putting it on one line and still have type support for the other properties exposed by a component. Now I have to ignore the entire component declaration when this happens - and it really frustrates my efforts to get the rest of my team sold on Typescript.

I’m also “stuck” on 3.5 until this gets fixed.

FYI - I wound up here after filing https://github.com/microsoft/vscode/issues/80715 against VSCode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use `@ts-ignore` for a block? - Stack Overflow
So to disable checking for a block (function, class, etc.) ... the error on one line, and you can do it for multiple...
Read more >
Google Python Style Guide
Python is the main dynamic language used at Google. This style guide is a list of dos and don'ts for Python programs. To...
Read more >
Documentation - TypeScript 3.9
When a line is preceded by a // @ts-expect-error comment, TypeScript will suppress that error from being reported; but if there's no error,...
Read more >
August 2019 (version 1.38) - Visual Studio Code
Adjust cursor surrounding lines - Keep your cursor centered in the editor. ... Go to Line supports negative line numbers - Quickly jump...
Read more >
The GNU Awk User's Guide
The best way to get a new awk was to ftp the source code for gawk from ... that line. awk continues to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found