Reputation: 21480
I want to expoort string contsnt but in such way that it would be inlined in all places it is used it and variable von't be created. I know it's possible with const enum
:
const enum SomeEnum {
SOME_VALUE = "SOME_VALUE"
}
alert(SomeEnum.SOME_VALUE);
compiles into
"use strict";
alert("SOME_VALUE" /* SOME_VALUE */);
But I'm interested in making dotless access to the value, i. e. I want to write
alert(SOME_VALUE);
and I want it to be compiles into the same thing.
How can I declare SOME_VALUE
to archive that?
Upvotes: 1
Views: 1358
Reputation: 11686
As of 2020-09, you cannot,
Here's a discussion about such a feature — inline constants — over at the Typescript GitHub repo: https://github.com/microsoft/TypeScript/issues/3964
Update: Now that issue got closed:
given the feedback so far and the risk of the feature, it's safe to say this isn't happening
So, likely Never, then.
Upvotes: 2