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 of type and avoiding an error of build in a release #107

Closed
3C0D opened this issue Feb 6, 2025 · 9 comments
Closed

Error of type and avoiding an error of build in a release #107

3C0D opened this issue Feb 6, 2025 · 9 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@3C0D
Copy link
Contributor

3C0D commented Feb 6, 2025

I don't know why, but when I build under GitHub Actions, simple errors become much more restrictive (as a @ts-ignore), whereas a local build doesn't cause any issues. (repo https://github.com/3C0D/obsidian-explorer-shortcuts/releases/tag/1.3.4)

I had to work around the problem by adding:

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
tree.handleDeleteSelectedItems(e);

I had already pushed a similar function before, where a required argument was missing. So this function also needs an argument; otherwise, the file won't be deleted. (KeyboardEvent)

@mnaoumov
Copy link
Collaborator

@3C0D I don't understand

https://github.com/3C0D/obsidian-explorer-shortcuts/actions/runs/13169628607/job/36757438385

Fails

Error: src/delete.ts(32,5): error TS2578: Unused '@ts-expect-error' directive.

Locally it also fails

    // @ts-expect-error
    tree.handleDeleteSelectedItems(e);

It fails because handleDeleteSelectedItems() is added to the typings, so @ts-expect-error fails as there is no errors.

Please elaborate what do you expect us to fix in obsidian-typings

@mnaoumov mnaoumov added the help wanted Extra attention is needed label Feb 10, 2025
@3C0D
Copy link
Contributor Author

3C0D commented Feb 10, 2025

The handleDeleteSelectedItems function in Obsidian’s code requires a KeyboardEvent argument to work (without it, files don’t delete). But the current typings declare it as handleDeleteSelectedItems(): void (no arguments).

This creates indeed two problems:
Runtime Failure: If you call it without the KeyboardEvent argument, TypeScript doesn’t complain (because the typings are wrong), but the function silently fails.

Build Errors: When I tried to suppress this with // @ts-expect-error, GitHub Actions failed because TypeScript saw "no error here" (since the typings hide the real issue). I had to hack it with @ts-ignore + an ESLint override.

The fix here would be:
handleDeleteSelectedItems(e: KeyboardEvent): void;

Let me know if you need more details.

@mnaoumov
Copy link
Collaborator

That's ironical, as with your PR 4 months ago, the missing argument was added: 37d8a08

I guess you have an outdated library version locally but GitHub action fetches the latest library version, and that causes the difference in behavior

@3C0D
Copy link
Contributor Author

3C0D commented Feb 10, 2025

I did a similar pull request there. But I forgot to add the previous one
4b32ff7

@3C0D
Copy link
Contributor Author

3C0D commented Feb 10, 2025

Ah ok I didn't see this one. But strange fact I'm using obsidian-typing: latest

@3C0D
Copy link
Contributor Author

3C0D commented Feb 10, 2025

OK I see I didn't do a npm i since a long time maybe. edit: rather npm update

@mnaoumov
Copy link
Collaborator

mnaoumov commented Feb 10, 2025

I honestly avoid "library": "latest". It is often misleading. I use "library": "^1.2.3"

And from time to time I call npx npm-check-updates -u && npm install

@mnaoumov
Copy link
Collaborator

I did a similar pull request there. But I forgot to add the previous one 4b32ff7

Added in https://github.com/Fevol/obsidian-typings/releases/tag/2.19.0

@3C0D
Copy link
Contributor Author

3C0D commented Feb 10, 2025

Thank you so much for your help with this! Your workaround worked perfectly, and the release is now live.
I tried to improve my approach a bit, but honestly, your skills are on another level. It’s really impressive. I mostly tinker with Obsidian when I need something specific, even though I don’t use it as much as I used to.

Thanks again for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants