Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript fails to compile when get method's first parameter is not a string #61

Open
meszaros-lajos-gyorgy opened this issue Dec 7, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@meszaros-lajos-gyorgy
Copy link

The following line says that the method's first parameter is a string:
https://github.com/davestewart/alias-hq/blob/main/src/index.js#L247

and vscode is yelling about it in my typescript project as expected:
image

@meszaros-lajos-gyorgy
Copy link
Author

I see the other type is also listed in the next line, but typescript doesn't recognise it as an overload

@meszaros-lajos-gyorgy meszaros-lajos-gyorgy changed the title Incorrect input type for the get method in jsdoc Typescript fails to compile when get method's first parameter is not a string Dec 7, 2022
@meszaros-lajos-gyorgy
Copy link
Author

meszaros-lajos-gyorgy commented Dec 7, 2022

My current workaround so far is:

import hq from 'alias-hq'

type TsOrJsConfig = {
  rootUrl: string
  baseUrl: string
  paths: Record<string, string[]>
}

type PluginCallback = (params: TsOrJsConfig) => any

const get = hq.get as (plugin: string | PluginCallback) => any

// ... use get instead of hq.get

@davestewart
Copy link
Owner

Hey there!

Sorry about that.

I should add type definitions (or migrate to TS) I suppose!

Let me look at that in the next couple of days.

@davestewart
Copy link
Owner

davestewart commented Apr 25, 2023

See:

@davestewart davestewart added the bug Something isn't working label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants