Skip to content

Design Meeting Notes, 5/15/2020 #38694

@DanielRosenwasser

Description

@DanielRosenwasser

Having JSON.stringify(expr) return string | undefined

#38574

  • We approved an issue about JSON.stringify potentially returning undefined.
    • JSON.stringify(function() {}) -> undefined
    • JSON.stringify(undefined) -> undefined
    • JSON.stringify(Symbol()) -> undefined
    • JSON.stringify({ toJSON() {} }) -> 🤷‍♀️
    • JSON.stringify(?????) -> string
  • Thinking
    • JSON.stringify(object | undefined) -> string | undefined
    • JSON.stringify(any) -> string
  • What are the goals?
  • Should've said it was string | undefined from the beginning, but strictNullChecks came later and we didn't wanna break people.
  • Fixing this is a fool's errand.
  • Won't fix?
    • Can't fix, won't fix, don't know how to fix.
    • The cure is worse than the disease.

Upper Bounds of Types Resolved to any

#38555
#29571

  • Should we specially interpret function fn<T extends U>(arg: T) when U is a type that resolves to any?
    • Substituting a type with any ideally shouldn't break existing code.
    • But users were using this to say "from the outside, I'm sound, from the inside I'm not".
  • Using any as a type constraint is a foot-gun.
    • But any itself is a foot-gun.
  • What about syntactic any being different?
    • Could give an error on syntactic any: "you mean unknown"
    • Seems strange.
  • extends any might be meaningful, but 50% of the time that meaning might not be obvious to people, causes more bugs.
  • Conclusion
    • Reconsider with more feedback
    • No plans for servicing release

Emitting empty export lists, and other fun problems with bundlers

webpack/webpack#10889

  • Do we need to start emitting export {}?

    • Maybe not for empty modules.
  • We're not emitting export {} for value-ful modules though.

    export type Yadda = any;
    
    var a = 10;
    
    export { };
    • Affects other stuff (e.g. strict mode)
    • We also don't emit anything in empty files when alwaysStrict is on.
      • Because we assume that, well, it's a module.
  • Weird because we emit export {} for .d.ts files.

  • Conclusion

    • Don't restore export * behavior
    • Evaluate where export {} may need to be injected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions