Comments (8)
@Darhagonable Done! For now I literally export the types that were there, maybe in the future it would make more sense to organise them into a separate types
folder
from openapi-ts.
That sounds right. Honestly, you might be the only person using those types right now, since in the past you couldn't get to them in any other way than ReturnType<typeof DefaultService.foo>
which is why I started using that. Of course, there might be times when you don't want to pull in the service import to your file. We could make the types exported too as you wrote above, but the more you export the more likelihood there will be a naming conflict, and we currently don't have a good way to detect and correct those. Also, this tree structure is a setup for #28. Once that is resolved, maybe we can clean it up a bit
from openapi-ts.
You can access them via Parameters<typeof MyService.operationName>[0]
I believe, does that work for you?
from openapi-ts.
Thats what im currently doing. It works but is more verbose. Exporting those types would be a nice to have though :P
from openapi-ts.
@mrlubos types like this no longer seem to be exported or am i missing some migration step at some point?
from openapi-ts.
Are you able to import $OpenApiTs
from types.gen
? Just be warned this API isn't finalised yet and may change. I personally tend to use service classes to get to response or payload types - ReturnType<typeof DefaultService.foo>
from openapi-ts.
@mrlubos Yes i can import $OpenApiTs
.
So if I'm understanding correctly TDataGetApiV1Foo
has been changed to $OpenApiTs["/api/v1/foo"]["get"]["req"]
?
Should probably be added to the migrations docs.
Seems then that the verbose ReturnType
useage is the preferred option indeed.
from openapi-ts.
For now then ill do my own exports export type TDataGetApiV1Foo = ReturnType<typeof DefaultService.foo>
👍
from openapi-ts.
Related Issues (20)
- Rename conflicting TypeScript identifiers
- DeprecationWarning: fs.Stats constructor is deprecated HOT 3
- export eslint.rules for external usage HOT 3
- Got client HOT 15
- Non-global clients/configs HOT 6
- Export services as module instead of class to enable tree shaking. HOT 10
- Unused @ts-expect-error comment HOT 11
- Support for exactOptionalPropertyTypes in tsconfig.json HOT 2
- Validate response against openapi schema HOT 1
- Standalone package for your client HOT 1
- [question] How does this package compare to `openapi-typescript`? HOT 2
- can't generate a node16 moduleResolution compatible package HOT 8
- Improve support for `Accept` and `Content-Type` headers
- Newly exported `DefaultService` does not exist HOT 14
- Export `FetchClient` interface
- Parameters with `in: header` cause incompatible types HOT 3
- fetch client: snake_case path arguments get converted to camelCase in types, but not in template string HOT 3
- Error types no longer strongly typed
- Add tsconfig tests
- FormData date type casted with qutoes HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-ts.