-
Notifications
You must be signed in to change notification settings - Fork 10
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
Generator fails to use type from library #9
Comments
Or is this because of the namespace? Could there be at least some hard overwrite, something like the magicTypes, but which would not check if the file exists, just replace the type and not fail? |
What do you mean exactly? The type cannot be imported as the |
Sorry, probably didnt explain it correctly. Also might be that I'm not understanding some part correctly, namely the In my case the So I would need either:
The latter is the same (similar) as done in the magicTypes, where I could import the local package in the Referenced code snippets: nest-sdk-generator/src/analyzer/extractor.ts Lines 207 to 211 in 5b5637d
Lines 189 to 199 in 5b5637d
|
Thanks for the explanation. Auto-extracting the types required from the namespace is actually really hard, which is why it isn't available as a feature in the SDK generator. The way namespaces work in the TypeScript compiler is really hard makes them really hard to use. The package replacement solution would be interesting though, but it requires the exact same package to be present on the client and server side - is that your case? |
Yes, in my case it is exactly the same package. It could also work for cases when type definition packages are being shared among frontend/backend for other use cases than only direct API interaction and don't need to be included. Basically it would be just saying to the nest-sdk-generator that this package is "peer dependency" of the SDK and the types will not be included in the output and it is up to the user of the sdk to include it. |
Btw, I was looking at other solutions (I like your's because of the approach with using custom request function allowing to include it more seamlessly to the client project¹) and some of them generate a full npm package including package.json (which I also like²), where the peerDependency could be explicitly specified. ¹ I can expect same response type (Observable/Promise and structure) as the HTTP library used elsewhere in the app |
I have created a little proof of concept repo with the suggested changes:
|
Thanks for your contribution ; I don't think it would be a good idea to generate a You can also have a different version requirement between the client and the server (e.g. you don't update the server for whatever reason but need to update the client, or vice-versa). I think it would be more relevant to just add an option to specify that some packages should be imported from the same package client-side instead of extracting it. |
Tried to use controller, which returns some data directly from
stripe
library butnest-sdk-generator
fails with:The text was updated successfully, but these errors were encountered: