Giter Club home page Giter Club logo

leavify's Introduction

function Developer(name) {
  this.name = name;
}
Developer.prototype.greet = function () {
  console.log("Hi, I'm", this.name);
};

const davi = new Developer('Davi Alexandre');
davi.greet();

leavify's People

Contributors

davi-alexandre avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

leavify's Issues

v0.2.0 todo

  • default export.
  • Figure out why import intellisense sometimes keeps suggesting the dist folder.
  • write more tests, to cover the function arguments as well.
  • Change package description
  • start with the readme.
  • Rename the function toChangeSet, since it refers to the type Changes and not ChangeSet.
  • remove the type ChangeSet.
  • Consider removing the Change and Changes types.
  • Throw error instead of returning empty object in get() for the leaf values that do not exist; use has() instead.
  • Return the changed leaf instead of type Change in findChanges(), given it's a special case for the mapLeaf() argument and harder to programatically read.
  • Consider the return type of toTree(), as other than unknown. [object]
  • Add Branch type

(Re) Implementing path-value autocompletion

Forgot to mention in the commit message, but ba1cd1f deletes the functionality which autocompletes a leaf-path and its leaf-value.
The reason for it is that typescript gets too slow. "To much type instantiation", thinking it was possibly infinite.

I think the problem was the use of three recursive types in a row, namely Fragment<T> = Tree<RecursivePartial<T>>, and finally LeafPath<Fragment<T>>. The solution was to just ask whether T extends Fragment.

So... I'll be getting back to this later, and check whether the lagging continues. Specifically, the deleted types are:

  1. LeafValue - which autocompletes for the possible values (when using as const) or their general type.
  2. PathLeafPair - the path and either its as const value or its general type.
const sample = [42, {prop: 'value'}] as const;
const pair: PathLeafPair<typeof sample> = ['[1].prop', 'value'] // or ['[0]', 42]

Use the object's prototype to store the changes

Consider not using any symbols, using the original and proposed properties directly, assuming these are not already present in the prototype.
Try to create class instances with these names as inherited fields or methods, and see if they collide or smth
I think they are stored 2 levels deep in the instance's prototypal inheritance chain, idk

Child referencing parent breaks autocompletion

class Book {
  title: string;
  chapters: Chapter[];
}
class Chapter {
  book: Book;
}
const path: LeafPath<Book> = 'title';

=> Results in path: any or Type instantiation is excessively deep and possibly infinite.ts(2589)

Possible solutions

1. Ideal solution: interpolate circular reference to any

It works hand-to-hand with RecursivePartial, that can provide intellisense for an arbitrary depth. In the above case, it would interpolate to:

path: `chapters[${number}].book${any}`

2. Omit from type

  • detect circular reference in type automatically, or
  • rely on the user omitting it from the type, as in:
    const path: LeafPath<Omit<Book, 'chapters'>> = 'title'

Circular reference false positive

const ob = [0, [1, [2]]];
type Bug = LeafPath<typeof ob>;
// -> 
  | '[]'
  | `[${number}]`
  | `[${number}][${number}]`
  | `[${number}][]`
  | `[][${number}]`
  | `[][]${any}`
  | `[][${number}]${any}`
  | `[${number}][]${any}`
  | `[${number}][${number}]${any}`

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.