Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Meeting Notes, 11/20/2015 #5740

Closed
RyanCavanaugh opened this issue Nov 20, 2015 · 2 comments
Closed

Design Meeting Notes, 11/20/2015 #5740

RyanCavanaugh opened this issue Nov 20, 2015 · 2 comments
Labels
Design Notes Notes from our design meetings

Comments

@RyanCavanaugh
Copy link
Member

  • Walkthrough of JSX SFCs and IntrinsicAttributes
  • Walkthrough of Salsa JS Class inference
  • Type inference for intersection/union types
    • πŸ‘
  • Grand unified theory of enums
    • Clear your mind and let's go on a journey of imagination 🌈 ⭐
    • Imagine a "string enum" enum Direction { North = 'north', South = 'south', ...}
    • type NS = Direction.North|Direction.South
    • What does this declaration actually mean?
      • It produces the following declarations
        • namespace Direction {
        • const North = "north" <- const North: North or const North: Direction ?
        • type North = "north"
        • }
        • type Direction = Direction.North | Direction.South | ...
      • It's not just contextual typing that needs to apply here
        • But we could tweak the rules
      • What should the assignability of strings to string literal types be?
    • This logic applies equally well to numbers!
    • How would we enforce enum branding in this scheme for numeric enums?
      • Add the ability to create 'fresh' types
      • A general solution for many problems
      • We could also enforce structural matching of the names
    • What about symbols?
      • Still no clear approach to handling symbol identity
    • Other primitive types are coming
      • Mostly numbers (UInt64, rational, bignum, struct, vector, etc...)
    • What should we inline?
      • Maybe const x = 10 ? With an opt-in
    • Mutable vs immutable widening, e.g.
      • let x = Direction.North; // x: Direction
      • const x = Direction.North; // x: Direction.North
      • What are the effects in e.g. function f() { let/const x = Direction.North; return x; } ?
@RyanCavanaugh RyanCavanaugh added the Design Notes Notes from our design meetings label Nov 20, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Nov 20, 2015

some additional notes on JSX and JS prototype assignments:

JSX

  • Fix ref and key unknown attribute by adding IntrinsicClassAttributes adds all globally available properties
  • JSX statles function components
    • add IntrinsicAttributes interface
    • a valid reference in a JSX element has to be a class with a constructor returning a JSX element or a function returning JSX element.

Prototype assignments in Js

  • Class inference from prototypes in JavaScriptΒ #5578
  • In a JS file a protptype assignments makes a function behave as a class
  • all assignemtns to this properties become property declarations
  • do not support MyClass.prototype = {}
  • what marks a class:
    • this assignment in the body
    • no, these are too common, a lot of false positives
    • case, upper case means a class
    • no return statements
    • common pattern for functions used as a class or a function
  • type of this typed as any for now in function bodies
  • need to iterate on this and get user feedback to see what is the best practice here
  • Possibly make SALSA configurable

@basarat
Copy link
Contributor

basarat commented Nov 23, 2015

Fix ref and key unknown attribute by adding IntrinsicClassAttributes adds all globally available properties

thank you 🌹!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

3 participants