MetaProperty is possibly nullish (#60440)
This commit is contained in:
Родитель
30979c2651
Коммит
55f1248a20
|
@ -39911,6 +39911,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.MetaProperty:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.YieldExpression:
|
||||
|
|
|
@ -96,4 +96,11 @@ predicateSemantics.ts(52,14): error TS2869: Right operand of ?? is unreachable b
|
|||
~~~~~~~~~~
|
||||
!!! error TS2869: Right operand of ?? is unreachable because the left operand is never nullish.
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
class X {
|
||||
constructor() {
|
||||
const p = new.target ?? 32;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,13 @@ function foo(this: Object | undefined) {
|
|||
const e = (i++, i++) ?? true; // error
|
||||
const f = (maybe, i++) ?? true; // error
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
class X {
|
||||
constructor() {
|
||||
const p = new.target ?? 32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [predicateSemantics.js]
|
||||
|
@ -106,3 +113,12 @@ function foo() {
|
|||
var e = (_h = (i++, i++)) !== null && _h !== void 0 ? _h : true; // error
|
||||
var f = (_j = (maybe, i++)) !== null && _j !== void 0 ? _j : true; // error
|
||||
}
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
var X = /** @class */ (function () {
|
||||
function X() {
|
||||
var _newTarget = this.constructor;
|
||||
var _a;
|
||||
var p = (_a = _newTarget) !== null && _a !== void 0 ? _a : 32;
|
||||
}
|
||||
return X;
|
||||
}());
|
||||
|
|
|
@ -104,3 +104,15 @@ function foo(this: Object | undefined) {
|
|||
>i : Symbol(i, Decl(predicateSemantics.ts, 48, 5))
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
class X {
|
||||
>X : Symbol(X, Decl(predicateSemantics.ts, 52, 1))
|
||||
|
||||
constructor() {
|
||||
const p = new.target ?? 32;
|
||||
>p : Symbol(p, Decl(predicateSemantics.ts, 57, 9))
|
||||
>new.target : Symbol(X, Decl(predicateSemantics.ts, 52, 1))
|
||||
>target : Symbol(X, Decl(predicateSemantics.ts, 52, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -308,3 +308,23 @@ function foo(this: Object | undefined) {
|
|||
> : ^^^^
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
class X {
|
||||
>X : X
|
||||
> : ^
|
||||
|
||||
constructor() {
|
||||
const p = new.target ?? 32;
|
||||
>p : 32 | typeof X
|
||||
> : ^^^^^^^^^^^^^
|
||||
>new.target ?? 32 : 32 | typeof X
|
||||
> : ^^^^^^^^^^^^^
|
||||
>new.target : typeof X
|
||||
> : ^^^^^^^^
|
||||
>target : typeof X
|
||||
> : ^^^^^^^^
|
||||
>32 : 32
|
||||
> : ^^
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,3 +51,10 @@ function foo(this: Object | undefined) {
|
|||
const e = (i++, i++) ?? true; // error
|
||||
const f = (maybe, i++) ?? true; // error
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60439
|
||||
class X {
|
||||
constructor() {
|
||||
const p = new.target ?? 32;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче