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.

New version converts `any` to `{}` too aggressively

See original GitHub issue

For code like this:

import {EventEmitter} from 'events';

interface MyData {
  foo: string;
}

class Foo extends EventEmitter {
  on(event: 'mydata', listener: (data: MyData) => void): this;
  on(event: string, listener: (...args: any[]) => void): this {
    return super.on(event, listener);
  }
}

, gts fix converts ...args: any[] to ...args: {}[], which makes the specialized on() method (for ‘mydata’) not compatible with the implementation and makes the build fail. I think this must be left as any[] because the super class (EventEmitter)'s type is any[].

That also brings another problem where the linter complains about {}[], saying that

Array type using ‘T[]’ is forbidden for non-simple types. Use’Array<T>’ instead.

Which forces me to write Array<{}>, which is harder to read than {}[] or any[]. It surprises me that it says {} is of a non-simple type.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JustinBeckwithcommented, Nov 13, 2017

I’m +1 on this approach - having the lint rule is ok, breaking all of my code when I run fix isn’t.

2reactions
ofrobotscommented, Nov 13, 2017

Agree with @calebegg. The no-any rule should not have a fixer.

I propose that we implement our own no-any-google rule that jettisons the fixer and use that instead. Or convince upstream to do it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is a Good Conversion Rate? It's Higher Than You Think!
What is a good conversion rate? Conversion is a key element in your paid search strategy. In this post, you'll learn a step-by-step, ......
Read more >
Windows 11 prep: How to convert MBR hard drive partitions to ...
Converting an MBR partition to a UEFI partition is accomplished with the help of a simple utility in Windows 10 called MBR2GPT.exe, which...
Read more >
E-book conversion — calibre 6.10.0 documentation
This document will refer mainly to the conversion settings as found in the conversion dialog, pictured below. All these settings are also available...
Read more >
Converting Client Modpack Versions To Server Version
Looking to host your favorite modpack on a server but the modpack doesn't have a server version? Learn how to convert client side...
Read more >
Convert a Word or PDF form or quiz to Microsoft Forms
You can import and convert your existing Word or PDF surveys or quizzes, on your local hard ... Forms page with New Form,...
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