Skip to content

NonNullExpression could be implemented #224

Description

@cymerrad

Sometimes I'm sure that some key-value pairs exist in a map, so I'm using "!" to get around compiler/linter yelling at me, that the value I'm getting from this map may be undefined.

declare function print(...msg: any[]): void;

type OnlyPossibleValues = "a" | "b" | "c";
let valueToNumber: Map<OnlyPossibleValues, { property: number }> = new Map();
valueToNumber.set("a", { property: 1 });
valueToNumber.set("b", { property: 2 });
valueToNumber.set("c", { property: 3 });

// let possiblyDefinedValue = valueToNumber.get("a");
let definitelyDefinedValue = valueToNumber.get("b")!;
// print(possiblyDefinedValue.property);
print(definitelyDefinedValue.property);

Unfortunately this is not implemented, even though it wouldn't have any effect on Lua code, but it would improve working with Typescript.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions