Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 565 Bytes

public-fields-syntax-ambiguity-1.md

File metadata and controls

46 lines (32 loc) · 565 Bytes
\
	[x] = [1, 2, 3]
\
class Test {
	[x] = [1, 2, 3]
}

Destructuring?

Computed property

Same syntax, very different semantics

  • bad to novices,

  • bad to programmers from other languages,

  • also bad to professional JS programmers

  • rarely known,

  • rarely used,

  • hard to recognize

TypeScript already support it years?

NO

TS 2.7+ (Jan 31, 2018)

Possible solution

New ESLint rule, no-class-computed-field

  • Well-known symbols are for methods/accessors,
  • Private fields instead of symbol-based private

No big use case

Just drop it!