Firacode: Disable Elvis ligature (?:) for optional TypeScript properties

Created on 11 Mar 2020  路  7Comments  路  Source: tonsky/FiraCode

I don't know languages where ?: is used as an operator well, but in TypeScript the sequence comes up a lot in interfaces, denoting optional properties in an interface:

image

The two characters don't form an operator here, they just happen to be next to each other, so the ligature is odd. Is ?: always (or at least usually) surrounded by spaces when it's used as an operator? Maybe it would work to only apply the ligature to :?, with the preceding space? (I don't have much experience with ligatures like this, so I have no idea if I'm asking for something reasonable.)

conflict

Most helpful comment

Kotlin uses ?: (elvis operator). It is conventionally surrounded by spaces. This is an unfortunate change for Kotlin users 馃槩

All 7 comments

Interesting! I鈥檒l mark it as a conflict but I鈥檓 not sure what can I do, except removing ligature altogether

It's used as ternary if operator in PHP. Spaces are not required.

@jdreesen Wouldn't that be foo ? bar : baz? That's not going to use the ?: ligature.

I know some languages (C?) use a ?: b as shorthand for a ? a : b or how a || b works in some languages.

@jdreesen Wouldn't that be foo ? bar : baz? That's not going to use the ?: ligature.

Right, but you can do $foo ?: $baz as shorthand, which returns $foo if $foo evaluates to true, and $baz otherwise. Example: https://3v4l.org/8H95j

Sad to see this go (I use it a lot in Kotlin, ObjC, and others), but I understand why it did

Kotlin uses ?: (elvis operator). It is conventionally surrounded by spaces. This is an unfortunate change for Kotlin users 馃槩

Was this page helpful?
0 / 5 - 0 ratings

Related issues

whatisaphone picture whatisaphone  路  3Comments

mlajtos picture mlajtos  路  4Comments

magnus-madsen picture magnus-madsen  路  3Comments

aolko picture aolko  路  3Comments

pedrowebcomum picture pedrowebcomum  路  4Comments