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.

Working around Typescript and defineCommand

See original GitHub issue

Hello,

Is there a way to work around the Typescript limitations with defineCommand?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
krolegcommented, May 2, 2019

@Qix- i don’t think it can be solved on ioredis side. To overcome issues with typings you can create a wrapper file with one @ts-ignore like this:

// using "@types/ioredis": "^4.0.8"
import Redis, { Redis as RedisInterface } from 'ioredis';

// @ts-ignore
export const redis: MyRedis = new Redis();

interface MyRedis extends RedisInterface {
    // declare your custom commands here
    test();
    anotherCustomCommand();
}

and use it like this (checked in VSCode with latest typescript and they pick up test method on redis):

import { redis} from './redis-wrapper';
redis.test();
2reactions
dantmancommented, Apr 2, 2019

This seems to be a feature request / question that shouldn’t be auto-closed without a maintainer actually looking at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use parameter as type definition? - Stack Overflow
I know that it works with generics but this way I would have to pass in the "schema" twice. Once as type and...
Read more >
1 Command & Event Handler | discord.js typescript tutorials
Discord: https://discord.io/reconlxGitHub: https://github.com/reconlx.
Read more >
REPLServer | typescript - v3.7.7
This method is primarily intended to be called from within the action function for commands registered using the replServer.defineCommand() method.
Read more >
Command in TypeScript / Design Patterns - Refactoring.Guru
Full code example in TypeScript with detailed comments and explanation. ... public doSomething(a: string): void { console.log(`Receiver: Working on (${a}.) ...
Read more >
How to build a command-line app in Node.js using TypeScript ...
As you can see with ts-node , we can actually run TypeScript files (*.ts) ... Let's try out a basic Cloud Function 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