feat(compiler): support a non-null postfix assert (#16672)
Template expressions can now use a post-fix `!` operator that asserts the target of the operator is not null. This is similar to the TypeScript non-null assert operator. Expressions generated in factories will be generated with the non-null assert operator. Closes: #10855
This commit is contained in:

committed by
Jason Aden

parent
2eca6e67e1
commit
b9521b568f
@ -146,6 +146,7 @@ export function main() {
|
||||
const lhs = o.variable('lhs');
|
||||
const rhs = o.variable('rhs');
|
||||
expect(emitStmt(o.not(someVar).toStmt())).toEqual('!someVar;');
|
||||
expect(emitStmt(o.assertNotNull(someVar).toStmt())).toEqual('someVar;');
|
||||
expect(
|
||||
emitStmt(someVar.conditional(o.variable('trueCase'), o.variable('falseCase')).toStmt()))
|
||||
.toEqual('(someVar? trueCase: falseCase);');
|
||||
|
@ -232,6 +232,7 @@ export function main() {
|
||||
const rhs = o.variable('rhs');
|
||||
expect(emitStmt(someVar.cast(o.INT_TYPE).toStmt())).toEqual('(<number>someVar);');
|
||||
expect(emitStmt(o.not(someVar).toStmt())).toEqual('!someVar;');
|
||||
expect(emitStmt(o.assertNotNull(someVar).toStmt())).toEqual('someVar!;');
|
||||
expect(
|
||||
emitStmt(someVar.conditional(o.variable('trueCase'), o.variable('falseCase')).toStmt()))
|
||||
.toEqual('(someVar? trueCase: falseCase);');
|
||||
|
Reference in New Issue
Block a user