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

Update code to be compatible with typescript (4.8+) strict mode #39

Open
perbergland opened this issue Jan 1, 2023 · 4 comments
Open

Comments

@perbergland
Copy link
Contributor

I get the following error when using the package with zodern:types (it brings in the implementation file as a typings file)

.meteor/local/types/node_modules/package-types/tmeasday_check-npm-versions/package/web.browser.legacy/check-npm-versions.ts (28,21): 'e' is of type 'unknown'.

The problem is that in strict mode, catch (e) is now by default catch (e:unknown) - I believe this was introduced in typescript 4.8.

Please change the code to use catch (e: any):

if (semver.satisfies(installedVersion, range)) {
      return true;
    } else {
      return installedVersion;
    }
  } catch (e: any) {
    // XXX add something to the tool to make this more reliable
    const message = e.toString();
    // One message comes out of the install npm package the other from npm directly
    if (message.includes('Cannot find module') === true || message.includes("Can't find npm module") === true) {
      return false;
    } else {
      throw e;
    }
  }
@github-actions
Copy link

github-actions bot commented Jan 1, 2023

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee you issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know

@perbergland
Copy link
Contributor Author

The workaround for now is to set "useUnknownInCatchVariables": false in your tsconfig.json file

@perbergland
Copy link
Contributor Author

Another fix would be to generate and include a .d.ts typings file in the package

@StorytellerCZ
Copy link
Member

I think doing types with zodern:types is a good step.

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

2 participants