mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
31 lines
535 B
TypeScript
31 lines
535 B
TypeScript
//// [tests/cases/compiler/incrementOnNullAssertion.ts] ////
|
|
|
|
//// [incrementOnNullAssertion.ts]
|
|
interface Dictionary<T> {
|
|
[myFavouriteType: string]: T | undefined
|
|
}
|
|
const x = 'bar'
|
|
let foo: Dictionary<number> = {}
|
|
if (foo[x] === undefined) {
|
|
foo[x] = 1
|
|
}
|
|
else {
|
|
let nu = foo[x]
|
|
let n = foo[x]
|
|
foo[x]!++
|
|
}
|
|
|
|
|
|
//// [incrementOnNullAssertion.js]
|
|
"use strict";
|
|
const x = 'bar';
|
|
let foo = {};
|
|
if (foo[x] === undefined) {
|
|
foo[x] = 1;
|
|
}
|
|
else {
|
|
let nu = foo[x];
|
|
let n = foo[x];
|
|
foo[x]++;
|
|
}
|