@ts-ignore is broken in 3.6 when code line is broken into 2 lines
See original GitHub issueSearch 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:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a smaller repro:
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.
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.