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 compatibility #7

Open
ilyasfoo opened this issue Mar 28, 2019 · 7 comments
Open

Typescript compatibility #7

ilyasfoo opened this issue Mar 28, 2019 · 7 comments

Comments

@ilyasfoo
Copy link

ilyasfoo commented Mar 28, 2019

Because this module extends functionality of Console, the following is required to avoid typescript complaining about missing "draft" function:

interface Console {
        draft: (a) => (b) => {}
}

I think to support this from the module level, we can use the global declaration feature

declare global {
    interface Console {
        draft: (a) => (b) => {}
    }
}
@ivanseidel
Copy link
Owner

good idea, can you make a merge request?

@elmarti
Copy link

elmarti commented May 9, 2019

interface Console {
    draft: (...args) => (b) => {}
}

Works for me as I leverage the console ...args setup

@dominik-korsa
Copy link

Is there any progress on this?

FuuuOverclocking added a commit to FuuuOverclocking/node-draftlog that referenced this issue Mar 26, 2021
Make your typescript program run, in the least degree.
Solve ivanseidel#7.
@adelisle
Copy link

I'm having an issue building a typescript project containing the recently published version 1.0.13 containing the merged #8.

node_modules/draftlog/index.d.ts:15:5 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

15     declare function into(console: Console, extra?: boolean): LineCountStream;
       ~~~~~~~


Found 1 error.

Removing that superfluous declare fixes this issue.

@kshutkin
Copy link

kshutkin commented Dec 2, 2021

tested draftlog 1.0.13 with rollup / rollup-plugin-typescript2. I have no problems and everything works perfectly regarding typescript compatibility.

@trhinehart-godaddy
Copy link

Running into issue @adelisle mentioned using typescript@4.5.5

@oliviermoratin-rapid
Copy link

Running into issue @adelisle mentioned using typescript@4.5.5

I wrapped the call with something like this and it works

const logUpdate = (msg: string): void => {
  return 'draft' in console && typeof console.draft === 'function' ? console.draft('test') : () => {};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants