Giter Club home page Giter Club logo

Comments (4)

kaleidawave avatar kaleidawave commented on May 15, 2024

Where I can try Ezno? Please add some online sandbox where I can try Ezne online

Currently not public, will be by the summer hopefully when I have more time.

Here is interesting example that makes you think about whole soundness of type checking

Yes this is an interesting issue that is really important for type safety. Under the type rules (which follow TypeScript), it is valid to pass obj to anotherFunc. And while this passes under the rules of TypeScript it will throw at runtime as there is no property .length on null.

Haven't tested but it all the data should be present as Ezno does track mutation effects. I think it would throw a property does not exist on the obj.field.length line.

from ezno.

kaleidawave avatar kaleidawave commented on May 15, 2024

Interestingly this is solved in Flow because they do not accept passing a general type to a union type.

https://flow.org/try/#1N4Igxg9gdgZglgcxALmAXwDTggEwKYogwCuUYALnNAAQCGUE5AFngE4BipYAPACrXJqweHgA2OQQGdyrOFATUAPtSjFRotAD4AFBABGAK0G8AlMAA6UateoB6W9X0GAdCPHUAvCrWiA3JZtqSChJCFE8Z1EIBG1zECY4OJNLNH8oSxIyShpQgFs8TjI+ASE3CWppWXktXUNjMwCbJ1c4MRw0wPpGFg4uWoMTDqbDFrbIvHlmNNSQLAA3NkkqKEI5gAZnACY1zecARhA0IA

I don't like this behaviour and diverges from TS. So effects are the way to go here

from ezno.

kaleidawave avatar kaleidawave commented on May 15, 2024

This sort of works. Given

const x = { a: 2 }
function updateA(obj: { a: string | number }) {
    obj.a = "hi"
}
updateA(x)
const y: number = x.a

It errors with Type "hi" is not assignable to type number. See specification.md#updating-property

Need to test with arrays and currently doesn't respect if x has an assingment restriction, so not perfect yet

from ezno.

kaleidawave avatar kaleidawave commented on May 15, 2024

I think this is now solved with

https://github.com/kaleidawave/ezno/blob/0881454c9de4579273d4941f8af29c33f99af34c/checker/specification/specification.md#assignment-to-union

and

https://github.com/kaleidawave/ezno/blob/0881454c9de4579273d4941f8af29c33f99af34c/checker/specification/specification.md#mutating-an-object-by-a-function

Might come back to make more user friendly and double check all the edge cases are identified at some point, but for now it is at least identified 🎉

from ezno.

Related Issues (20)

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.