Giter Club home page Giter Club logo

untypeable's People

Contributors

mattpocock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

untypeable's Issues

Fix module export type definitions

What is the issue?

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.

Screenshot 2023-03-15 at 9 37 47 am

How to fix it?

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* would love a video tutorial on this

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.

Fully optional inputs should not require a 2nd parameter

What is the issue?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.