Typescript: QuestionToken is not removed from method declaration emit

Created on 6 Nov 2019  路  2Comments  路  Source: microsoft/TypeScript


TypeScript Version: 3.7.2


Search Terms:

Code

// @target: es6
class Base {
    method?() { }
}

Expected behavior:

"use strict";
class Base {
    method() { }
}

Actual behavior:

"use strict";
class Base {
    method?() { }
}

Playground Link: http://www.typescriptlang.org/play/?target=2&ssl=3&ssc=2&pln=1&pc=1#code/MYGwhgzhAEBCkFNoG8BQ0PQLYIC4AsB7AEwH4AKAShWgF9V6g

Bug Fix Available

All 2 comments

Somehow this isn't a regression?!?!?!?

As far back as 2.4.1!
Holy shit!

I've never considered writing such a construct before...

Every time I've needed an "optional method", I would use,

class Base {
    method? : () => T
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Antony-Jones picture Antony-Jones  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

seanzer picture seanzer  路  3Comments

jbondc picture jbondc  路  3Comments

dlaberge picture dlaberge  路  3Comments