total-typescript / untypeable Goto Github PK
View Code? Open in Web Editor NEWGet type-safe access to any API, with a zero-bundle size option.
Get type-safe access to any API, with a zero-bundle size option.
Currently the documentation references importing untypeable/client
but it seems that the type definitions for this and all other exports does not seem to be working. This is likely due to the fact that types
property inside of exports
is not widely supported yet.
For now as a workaround it is possible to import untypeable/dist/client
instead but it would be good to add a typesVersions
property to the package.json
to add support for anyone not using NodeNext
as their TypeScript module setting.
Not an issue so feel free to close or delete but would love a video on this. I dont quite understand it from the docs, not because of the docs themselves but i struggle to understand documentation in general, videos always seem to get the point across. thank you.
Currently if you pass in an input where all properties are optional you are still required to pass in an empty object as a second argument. For example:
import { initUntypeable, createTypeLevelClient } from "untypeable";
const u = initUntypeable();
interface User {
id: string;
name: string;
};
const router = u.router({
"/user": u.input<{ id?: string }>().output<User>(),
});
const client = createTypeLevelClient<typeof router>((path, input) => {
return fetch(`http://localhost:3000${path}?${new URLSearchParams(input)}`).then(
(res) => res.json(),
);
});
const user = await client("/user", {});
// ^ Without this empty object TypeScript will complain that a 2nd argument is missing
Ideally it would be better if it was checked it all properties for an input record are optional & if so make the 2nd argument for the client function optional / default to an empty object.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.