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 occurs in typescript project #200

Open
machenity opened this issue Jan 21, 2020 · 6 comments
Open

Error occurs in typescript project #200

machenity opened this issue Jan 21, 2020 · 6 comments

Comments

@machenity
Copy link
Contributor

Using this in typescript project occurs error:

main.d.ts: Cannot find module 'swagger-schema-official'

스크린샷 2020-01-21 오전 11 30 10

I guess It is because swagger-schema-official is a devdependency of openwhisk, and npm install doesn't install the devdependencies of the dependencies.
Are there any ways to solve the error or I should just ignore it?

@DrewML
Copy link
Contributor

DrewML commented Feb 21, 2020

@machenity ran into this today as well.

A simple fix for your project is to include @types/swagger-schema-official as a devDependencies entry in your project's package.json, but that's more of a hack since you're putting a direct dependency on what's really a transitive dependency - versioning could get weird.

For projects that publish external type definitions (like openwhisk-client-js), it's typically recommended to publish definitions through DefinitelyTyped, since that project's build process will generate a package.json with proper dependencies based on import declarations. So @types/openwhisk-client-js would have a dependency on @types/swagger-schema-official.

If the authors of this project want to keep the d.ts file in this repo, the fix would be putting a hard dependency on @types/swagger-schema-official, the downside being that non-TS users will all have a superfluous dependency on disk.

@machenity
Copy link
Contributor Author

@DrewML Thanks for your kind answer! I just installed @types/swagger-schema-official manually.
Has this project been discussed for exporting a declaration file to DefinitelyTyped?

@machenity machenity changed the title Error occurrs in typescript project Error occurs in typescript project Feb 25, 2020
@DrewML
Copy link
Contributor

DrewML commented Feb 26, 2020

Thanks for your kind answer!

No problem!

Has this project been discussed for exporting a declaration file to DefinitelyTyped?

To be honest I'm not totally sure - I'm pretty new to working with OpenWhisk myself.

Maybe something that @rabbah might know?

@rabbah
Copy link
Member

rabbah commented Feb 27, 2020

Thanks for tagging me @DrewML. Maybe we can convert the entire library to ts :D

We haven't discussed it but we welcome contributions.

@DrewML
Copy link
Contributor

DrewML commented Mar 10, 2020

Maybe we can convert the entire library to ts :D

@rabbah That would be pretty awesome 😄. Any idea if there would be pushback from other folks involved in the project? Technically can go the full .ts file route, but we can also use tsc to type check jsdoc-style comments (source) if that would make adoption more palatable.

@rabbah
Copy link
Member

rabbah commented Mar 10, 2020

I think it would be welcomed - if you're interested, I'd suggest sending a note to the project dev list ([email protected]) where community members could then more broadly participate.

What's important is to note that this package is used a lot both by the project and others downstream, so being mindful that compatibility is important.

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

3 participants