Test: Allow ++ after non-null assertion
This commit is contained in:
parent
55beb14bca
commit
497d627a02
28
tests/baselines/reference/incrementOnNullAssertion.js
Normal file
28
tests/baselines/reference/incrementOnNullAssertion.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
//// [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";
|
||||
var x = 'bar';
|
||||
var foo = {};
|
||||
if (foo[x] === undefined) {
|
||||
foo[x] = 1;
|
||||
}
|
||||
else {
|
||||
var nu = foo[x];
|
||||
var n = foo[x];
|
||||
foo[x]++;
|
||||
}
|
41
tests/baselines/reference/incrementOnNullAssertion.symbols
Normal file
41
tests/baselines/reference/incrementOnNullAssertion.symbols
Normal file
|
@ -0,0 +1,41 @@
|
|||
=== tests/cases/compiler/incrementOnNullAssertion.ts ===
|
||||
interface Dictionary<T> {
|
||||
>Dictionary : Symbol(Dictionary, Decl(incrementOnNullAssertion.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(incrementOnNullAssertion.ts, 0, 21))
|
||||
|
||||
[myFavouriteType: string]: T | undefined
|
||||
>myFavouriteType : Symbol(myFavouriteType, Decl(incrementOnNullAssertion.ts, 1, 5))
|
||||
>T : Symbol(T, Decl(incrementOnNullAssertion.ts, 0, 21))
|
||||
}
|
||||
const x = 'bar'
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
|
||||
let foo: Dictionary<number> = {}
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>Dictionary : Symbol(Dictionary, Decl(incrementOnNullAssertion.ts, 0, 0))
|
||||
|
||||
if (foo[x] === undefined) {
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
foo[x] = 1
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
}
|
||||
else {
|
||||
let nu = foo[x]
|
||||
>nu : Symbol(nu, Decl(incrementOnNullAssertion.ts, 9, 7))
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
|
||||
let n = foo[x]
|
||||
>n : Symbol(n, Decl(incrementOnNullAssertion.ts, 10, 7))
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
|
||||
foo[x]!++
|
||||
>foo : Symbol(foo, Decl(incrementOnNullAssertion.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(incrementOnNullAssertion.ts, 3, 5))
|
||||
}
|
||||
|
53
tests/baselines/reference/incrementOnNullAssertion.types
Normal file
53
tests/baselines/reference/incrementOnNullAssertion.types
Normal file
|
@ -0,0 +1,53 @@
|
|||
=== tests/cases/compiler/incrementOnNullAssertion.ts ===
|
||||
interface Dictionary<T> {
|
||||
>Dictionary : Dictionary<T>
|
||||
>T : T
|
||||
|
||||
[myFavouriteType: string]: T | undefined
|
||||
>myFavouriteType : string
|
||||
>T : T
|
||||
}
|
||||
const x = 'bar'
|
||||
>x : "bar"
|
||||
>'bar' : "bar"
|
||||
|
||||
let foo: Dictionary<number> = {}
|
||||
>foo : Dictionary<number>
|
||||
>Dictionary : Dictionary<T>
|
||||
>{} : {}
|
||||
|
||||
if (foo[x] === undefined) {
|
||||
>foo[x] === undefined : boolean
|
||||
>foo[x] : number | undefined
|
||||
>foo : Dictionary<number>
|
||||
>x : "bar"
|
||||
>undefined : undefined
|
||||
|
||||
foo[x] = 1
|
||||
>foo[x] = 1 : 1
|
||||
>foo[x] : number | undefined
|
||||
>foo : Dictionary<number>
|
||||
>x : "bar"
|
||||
>1 : 1
|
||||
}
|
||||
else {
|
||||
let nu = foo[x]
|
||||
>nu : number | undefined
|
||||
>foo[x] : number | undefined
|
||||
>foo : Dictionary<number>
|
||||
>x : "bar"
|
||||
|
||||
let n = foo[x]
|
||||
>n : number | undefined
|
||||
>foo[x] : number | undefined
|
||||
>foo : Dictionary<number>
|
||||
>x : "bar"
|
||||
|
||||
foo[x]!++
|
||||
>foo[x]!++ : number
|
||||
>foo[x]! : number
|
||||
>foo[x] : number | undefined
|
||||
>foo : Dictionary<number>
|
||||
>x : "bar"
|
||||
}
|
||||
|
14
tests/cases/compiler/incrementOnNullAssertion.ts
Normal file
14
tests/cases/compiler/incrementOnNullAssertion.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
// @strict: true
|
||||
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]!++
|
||||
}
|
Loading…
Reference in a new issue