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

Error TS2709: Cannot use namespace 'HotPatcher' as a type. #323

Closed
pro-sumer opened this issue Oct 10, 2022 · 5 comments
Closed

Error TS2709: Cannot use namespace 'HotPatcher' as a type. #323

pro-sumer opened this issue Oct 10, 2022 · 5 comments

Comments

@pro-sumer
Copy link

pro-sumer commented Oct 10, 2022

Unfortunately I (still) can't use webdav-client with TypeScript (due to an issue with hot-patcher):

➜ tsc
node_modules/.pnpm/webdav@4.11.0/node_modules/webdav/dist/node/compat/patcher.d.ts:2:39 - error TS2709: Cannot use namespace 'HotPatcher' as a type.

2 export declare function getPatcher(): HotPatcher;
                                        ~~~~~~~~~~


Found 1 error in node_modules/.pnpm/webdav@4.11.0/node_modules/webdav/dist/node/compat/patcher.d.ts:2

I did see you mention in #314 that the PR from #315 should enable using TypeScript, so I guess I'm doing something wrong?

What could that be?

Or should I wait for #317?

@blackraspberryyy
Copy link

What worked for me, instead of enabling skipLibCheck: true, was just adding my custom declaration file in my local project (by following this tutorial). Then, the contents are the same with @santiagocano08's declaration file on #315 PR.

// ./src/@typings/index.d.ts

declare module "hot-patcher" {
    class HotPatcher {
        patchInline(key: string, method: any, ...args: any[]): any;
    }
    export default HotPatcher;
}

@perry-mitchell
Copy link
Owner

I'm looking into this now. I'm having some issues properly building HotPatcher for typescript.. but once that's working I'll release an update.

@perry-mitchell perry-mitchell self-assigned this Nov 18, 2022
@perry-mitchell
Copy link
Owner

perry-mitchell commented Nov 19, 2022

Hot Patcher and outputting non-ESM bundles has been a pain, so I've released it as an ESM module @ v2. Due to that, I'll roll it into WebDAV under a new major and will release this library as ESM also: #326

ESM has been requested for a while, and it's definitely the way to go for new builds. So unfortunately to fix this issue it'll most likely require you to update to v5+ESM. This is good reading if you're interested in migrating to ESM.

@perry-mitchell
Copy link
Owner

perry-mitchell commented Nov 19, 2022

Nevermind, I fixed this in another commit... I had to remove the declarations.. 😅

I'll still be releasing the ESM build shortly but v4 should also get this fix!

EDIT: v4.11.2 released with this.

@blackraspberryyy
Copy link

I updated webdav to v4.11.2 on my project and npm run build works now without warnings or errors. 🎉🎉🎉 Thank you @perry-mitchell!

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

No branches or pull requests

3 participants