Typescript: Suggestion Backlog Slog, 4/3/2017

Created on 3 Apr 2017  路  1Comment  路  Source: microsoft/TypeScript

"Do crazy stuff while Mohamed is out" edition 馃懚

  • #16 Safe Navigation operator
  • #3508 ESNext 'bind' operator ::
  • #563 Partial classes
  • #1206 string enums
  • #13721 Pure annotation on downlevel emits
  • #3854 protected in interfaces
  • #5296 Spread for function calls
  • #14764 Disallow comparing string | null to undefined
  • #10715 unknown alternative to any
  • #14762 T & {} should just be T, at least in typeToString
  • #338 Allow super.get/set
  • #766 Allow declaring class members in the constructor
  • #5156 > operator and friends on union types
  • #10570 Inherited typing for class property initializers
  • #14417 Optional getters in classes
Design Notes

Most helpful comment

  • #16 Safe Navigation operator

    • Not at stage 2 yet; behavior may differ

    • We have opinions on null and undefined coalescing

    • Ryan wants us to be ahead rather than behind on features

    • Not even in Babel yet?

    • Even stage 2 isn't safe (decorators!)

    • Start work at stage 2; stage 1 is too early

    • Let's wait until stage 2

  • #3508 ESNext 'bind' operator ::

    • Very important open questions on semantics, which may differ widely in behavior

    • Exact binding location is unclear

    • Wait for stage 2

  • #563 Partial classes

    • Sugar for existing syntax, sometimes

    • Not part of ES6

    • Trying to avoid new ES6 class features

    • We're not trying to reinvent C# as much as people like to pretend otherwise

    • The side effects of this with modern modules are simply bad

    • JavaScript has better compositional patterns available

    • :-1: hasn't happened by now, not going to

  • #1206 string enums

    • Everyone wants them

    • They're awesome

    • Come on

    • What about taking enums to TC39?

    • Sugar for what we can already do

    • We keep saying "Don't use namespace because modules are better" but then use namespaces for all would-be sugar features

    • Another sketch

 enum Foo {
    Red = "Red is my Favorite Color",
    Green = "Green is my Favorite color",
    Blue = "Blue!"
}

namespace Foo {
    export const Red: "Red" = "Robin";
    export type Red = typeof Red;
    export const Blue: "Blue" = "Bluebird";
    export type Blue = typeof Blue;
}
// "Robin" | "Bluebird"

type Foo = Foo.Red | Foo.Blue;
  • Ryan to write minispec

    • #13721 Pure annotation on downlevel emits

    • Needed for good treeshaking

    • Wouldn't emit if it had static non-literal initializers

    • Debate about terminology

    • Want to emit something understood by both uglify and closure

    • Why don't minifiers just recognize this pattern?



      • Not enough resources, requires a lot of CFA



    • We could just write /* class */ and the minifiers have to figure out side effects

    • :+1: with follow-up on uglify, Daniel to address

    • #14764 Disallow comparing string | null to undefined

    • Currently a hack

    • It's all ad hoc

    • Proposed rule: You can't test for the "wrong" empty

    • Checking for undefined is good defensiveness, checking for null is suspicious

    • AMF

    • #14762 T & {} should just be T, at least in typeToString

    • Filter this out when there no observable effects

    • :+1: (Anders knows what to do)

Out of time

  • #3854 protected in interfaces
  • #5296 Spread for function calls
  • #10715 unknown alternative to any
  • #338 Allow super.get/set
  • #766 Allow declaring class members in the constructor
  • #5156 > operator and friends on union types
  • #10570 Inherited typing for class property initializers
  • #14417 Optional getters in classes

>All comments

  • #16 Safe Navigation operator

    • Not at stage 2 yet; behavior may differ

    • We have opinions on null and undefined coalescing

    • Ryan wants us to be ahead rather than behind on features

    • Not even in Babel yet?

    • Even stage 2 isn't safe (decorators!)

    • Start work at stage 2; stage 1 is too early

    • Let's wait until stage 2

  • #3508 ESNext 'bind' operator ::

    • Very important open questions on semantics, which may differ widely in behavior

    • Exact binding location is unclear

    • Wait for stage 2

  • #563 Partial classes

    • Sugar for existing syntax, sometimes

    • Not part of ES6

    • Trying to avoid new ES6 class features

    • We're not trying to reinvent C# as much as people like to pretend otherwise

    • The side effects of this with modern modules are simply bad

    • JavaScript has better compositional patterns available

    • :-1: hasn't happened by now, not going to

  • #1206 string enums

    • Everyone wants them

    • They're awesome

    • Come on

    • What about taking enums to TC39?

    • Sugar for what we can already do

    • We keep saying "Don't use namespace because modules are better" but then use namespaces for all would-be sugar features

    • Another sketch

 enum Foo {
    Red = "Red is my Favorite Color",
    Green = "Green is my Favorite color",
    Blue = "Blue!"
}

namespace Foo {
    export const Red: "Red" = "Robin";
    export type Red = typeof Red;
    export const Blue: "Blue" = "Bluebird";
    export type Blue = typeof Blue;
}
// "Robin" | "Bluebird"

type Foo = Foo.Red | Foo.Blue;
  • Ryan to write minispec

    • #13721 Pure annotation on downlevel emits

    • Needed for good treeshaking

    • Wouldn't emit if it had static non-literal initializers

    • Debate about terminology

    • Want to emit something understood by both uglify and closure

    • Why don't minifiers just recognize this pattern?



      • Not enough resources, requires a lot of CFA



    • We could just write /* class */ and the minifiers have to figure out side effects

    • :+1: with follow-up on uglify, Daniel to address

    • #14764 Disallow comparing string | null to undefined

    • Currently a hack

    • It's all ad hoc

    • Proposed rule: You can't test for the "wrong" empty

    • Checking for undefined is good defensiveness, checking for null is suspicious

    • AMF

    • #14762 T & {} should just be T, at least in typeToString

    • Filter this out when there no observable effects

    • :+1: (Anders knows what to do)

Out of time

  • #3854 protected in interfaces
  • #5296 Spread for function calls
  • #10715 unknown alternative to any
  • #338 Allow super.get/set
  • #766 Allow declaring class members in the constructor
  • #5156 > operator and friends on union types
  • #10570 Inherited typing for class property initializers
  • #14417 Optional getters in classes
Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartynasZilinskas picture MartynasZilinskas  路  3Comments

wmaurer picture wmaurer  路  3Comments

remojansen picture remojansen  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

seanzer picture seanzer  路  3Comments