feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)

* feat(7481): add explicit type compatibility check with 'satisfies' expression

* Add failing test for lack of intersectioned contextual type

* Implement the behavior

* Add test corresponding to the 'if'

* Add test based on defined scenarios

* remove isExpression in favor of using type casting

* move tests from compiler to conformance folder

* update baseline

* add missing contextFlags argument

* use asserted type

* accept baseline

Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
This commit is contained in:
Oleksandr T
2022-08-26 20:05:52 +03:00
committed by GitHub
parent 07157914eb
commit 164dddc48e
102 changed files with 3172 additions and 449 deletions
+18
View File
@@ -27506,6 +27506,8 @@ namespace ts {
}
case SyntaxKind.NonNullExpression:
return getContextualType(parent as NonNullExpression, contextFlags);
case SyntaxKind.SatisfiesExpression:
return getTypeFromTypeNode((parent as SatisfiesExpression).type);
case SyntaxKind.ExportAssignment:
return tryGetTypeFromEffectiveTypeNode(parent as ExportAssignment);
case SyntaxKind.JsxExpression:
@@ -32442,6 +32444,20 @@ namespace ts {
}
}
function checkSatisfiesExpression(node: SatisfiesExpression) {
checkSourceElement(node.type);
const targetType = getTypeFromTypeNode(node.type);
if (isErrorType(targetType)) {
return targetType;
}
const exprType = checkExpression(node.expression);
checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
return exprType;
}
function checkMetaProperty(node: MetaProperty): Type {
checkGrammarMetaProperty(node);
@@ -35235,6 +35251,8 @@ namespace ts {
return checkNonNullAssertion(node as NonNullExpression);
case SyntaxKind.ExpressionWithTypeArguments:
return checkExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
case SyntaxKind.SatisfiesExpression:
return checkSatisfiesExpression(node as SatisfiesExpression);
case SyntaxKind.MetaProperty:
return checkMetaProperty(node as MetaProperty);
case SyntaxKind.DeleteExpression:
+9 -1
View File
@@ -1100,7 +1100,7 @@
"category": "Error",
"code": 1359
},
"Class constructor may not be a generator.": {
"Type '{0}' does not satisfy the expected type '{1}'.": {
"category": "Error",
"code": 1360
},
@@ -1132,6 +1132,10 @@
"category": "Message",
"code": 1367
},
"Class constructor may not be a generator.": {
"category": "Error",
"code": 1368
},
"Did you mean '{0}'?": {
"category": "Message",
"code": 1369
@@ -6376,6 +6380,10 @@
"category": "Error",
"code": 8036
},
"Type satisfaction expressions can only be used in TypeScript files.": {
"category": "Error",
"code": 8037
},
"Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit.": {
"category": "Error",
+12
View File
@@ -1763,6 +1763,8 @@ namespace ts {
return emitNonNullExpression(node as NonNullExpression);
case SyntaxKind.ExpressionWithTypeArguments:
return emitExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
case SyntaxKind.SatisfiesExpression:
return emitSatisfiesExpression(node as SatisfiesExpression);
case SyntaxKind.MetaProperty:
return emitMetaProperty(node as MetaProperty);
case SyntaxKind.SyntheticExpression:
@@ -2846,6 +2848,16 @@ namespace ts {
writeOperator("!");
}
function emitSatisfiesExpression(node: SatisfiesExpression) {
emitExpression(node.expression, /*parenthesizerRules*/ undefined);
if (node.type) {
writeSpace();
writeKeyword("satisfies");
writeSpace();
emit(node.type);
}
}
function emitMetaProperty(node: MetaProperty) {
writeToken(node.keywordToken, node.pos, writePunctuation);
writePunctuation(".");
+24
View File
@@ -222,6 +222,8 @@ namespace ts {
updateAsExpression,
createNonNullExpression,
updateNonNullExpression,
createSatisfiesExpression,
updateSatisfiesExpression,
createNonNullChain,
updateNonNullChain,
createMetaProperty,
@@ -3142,6 +3144,26 @@ namespace ts {
: node;
}
// @api
function createSatisfiesExpression(expression: Expression, type: TypeNode) {
const node = createBaseExpression<SatisfiesExpression>(SyntaxKind.SatisfiesExpression);
node.expression = expression;
node.type = type;
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildFlags(node.type) |
TransformFlags.ContainsTypeScript;
return node;
}
// @api
function updateSatisfiesExpression(node: SatisfiesExpression, expression: Expression, type: TypeNode) {
return node.expression !== expression
|| node.type !== type
? update(createSatisfiesExpression(expression, type), node)
: node;
}
// @api
function createNonNullChain(expression: Expression) {
const node = createBaseExpression<NonNullChain>(SyntaxKind.NonNullExpression);
@@ -5730,6 +5752,7 @@ namespace ts {
case SyntaxKind.ParenthesizedExpression: return updateParenthesizedExpression(outerExpression, expression);
case SyntaxKind.TypeAssertionExpression: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
case SyntaxKind.AsExpression: return updateAsExpression(outerExpression, expression, outerExpression.type);
case SyntaxKind.SatisfiesExpression: return updateSatisfiesExpression(outerExpression, expression, outerExpression.type);
case SyntaxKind.NonNullExpression: return updateNonNullExpression(outerExpression, expression);
case SyntaxKind.PartiallyEmittedExpression: return updatePartiallyEmittedExpression(outerExpression, expression);
}
@@ -6465,6 +6488,7 @@ namespace ts {
case SyntaxKind.ArrayBindingPattern:
return TransformFlags.BindingPatternExcludes;
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.SatisfiesExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.PartiallyEmittedExpression:
case SyntaxKind.ParenthesizedExpression:
+4
View File
@@ -438,6 +438,10 @@ namespace ts {
return node.kind === SyntaxKind.AsExpression;
}
export function isSatisfiesExpression(node: Node): node is SatisfiesExpression {
return node.kind === SyntaxKind.SatisfiesExpression;
}
export function isNonNullExpression(node: Node): node is NonNullExpression {
return node.kind === SyntaxKind.NonNullExpression;
}
+1
View File
@@ -437,6 +437,7 @@ namespace ts {
return (kinds & OuterExpressionKinds.Parentheses) !== 0;
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.SatisfiesExpression:
return (kinds & OuterExpressionKinds.TypeAssertions) !== 0;
case SyntaxKind.NonNullExpression:
return (kinds & OuterExpressionKinds.NonNullAssertions) !== 0;
+11 -3
View File
@@ -393,6 +393,9 @@ namespace ts {
[SyntaxKind.NonNullExpression]: function forEachChildInNonNullExpression<T>(node: NonNullExpression, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.expression);
},
[SyntaxKind.SatisfiesExpression]: function forEachChildInSatisfiesExpression<T>(node: SatisfiesExpression, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type);
},
[SyntaxKind.MetaProperty]: function forEachChildInMetaProperty<T>(node: MetaProperty, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.name);
},
@@ -841,7 +844,6 @@ namespace ts {
if (node === undefined || node.kind <= SyntaxKind.LastToken) {
return;
}
const fn = (forEachChildTable as Record<SyntaxKind, ForEachChildFunction<any>>)[node.kind];
return fn === undefined ? undefined : fn(node, cbNode, cbNodes);
}
@@ -5109,7 +5111,7 @@ namespace ts {
break;
}
if (token() === SyntaxKind.AsKeyword) {
if (token() === SyntaxKind.AsKeyword || token() === SyntaxKind.SatisfiesKeyword) {
// Make sure we *do* perform ASI for constructs like this:
// var x = foo
// as (Bar)
@@ -5119,8 +5121,10 @@ namespace ts {
break;
}
else {
const keywordKind = token();
nextToken();
leftOperand = makeAsExpression(leftOperand, parseType());
leftOperand = keywordKind === SyntaxKind.SatisfiesKeyword ? makeSatisfiesExpression(leftOperand, parseType()) :
makeAsExpression(leftOperand, parseType());
}
}
else {
@@ -5139,6 +5143,10 @@ namespace ts {
return getBinaryOperatorPrecedence(token()) > 0;
}
function makeSatisfiesExpression(left: Expression, right: TypeNode): SatisfiesExpression {
return finishNode(factory.createSatisfiesExpression(left, right), left.pos);
}
function makeBinaryExpression(left: Expression, operatorToken: BinaryOperatorToken, right: Expression, pos: number): BinaryExpression {
return finishNode(factory.createBinaryExpression(left, operatorToken, right), pos);
}
+3
View File
@@ -2372,6 +2372,9 @@ namespace ts {
case SyntaxKind.AsExpression:
diagnostics.push(createDiagnosticForNode((node as AsExpression).type, Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
return "skip";
case SyntaxKind.SatisfiesExpression:
diagnostics.push(createDiagnosticForNode((node as SatisfiesExpression).type, Diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files));
return "skip";
case SyntaxKind.TypeAssertionExpression:
Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX.
}
+1
View File
@@ -136,6 +136,7 @@ namespace ts {
require: SyntaxKind.RequireKeyword,
global: SyntaxKind.GlobalKeyword,
return: SyntaxKind.ReturnKeyword,
satisfies: SyntaxKind.SatisfiesKeyword,
set: SyntaxKind.SetKeyword,
static: SyntaxKind.StaticKeyword,
string: SyntaxKind.StringKeyword,
+8
View File
@@ -529,6 +529,9 @@ namespace ts {
// TypeScript type assertions are removed, but their subtrees are preserved.
return visitAssertionExpression(node as AssertionExpression);
case SyntaxKind.SatisfiesExpression:
return visitSatisfiesExpression(node as SatisfiesExpression);
case SyntaxKind.CallExpression:
return visitCallExpression(node as CallExpression);
@@ -1421,6 +1424,11 @@ namespace ts {
return factory.createPartiallyEmittedExpression(expression, node);
}
function visitSatisfiesExpression(node: SatisfiesExpression): Expression {
const expression = visitNode(node.expression, visitor, isExpression);
return factory.createPartiallyEmittedExpression(expression, node);
}
function visitCallExpression(node: CallExpression) {
return factory.updateCallExpression(
node,
+13
View File
@@ -181,6 +181,7 @@ namespace ts {
RequireKeyword,
NumberKeyword,
ObjectKeyword,
SatisfiesKeyword,
SetKeyword,
StringKeyword,
SymbolKeyword,
@@ -274,6 +275,7 @@ namespace ts {
NonNullExpression,
MetaProperty,
SyntheticExpression,
SatisfiesExpression,
// Misc
TemplateSpan,
@@ -607,6 +609,7 @@ namespace ts {
| SyntaxKind.OverrideKeyword
| SyntaxKind.RequireKeyword
| SyntaxKind.ReturnKeyword
| SyntaxKind.SatisfiesKeyword
| SyntaxKind.SetKeyword
| SyntaxKind.StaticKeyword
| SyntaxKind.StringKeyword
@@ -1007,6 +1010,7 @@ namespace ts {
| ExpressionWithTypeArguments
| AsExpression
| NonNullExpression
| SatisfiesExpression
| MetaProperty
| TemplateSpan
| Block
@@ -2815,6 +2819,12 @@ namespace ts {
readonly expression: UnaryExpression;
}
export interface SatisfiesExpression extends Expression {
readonly kind: SyntaxKind.SatisfiesExpression;
readonly expression: Expression;
readonly type: TypeNode;
}
export type AssertionExpression =
| TypeAssertion
| AsExpression
@@ -7520,6 +7530,7 @@ namespace ts {
export type OuterExpression =
| ParenthesizedExpression
| TypeAssertion
| SatisfiesExpression
| AsExpression
| NonNullExpression
| PartiallyEmittedExpression;
@@ -7856,6 +7867,8 @@ namespace ts {
updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain;
createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
createSatisfiesExpression(expression: Expression, type: TypeNode): SatisfiesExpression;
updateSatisfiesExpression(node: SatisfiesExpression, expression: Expression, type: TypeNode): SatisfiesExpression;
//
// Misc
+7 -1
View File
@@ -1995,6 +1995,7 @@ namespace ts {
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.SatisfiesExpression:
case SyntaxKind.NonNullExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.FunctionExpression:
@@ -2095,6 +2096,8 @@ namespace ts {
return (parent as ExpressionWithTypeArguments).expression === node && !isPartOfTypeNode(parent);
case SyntaxKind.ShorthandPropertyAssignment:
return (parent as ShorthandPropertyAssignment).objectAssignmentInitializer === node;
case SyntaxKind.SatisfiesExpression:
return node === (parent as SatisfiesExpression).expression;
default:
return isExpressionNode(parent);
}
@@ -3801,6 +3804,7 @@ namespace ts {
return OperatorPrecedence.Member;
case SyntaxKind.AsExpression:
case SyntaxKind.SatisfiesExpression:
return OperatorPrecedence.Relational;
case SyntaxKind.ThisKeyword:
@@ -3859,6 +3863,7 @@ namespace ts {
case SyntaxKind.InstanceOfKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.AsKeyword:
case SyntaxKind.SatisfiesKeyword:
return OperatorPrecedence.Relational;
case SyntaxKind.LessThanLessThanToken:
case SyntaxKind.GreaterThanGreaterThanToken:
@@ -5930,7 +5935,8 @@ namespace ts {
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.NonNullExpression:
case SyntaxKind.PartiallyEmittedExpression:
node = (node as CallExpression | PropertyAccessExpression | ElementAccessExpression | AsExpression | NonNullExpression | PartiallyEmittedExpression).expression;
case SyntaxKind.SatisfiesExpression:
node = (node as CallExpression | PropertyAccessExpression | ElementAccessExpression | AsExpression | NonNullExpression | PartiallyEmittedExpression | SatisfiesExpression).expression;
continue;
}
+1
View File
@@ -1642,6 +1642,7 @@ namespace ts {
case SyntaxKind.OmittedExpression:
case SyntaxKind.CommaListExpression:
case SyntaxKind.PartiallyEmittedExpression:
case SyntaxKind.SatisfiesExpression:
return true;
default:
return isUnaryExpressionKind(kind);
+7 -1
View File
@@ -888,13 +888,19 @@ namespace ts {
nodeVisitor(node.type, visitor, isTypeNode));
},
[SyntaxKind.SatisfiesExpression]: function visitEachChildOfSatisfiesExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
return context.factory.updateSatisfiesExpression(node,
nodeVisitor(node.expression, visitor, isExpression),
nodeVisitor(node.type, visitor, isTypeNode));
},
[SyntaxKind.NonNullExpression]: function visitEachChildOfNonNullExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
return isOptionalChain(node) ?
context.factory.updateNonNullChain(node,
nodeVisitor(node.expression, visitor, isExpression)) :
context.factory.updateNonNullExpression(node,
nodeVisitor(node.expression, visitor, isExpression));
},
},
[SyntaxKind.MetaProperty]: function visitEachChildOfMetaProperty(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
return context.factory.updateMetaProperty(node,
+4
View File
@@ -1388,6 +1388,7 @@ namespace FourSlashInterface {
"package",
"readonly",
"return",
"satisfies",
"string",
"super",
"switch",
@@ -1503,6 +1504,7 @@ namespace FourSlashInterface {
"null",
"package",
"return",
"satisfies",
"super",
"switch",
"this",
@@ -1601,6 +1603,7 @@ namespace FourSlashInterface {
"package",
"readonly",
"return",
"satisfies",
"string",
"super",
"switch",
@@ -1655,6 +1658,7 @@ namespace FourSlashInterface {
"null",
"package",
"return",
"satisfies",
"super",
"switch",
"this",
+4
View File
@@ -449,6 +449,10 @@ namespace ts.CallHierarchy {
recordCallSite(node as AccessExpression);
forEachChild(node, collect);
break;
case SyntaxKind.SatisfiesExpression:
// do not descend into the type side of an assertion
collect((node as SatisfiesExpression).expression);
return;
}
if (isPartOfTypeNode(node)) {
+1
View File
@@ -369,6 +369,7 @@ namespace ts {
case SyntaxKind.InstanceOfKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.AsKeyword:
case SyntaxKind.SatisfiesKeyword:
case SyntaxKind.EqualsEqualsToken:
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
+4
View File
@@ -2675,6 +2675,9 @@ namespace ts.Completions {
case SyntaxKind.ExtendsKeyword:
return parentKind === SyntaxKind.TypeParameter;
case SyntaxKind.SatisfiesKeyword:
return parentKind === SyntaxKind.SatisfiesExpression;
}
}
return false;
@@ -3962,6 +3965,7 @@ namespace ts.Completions {
return kind === SyntaxKind.AsyncKeyword
|| kind === SyntaxKind.AwaitKeyword
|| kind === SyntaxKind.AsKeyword
|| kind === SyntaxKind.SatisfiesKeyword
|| kind === SyntaxKind.TypeKeyword
|| !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
}
+1
View File
@@ -449,6 +449,7 @@ namespace ts.formatting {
case SyntaxKind.TypePredicate:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
case SyntaxKind.SatisfiesExpression:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
+2
View File
@@ -143,6 +143,8 @@ namespace Harness {
"exactOptionalPropertyTypes",
"useDefineForClassFields",
"useUnknownInCatchVariables",
"noUncheckedIndexedAccess",
"noPropertyAccessFromIndexSignature",
];
private fileName: string;
private justName: string;
+230 -220
View File
@@ -254,215 +254,217 @@ declare namespace ts {
RequireKeyword = 146,
NumberKeyword = 147,
ObjectKeyword = 148,
SetKeyword = 149,
StringKeyword = 150,
SymbolKeyword = 151,
TypeKeyword = 152,
UndefinedKeyword = 153,
UniqueKeyword = 154,
UnknownKeyword = 155,
FromKeyword = 156,
GlobalKeyword = 157,
BigIntKeyword = 158,
OverrideKeyword = 159,
OfKeyword = 160,
QualifiedName = 161,
ComputedPropertyName = 162,
TypeParameter = 163,
Parameter = 164,
Decorator = 165,
PropertySignature = 166,
PropertyDeclaration = 167,
MethodSignature = 168,
MethodDeclaration = 169,
ClassStaticBlockDeclaration = 170,
Constructor = 171,
GetAccessor = 172,
SetAccessor = 173,
CallSignature = 174,
ConstructSignature = 175,
IndexSignature = 176,
TypePredicate = 177,
TypeReference = 178,
FunctionType = 179,
ConstructorType = 180,
TypeQuery = 181,
TypeLiteral = 182,
ArrayType = 183,
TupleType = 184,
OptionalType = 185,
RestType = 186,
UnionType = 187,
IntersectionType = 188,
ConditionalType = 189,
InferType = 190,
ParenthesizedType = 191,
ThisType = 192,
TypeOperator = 193,
IndexedAccessType = 194,
MappedType = 195,
LiteralType = 196,
NamedTupleMember = 197,
TemplateLiteralType = 198,
TemplateLiteralTypeSpan = 199,
ImportType = 200,
ObjectBindingPattern = 201,
ArrayBindingPattern = 202,
BindingElement = 203,
ArrayLiteralExpression = 204,
ObjectLiteralExpression = 205,
PropertyAccessExpression = 206,
ElementAccessExpression = 207,
CallExpression = 208,
NewExpression = 209,
TaggedTemplateExpression = 210,
TypeAssertionExpression = 211,
ParenthesizedExpression = 212,
FunctionExpression = 213,
ArrowFunction = 214,
DeleteExpression = 215,
TypeOfExpression = 216,
VoidExpression = 217,
AwaitExpression = 218,
PrefixUnaryExpression = 219,
PostfixUnaryExpression = 220,
BinaryExpression = 221,
ConditionalExpression = 222,
TemplateExpression = 223,
YieldExpression = 224,
SpreadElement = 225,
ClassExpression = 226,
OmittedExpression = 227,
ExpressionWithTypeArguments = 228,
AsExpression = 229,
NonNullExpression = 230,
MetaProperty = 231,
SyntheticExpression = 232,
TemplateSpan = 233,
SemicolonClassElement = 234,
Block = 235,
EmptyStatement = 236,
VariableStatement = 237,
ExpressionStatement = 238,
IfStatement = 239,
DoStatement = 240,
WhileStatement = 241,
ForStatement = 242,
ForInStatement = 243,
ForOfStatement = 244,
ContinueStatement = 245,
BreakStatement = 246,
ReturnStatement = 247,
WithStatement = 248,
SwitchStatement = 249,
LabeledStatement = 250,
ThrowStatement = 251,
TryStatement = 252,
DebuggerStatement = 253,
VariableDeclaration = 254,
VariableDeclarationList = 255,
FunctionDeclaration = 256,
ClassDeclaration = 257,
InterfaceDeclaration = 258,
TypeAliasDeclaration = 259,
EnumDeclaration = 260,
ModuleDeclaration = 261,
ModuleBlock = 262,
CaseBlock = 263,
NamespaceExportDeclaration = 264,
ImportEqualsDeclaration = 265,
ImportDeclaration = 266,
ImportClause = 267,
NamespaceImport = 268,
NamedImports = 269,
ImportSpecifier = 270,
ExportAssignment = 271,
ExportDeclaration = 272,
NamedExports = 273,
NamespaceExport = 274,
ExportSpecifier = 275,
MissingDeclaration = 276,
ExternalModuleReference = 277,
JsxElement = 278,
JsxSelfClosingElement = 279,
JsxOpeningElement = 280,
JsxClosingElement = 281,
JsxFragment = 282,
JsxOpeningFragment = 283,
JsxClosingFragment = 284,
JsxAttribute = 285,
JsxAttributes = 286,
JsxSpreadAttribute = 287,
JsxExpression = 288,
CaseClause = 289,
DefaultClause = 290,
HeritageClause = 291,
CatchClause = 292,
AssertClause = 293,
AssertEntry = 294,
ImportTypeAssertionContainer = 295,
PropertyAssignment = 296,
ShorthandPropertyAssignment = 297,
SpreadAssignment = 298,
EnumMember = 299,
UnparsedPrologue = 300,
UnparsedPrepend = 301,
UnparsedText = 302,
UnparsedInternalText = 303,
UnparsedSyntheticReference = 304,
SourceFile = 305,
Bundle = 306,
UnparsedSource = 307,
InputFiles = 308,
JSDocTypeExpression = 309,
JSDocNameReference = 310,
JSDocMemberName = 311,
JSDocAllType = 312,
JSDocUnknownType = 313,
JSDocNullableType = 314,
JSDocNonNullableType = 315,
JSDocOptionalType = 316,
JSDocFunctionType = 317,
JSDocVariadicType = 318,
JSDocNamepathType = 319,
JSDoc = 320,
SatisfiesKeyword = 149,
SetKeyword = 150,
StringKeyword = 151,
SymbolKeyword = 152,
TypeKeyword = 153,
UndefinedKeyword = 154,
UniqueKeyword = 155,
UnknownKeyword = 156,
FromKeyword = 157,
GlobalKeyword = 158,
BigIntKeyword = 159,
OverrideKeyword = 160,
OfKeyword = 161,
QualifiedName = 162,
ComputedPropertyName = 163,
TypeParameter = 164,
Parameter = 165,
Decorator = 166,
PropertySignature = 167,
PropertyDeclaration = 168,
MethodSignature = 169,
MethodDeclaration = 170,
ClassStaticBlockDeclaration = 171,
Constructor = 172,
GetAccessor = 173,
SetAccessor = 174,
CallSignature = 175,
ConstructSignature = 176,
IndexSignature = 177,
TypePredicate = 178,
TypeReference = 179,
FunctionType = 180,
ConstructorType = 181,
TypeQuery = 182,
TypeLiteral = 183,
ArrayType = 184,
TupleType = 185,
OptionalType = 186,
RestType = 187,
UnionType = 188,
IntersectionType = 189,
ConditionalType = 190,
InferType = 191,
ParenthesizedType = 192,
ThisType = 193,
TypeOperator = 194,
IndexedAccessType = 195,
MappedType = 196,
LiteralType = 197,
NamedTupleMember = 198,
TemplateLiteralType = 199,
TemplateLiteralTypeSpan = 200,
ImportType = 201,
ObjectBindingPattern = 202,
ArrayBindingPattern = 203,
BindingElement = 204,
ArrayLiteralExpression = 205,
ObjectLiteralExpression = 206,
PropertyAccessExpression = 207,
ElementAccessExpression = 208,
CallExpression = 209,
NewExpression = 210,
TaggedTemplateExpression = 211,
TypeAssertionExpression = 212,
ParenthesizedExpression = 213,
FunctionExpression = 214,
ArrowFunction = 215,
DeleteExpression = 216,
TypeOfExpression = 217,
VoidExpression = 218,
AwaitExpression = 219,
PrefixUnaryExpression = 220,
PostfixUnaryExpression = 221,
BinaryExpression = 222,
ConditionalExpression = 223,
TemplateExpression = 224,
YieldExpression = 225,
SpreadElement = 226,
ClassExpression = 227,
OmittedExpression = 228,
ExpressionWithTypeArguments = 229,
AsExpression = 230,
NonNullExpression = 231,
MetaProperty = 232,
SyntheticExpression = 233,
SatisfiesExpression = 234,
TemplateSpan = 235,
SemicolonClassElement = 236,
Block = 237,
EmptyStatement = 238,
VariableStatement = 239,
ExpressionStatement = 240,
IfStatement = 241,
DoStatement = 242,
WhileStatement = 243,
ForStatement = 244,
ForInStatement = 245,
ForOfStatement = 246,
ContinueStatement = 247,
BreakStatement = 248,
ReturnStatement = 249,
WithStatement = 250,
SwitchStatement = 251,
LabeledStatement = 252,
ThrowStatement = 253,
TryStatement = 254,
DebuggerStatement = 255,
VariableDeclaration = 256,
VariableDeclarationList = 257,
FunctionDeclaration = 258,
ClassDeclaration = 259,
InterfaceDeclaration = 260,
TypeAliasDeclaration = 261,
EnumDeclaration = 262,
ModuleDeclaration = 263,
ModuleBlock = 264,
CaseBlock = 265,
NamespaceExportDeclaration = 266,
ImportEqualsDeclaration = 267,
ImportDeclaration = 268,
ImportClause = 269,
NamespaceImport = 270,
NamedImports = 271,
ImportSpecifier = 272,
ExportAssignment = 273,
ExportDeclaration = 274,
NamedExports = 275,
NamespaceExport = 276,
ExportSpecifier = 277,
MissingDeclaration = 278,
ExternalModuleReference = 279,
JsxElement = 280,
JsxSelfClosingElement = 281,
JsxOpeningElement = 282,
JsxClosingElement = 283,
JsxFragment = 284,
JsxOpeningFragment = 285,
JsxClosingFragment = 286,
JsxAttribute = 287,
JsxAttributes = 288,
JsxSpreadAttribute = 289,
JsxExpression = 290,
CaseClause = 291,
DefaultClause = 292,
HeritageClause = 293,
CatchClause = 294,
AssertClause = 295,
AssertEntry = 296,
ImportTypeAssertionContainer = 297,
PropertyAssignment = 298,
ShorthandPropertyAssignment = 299,
SpreadAssignment = 300,
EnumMember = 301,
UnparsedPrologue = 302,
UnparsedPrepend = 303,
UnparsedText = 304,
UnparsedInternalText = 305,
UnparsedSyntheticReference = 306,
SourceFile = 307,
Bundle = 308,
UnparsedSource = 309,
InputFiles = 310,
JSDocTypeExpression = 311,
JSDocNameReference = 312,
JSDocMemberName = 313,
JSDocAllType = 314,
JSDocUnknownType = 315,
JSDocNullableType = 316,
JSDocNonNullableType = 317,
JSDocOptionalType = 318,
JSDocFunctionType = 319,
JSDocVariadicType = 320,
JSDocNamepathType = 321,
JSDoc = 322,
/** @deprecated Use SyntaxKind.JSDoc */
JSDocComment = 320,
JSDocText = 321,
JSDocTypeLiteral = 322,
JSDocSignature = 323,
JSDocLink = 324,
JSDocLinkCode = 325,
JSDocLinkPlain = 326,
JSDocTag = 327,
JSDocAugmentsTag = 328,
JSDocImplementsTag = 329,
JSDocAuthorTag = 330,
JSDocDeprecatedTag = 331,
JSDocClassTag = 332,
JSDocPublicTag = 333,
JSDocPrivateTag = 334,
JSDocProtectedTag = 335,
JSDocReadonlyTag = 336,
JSDocOverrideTag = 337,
JSDocCallbackTag = 338,
JSDocEnumTag = 339,
JSDocParameterTag = 340,
JSDocReturnTag = 341,
JSDocThisTag = 342,
JSDocTypeTag = 343,
JSDocTemplateTag = 344,
JSDocTypedefTag = 345,
JSDocSeeTag = 346,
JSDocPropertyTag = 347,
SyntaxList = 348,
NotEmittedStatement = 349,
PartiallyEmittedExpression = 350,
CommaListExpression = 351,
MergeDeclarationMarker = 352,
EndOfDeclarationMarker = 353,
SyntheticReferenceExpression = 354,
Count = 355,
JSDocComment = 322,
JSDocText = 323,
JSDocTypeLiteral = 324,
JSDocSignature = 325,
JSDocLink = 326,
JSDocLinkCode = 327,
JSDocLinkPlain = 328,
JSDocTag = 329,
JSDocAugmentsTag = 330,
JSDocImplementsTag = 331,
JSDocAuthorTag = 332,
JSDocDeprecatedTag = 333,
JSDocClassTag = 334,
JSDocPublicTag = 335,
JSDocPrivateTag = 336,
JSDocProtectedTag = 337,
JSDocReadonlyTag = 338,
JSDocOverrideTag = 339,
JSDocCallbackTag = 340,
JSDocEnumTag = 341,
JSDocParameterTag = 342,
JSDocReturnTag = 343,
JSDocThisTag = 344,
JSDocTypeTag = 345,
JSDocTemplateTag = 346,
JSDocTypedefTag = 347,
JSDocSeeTag = 348,
JSDocPropertyTag = 349,
SyntaxList = 350,
NotEmittedStatement = 351,
PartiallyEmittedExpression = 352,
CommaListExpression = 353,
MergeDeclarationMarker = 354,
EndOfDeclarationMarker = 355,
SyntheticReferenceExpression = 356,
Count = 357,
FirstAssignment = 63,
LastAssignment = 78,
FirstCompoundAssignment = 64,
@@ -470,15 +472,15 @@ declare namespace ts {
FirstReservedWord = 81,
LastReservedWord = 116,
FirstKeyword = 81,
LastKeyword = 160,
LastKeyword = 161,
FirstFutureReservedWord = 117,
LastFutureReservedWord = 125,
FirstTypeNode = 177,
LastTypeNode = 200,
FirstTypeNode = 178,
LastTypeNode = 201,
FirstPunctuation = 18,
LastPunctuation = 78,
FirstToken = 0,
LastToken = 160,
LastToken = 161,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -487,19 +489,19 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 78,
FirstStatement = 237,
LastStatement = 253,
FirstNode = 161,
FirstJSDocNode = 309,
LastJSDocNode = 347,
FirstJSDocTagNode = 327,
LastJSDocTagNode = 347,
FirstStatement = 239,
LastStatement = 255,
FirstNode = 162,
FirstJSDocNode = 311,
LastJSDocNode = 349,
FirstJSDocTagNode = 329,
LastJSDocTagNode = 349,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
@@ -1340,6 +1342,11 @@ declare namespace ts {
readonly type: TypeNode;
readonly expression: UnaryExpression;
}
export interface SatisfiesExpression extends Expression {
readonly kind: SyntaxKind.SatisfiesExpression;
readonly expression: Expression;
readonly type: TypeNode;
}
export type AssertionExpression = TypeAssertion | AsExpression;
export interface NonNullExpression extends LeftHandSideExpression {
readonly kind: SyntaxKind.NonNullExpression;
@@ -3588,6 +3595,8 @@ declare namespace ts {
updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain;
createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
createSatisfiesExpression(expression: Expression, type: TypeNode): SatisfiesExpression;
updateSatisfiesExpression(node: SatisfiesExpression, expression: Expression, type: TypeNode): SatisfiesExpression;
createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
createSemicolonClassElement(): SemicolonClassElement;
@@ -4717,6 +4726,7 @@ declare namespace ts {
function isOmittedExpression(node: Node): node is OmittedExpression;
function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments;
function isAsExpression(node: Node): node is AsExpression;
function isSatisfiesExpression(node: Node): node is SatisfiesExpression;
function isNonNullExpression(node: Node): node is NonNullExpression;
function isMetaProperty(node: Node): node is MetaProperty;
function isSyntheticExpression(node: Node): node is SyntheticExpression;
+230 -220
View File
@@ -254,215 +254,217 @@ declare namespace ts {
RequireKeyword = 146,
NumberKeyword = 147,
ObjectKeyword = 148,
SetKeyword = 149,
StringKeyword = 150,
SymbolKeyword = 151,
TypeKeyword = 152,
UndefinedKeyword = 153,
UniqueKeyword = 154,
UnknownKeyword = 155,
FromKeyword = 156,
GlobalKeyword = 157,
BigIntKeyword = 158,
OverrideKeyword = 159,
OfKeyword = 160,
QualifiedName = 161,
ComputedPropertyName = 162,
TypeParameter = 163,
Parameter = 164,
Decorator = 165,
PropertySignature = 166,
PropertyDeclaration = 167,
MethodSignature = 168,
MethodDeclaration = 169,
ClassStaticBlockDeclaration = 170,
Constructor = 171,
GetAccessor = 172,
SetAccessor = 173,
CallSignature = 174,
ConstructSignature = 175,
IndexSignature = 176,
TypePredicate = 177,
TypeReference = 178,
FunctionType = 179,
ConstructorType = 180,
TypeQuery = 181,
TypeLiteral = 182,
ArrayType = 183,
TupleType = 184,
OptionalType = 185,
RestType = 186,
UnionType = 187,
IntersectionType = 188,
ConditionalType = 189,
InferType = 190,
ParenthesizedType = 191,
ThisType = 192,
TypeOperator = 193,
IndexedAccessType = 194,
MappedType = 195,
LiteralType = 196,
NamedTupleMember = 197,
TemplateLiteralType = 198,
TemplateLiteralTypeSpan = 199,
ImportType = 200,
ObjectBindingPattern = 201,
ArrayBindingPattern = 202,
BindingElement = 203,
ArrayLiteralExpression = 204,
ObjectLiteralExpression = 205,
PropertyAccessExpression = 206,
ElementAccessExpression = 207,
CallExpression = 208,
NewExpression = 209,
TaggedTemplateExpression = 210,
TypeAssertionExpression = 211,
ParenthesizedExpression = 212,
FunctionExpression = 213,
ArrowFunction = 214,
DeleteExpression = 215,
TypeOfExpression = 216,
VoidExpression = 217,
AwaitExpression = 218,
PrefixUnaryExpression = 219,
PostfixUnaryExpression = 220,
BinaryExpression = 221,
ConditionalExpression = 222,
TemplateExpression = 223,
YieldExpression = 224,
SpreadElement = 225,
ClassExpression = 226,
OmittedExpression = 227,
ExpressionWithTypeArguments = 228,
AsExpression = 229,
NonNullExpression = 230,
MetaProperty = 231,
SyntheticExpression = 232,
TemplateSpan = 233,
SemicolonClassElement = 234,
Block = 235,
EmptyStatement = 236,
VariableStatement = 237,
ExpressionStatement = 238,
IfStatement = 239,
DoStatement = 240,
WhileStatement = 241,
ForStatement = 242,
ForInStatement = 243,
ForOfStatement = 244,
ContinueStatement = 245,
BreakStatement = 246,
ReturnStatement = 247,
WithStatement = 248,
SwitchStatement = 249,
LabeledStatement = 250,
ThrowStatement = 251,
TryStatement = 252,
DebuggerStatement = 253,
VariableDeclaration = 254,
VariableDeclarationList = 255,
FunctionDeclaration = 256,
ClassDeclaration = 257,
InterfaceDeclaration = 258,
TypeAliasDeclaration = 259,
EnumDeclaration = 260,
ModuleDeclaration = 261,
ModuleBlock = 262,
CaseBlock = 263,
NamespaceExportDeclaration = 264,
ImportEqualsDeclaration = 265,
ImportDeclaration = 266,
ImportClause = 267,
NamespaceImport = 268,
NamedImports = 269,
ImportSpecifier = 270,
ExportAssignment = 271,
ExportDeclaration = 272,
NamedExports = 273,
NamespaceExport = 274,
ExportSpecifier = 275,
MissingDeclaration = 276,
ExternalModuleReference = 277,
JsxElement = 278,
JsxSelfClosingElement = 279,
JsxOpeningElement = 280,
JsxClosingElement = 281,
JsxFragment = 282,
JsxOpeningFragment = 283,
JsxClosingFragment = 284,
JsxAttribute = 285,
JsxAttributes = 286,
JsxSpreadAttribute = 287,
JsxExpression = 288,
CaseClause = 289,
DefaultClause = 290,
HeritageClause = 291,
CatchClause = 292,
AssertClause = 293,
AssertEntry = 294,
ImportTypeAssertionContainer = 295,
PropertyAssignment = 296,
ShorthandPropertyAssignment = 297,
SpreadAssignment = 298,
EnumMember = 299,
UnparsedPrologue = 300,
UnparsedPrepend = 301,
UnparsedText = 302,
UnparsedInternalText = 303,
UnparsedSyntheticReference = 304,
SourceFile = 305,
Bundle = 306,
UnparsedSource = 307,
InputFiles = 308,
JSDocTypeExpression = 309,
JSDocNameReference = 310,
JSDocMemberName = 311,
JSDocAllType = 312,
JSDocUnknownType = 313,
JSDocNullableType = 314,
JSDocNonNullableType = 315,
JSDocOptionalType = 316,
JSDocFunctionType = 317,
JSDocVariadicType = 318,
JSDocNamepathType = 319,
JSDoc = 320,
SatisfiesKeyword = 149,
SetKeyword = 150,
StringKeyword = 151,
SymbolKeyword = 152,
TypeKeyword = 153,
UndefinedKeyword = 154,
UniqueKeyword = 155,
UnknownKeyword = 156,
FromKeyword = 157,
GlobalKeyword = 158,
BigIntKeyword = 159,
OverrideKeyword = 160,
OfKeyword = 161,
QualifiedName = 162,
ComputedPropertyName = 163,
TypeParameter = 164,
Parameter = 165,
Decorator = 166,
PropertySignature = 167,
PropertyDeclaration = 168,
MethodSignature = 169,
MethodDeclaration = 170,
ClassStaticBlockDeclaration = 171,
Constructor = 172,
GetAccessor = 173,
SetAccessor = 174,
CallSignature = 175,
ConstructSignature = 176,
IndexSignature = 177,
TypePredicate = 178,
TypeReference = 179,
FunctionType = 180,
ConstructorType = 181,
TypeQuery = 182,
TypeLiteral = 183,
ArrayType = 184,
TupleType = 185,
OptionalType = 186,
RestType = 187,
UnionType = 188,
IntersectionType = 189,
ConditionalType = 190,
InferType = 191,
ParenthesizedType = 192,
ThisType = 193,
TypeOperator = 194,
IndexedAccessType = 195,
MappedType = 196,
LiteralType = 197,
NamedTupleMember = 198,
TemplateLiteralType = 199,
TemplateLiteralTypeSpan = 200,
ImportType = 201,
ObjectBindingPattern = 202,
ArrayBindingPattern = 203,
BindingElement = 204,
ArrayLiteralExpression = 205,
ObjectLiteralExpression = 206,
PropertyAccessExpression = 207,
ElementAccessExpression = 208,
CallExpression = 209,
NewExpression = 210,
TaggedTemplateExpression = 211,
TypeAssertionExpression = 212,
ParenthesizedExpression = 213,
FunctionExpression = 214,
ArrowFunction = 215,
DeleteExpression = 216,
TypeOfExpression = 217,
VoidExpression = 218,
AwaitExpression = 219,
PrefixUnaryExpression = 220,
PostfixUnaryExpression = 221,
BinaryExpression = 222,
ConditionalExpression = 223,
TemplateExpression = 224,
YieldExpression = 225,
SpreadElement = 226,
ClassExpression = 227,
OmittedExpression = 228,
ExpressionWithTypeArguments = 229,
AsExpression = 230,
NonNullExpression = 231,
MetaProperty = 232,
SyntheticExpression = 233,
SatisfiesExpression = 234,
TemplateSpan = 235,
SemicolonClassElement = 236,
Block = 237,
EmptyStatement = 238,
VariableStatement = 239,
ExpressionStatement = 240,
IfStatement = 241,
DoStatement = 242,
WhileStatement = 243,
ForStatement = 244,
ForInStatement = 245,
ForOfStatement = 246,
ContinueStatement = 247,
BreakStatement = 248,
ReturnStatement = 249,
WithStatement = 250,
SwitchStatement = 251,
LabeledStatement = 252,
ThrowStatement = 253,
TryStatement = 254,
DebuggerStatement = 255,
VariableDeclaration = 256,
VariableDeclarationList = 257,
FunctionDeclaration = 258,
ClassDeclaration = 259,
InterfaceDeclaration = 260,
TypeAliasDeclaration = 261,
EnumDeclaration = 262,
ModuleDeclaration = 263,
ModuleBlock = 264,
CaseBlock = 265,
NamespaceExportDeclaration = 266,
ImportEqualsDeclaration = 267,
ImportDeclaration = 268,
ImportClause = 269,
NamespaceImport = 270,
NamedImports = 271,
ImportSpecifier = 272,
ExportAssignment = 273,
ExportDeclaration = 274,
NamedExports = 275,
NamespaceExport = 276,
ExportSpecifier = 277,
MissingDeclaration = 278,
ExternalModuleReference = 279,
JsxElement = 280,
JsxSelfClosingElement = 281,
JsxOpeningElement = 282,
JsxClosingElement = 283,
JsxFragment = 284,
JsxOpeningFragment = 285,
JsxClosingFragment = 286,
JsxAttribute = 287,
JsxAttributes = 288,
JsxSpreadAttribute = 289,
JsxExpression = 290,
CaseClause = 291,
DefaultClause = 292,
HeritageClause = 293,
CatchClause = 294,
AssertClause = 295,
AssertEntry = 296,
ImportTypeAssertionContainer = 297,
PropertyAssignment = 298,
ShorthandPropertyAssignment = 299,
SpreadAssignment = 300,
EnumMember = 301,
UnparsedPrologue = 302,
UnparsedPrepend = 303,
UnparsedText = 304,
UnparsedInternalText = 305,
UnparsedSyntheticReference = 306,
SourceFile = 307,
Bundle = 308,
UnparsedSource = 309,
InputFiles = 310,
JSDocTypeExpression = 311,
JSDocNameReference = 312,
JSDocMemberName = 313,
JSDocAllType = 314,
JSDocUnknownType = 315,
JSDocNullableType = 316,
JSDocNonNullableType = 317,
JSDocOptionalType = 318,
JSDocFunctionType = 319,
JSDocVariadicType = 320,
JSDocNamepathType = 321,
JSDoc = 322,
/** @deprecated Use SyntaxKind.JSDoc */
JSDocComment = 320,
JSDocText = 321,
JSDocTypeLiteral = 322,
JSDocSignature = 323,
JSDocLink = 324,
JSDocLinkCode = 325,
JSDocLinkPlain = 326,
JSDocTag = 327,
JSDocAugmentsTag = 328,
JSDocImplementsTag = 329,
JSDocAuthorTag = 330,
JSDocDeprecatedTag = 331,
JSDocClassTag = 332,
JSDocPublicTag = 333,
JSDocPrivateTag = 334,
JSDocProtectedTag = 335,
JSDocReadonlyTag = 336,
JSDocOverrideTag = 337,
JSDocCallbackTag = 338,
JSDocEnumTag = 339,
JSDocParameterTag = 340,
JSDocReturnTag = 341,
JSDocThisTag = 342,
JSDocTypeTag = 343,
JSDocTemplateTag = 344,
JSDocTypedefTag = 345,
JSDocSeeTag = 346,
JSDocPropertyTag = 347,
SyntaxList = 348,
NotEmittedStatement = 349,
PartiallyEmittedExpression = 350,
CommaListExpression = 351,
MergeDeclarationMarker = 352,
EndOfDeclarationMarker = 353,
SyntheticReferenceExpression = 354,
Count = 355,
JSDocComment = 322,
JSDocText = 323,
JSDocTypeLiteral = 324,
JSDocSignature = 325,
JSDocLink = 326,
JSDocLinkCode = 327,
JSDocLinkPlain = 328,
JSDocTag = 329,
JSDocAugmentsTag = 330,
JSDocImplementsTag = 331,
JSDocAuthorTag = 332,
JSDocDeprecatedTag = 333,
JSDocClassTag = 334,
JSDocPublicTag = 335,
JSDocPrivateTag = 336,
JSDocProtectedTag = 337,
JSDocReadonlyTag = 338,
JSDocOverrideTag = 339,
JSDocCallbackTag = 340,
JSDocEnumTag = 341,
JSDocParameterTag = 342,
JSDocReturnTag = 343,
JSDocThisTag = 344,
JSDocTypeTag = 345,
JSDocTemplateTag = 346,
JSDocTypedefTag = 347,
JSDocSeeTag = 348,
JSDocPropertyTag = 349,
SyntaxList = 350,
NotEmittedStatement = 351,
PartiallyEmittedExpression = 352,
CommaListExpression = 353,
MergeDeclarationMarker = 354,
EndOfDeclarationMarker = 355,
SyntheticReferenceExpression = 356,
Count = 357,
FirstAssignment = 63,
LastAssignment = 78,
FirstCompoundAssignment = 64,
@@ -470,15 +472,15 @@ declare namespace ts {
FirstReservedWord = 81,
LastReservedWord = 116,
FirstKeyword = 81,
LastKeyword = 160,
LastKeyword = 161,
FirstFutureReservedWord = 117,
LastFutureReservedWord = 125,
FirstTypeNode = 177,
LastTypeNode = 200,
FirstTypeNode = 178,
LastTypeNode = 201,
FirstPunctuation = 18,
LastPunctuation = 78,
FirstToken = 0,
LastToken = 160,
LastToken = 161,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -487,19 +489,19 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 78,
FirstStatement = 237,
LastStatement = 253,
FirstNode = 161,
FirstJSDocNode = 309,
LastJSDocNode = 347,
FirstJSDocTagNode = 327,
LastJSDocTagNode = 347,
FirstStatement = 239,
LastStatement = 255,
FirstNode = 162,
FirstJSDocNode = 311,
LastJSDocNode = 349,
FirstJSDocTagNode = 329,
LastJSDocTagNode = 349,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
@@ -1340,6 +1342,11 @@ declare namespace ts {
readonly type: TypeNode;
readonly expression: UnaryExpression;
}
export interface SatisfiesExpression extends Expression {
readonly kind: SyntaxKind.SatisfiesExpression;
readonly expression: Expression;
readonly type: TypeNode;
}
export type AssertionExpression = TypeAssertion | AsExpression;
export interface NonNullExpression extends LeftHandSideExpression {
readonly kind: SyntaxKind.NonNullExpression;
@@ -3588,6 +3595,8 @@ declare namespace ts {
updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain;
createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
createSatisfiesExpression(expression: Expression, type: TypeNode): SatisfiesExpression;
updateSatisfiesExpression(node: SatisfiesExpression, expression: Expression, type: TypeNode): SatisfiesExpression;
createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
createSemicolonClassElement(): SemicolonClassElement;
@@ -4717,6 +4726,7 @@ declare namespace ts {
function isOmittedExpression(node: Node): node is OmittedExpression;
function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments;
function isAsExpression(node: Node): node is AsExpression;
function isSatisfiesExpression(node: Node): node is SatisfiesExpression;
function isNonNullExpression(node: Node): node is NonNullExpression;
function isMetaProperty(node: Node): node is MetaProperty;
function isSyntheticExpression(node: Node): node is SyntheticExpression;
@@ -3115,6 +3115,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -4048,6 +4048,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -11121,6 +11133,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -15947,6 +15971,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -23020,6 +23056,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -27097,6 +27145,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -32330,6 +32390,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -36361,6 +36433,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -41548,6 +41632,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -46781,6 +46877,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -52014,6 +52122,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -57247,6 +57367,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -61319,6 +61451,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -65391,6 +65535,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -69463,6 +69619,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -73535,6 +73703,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -77607,6 +77787,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -81679,6 +81871,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -86188,6 +86392,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -91546,6 +91762,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -96064,6 +96292,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -4882,6 +4882,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -11062,6 +11074,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -16974,6 +16998,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -22627,6 +22663,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -28430,6 +28478,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -34610,6 +34670,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -40539,6 +40611,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -3269,6 +3269,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -7034,6 +7046,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -11081,6 +11105,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -3022,6 +3022,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -7469,6 +7481,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "string",
"kind": "keyword",
@@ -11472,6 +11496,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -15703,6 +15739,18 @@
}
]
},
{
"name": "satisfies",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "satisfies",
"kind": "keyword"
}
]
},
{
"name": "String",
"kind": "var",
@@ -1,10 +1,10 @@
tests/cases/conformance/salsa/constructorNameInGenerator.ts(2,6): error TS1360: Class constructor may not be a generator.
tests/cases/conformance/salsa/constructorNameInGenerator.ts(2,6): error TS1368: Class constructor may not be a generator.
==== tests/cases/conformance/salsa/constructorNameInGenerator.ts (1 errors) ====
class C2 {
*constructor() {}
~~~~~~~~~~~
!!! error TS1360: Class constructor may not be a generator.
!!! error TS1368: Class constructor may not be a generator.
}
@@ -0,0 +1,44 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(12,20): error TS1360: Type '{ a: number; b: number; }' does not satisfy the expected type 'I1'.
Object literal may only specify known properties, and 'b' does not exist in type 'I1'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(13,26): error TS1360: Type '{}' does not satisfy the expected type 'I1'.
Property 'a' is missing in type '{}' but required in type 'I1'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(24,23): error TS1360: Type '{ a: string; b: string; }' does not satisfy the expected type 'A'.
Object literal may only specify known properties, and 'b' does not exist in type 'A'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts (3 errors) ====
interface I1 {
a: number;
}
type T1 = {
a: "a" | "b";
}
type T2 = (x: string) => void;
const t1 = { a: 1 } satisfies I1; // Ok
const t2 = { a: 1, b: 1 } satisfies I1; // Error
~~~~
!!! error TS1360: Type '{ a: number; b: number; }' does not satisfy the expected type 'I1'.
!!! error TS1360: Object literal may only specify known properties, and 'b' does not exist in type 'I1'.
const t3 = { } satisfies I1; // Error
~~
!!! error TS1360: Type '{}' does not satisfy the expected type 'I1'.
!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'I1'.
!!! related TS2728 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts:2:5: 'a' is declared here.
const t4: T1 = { a: "a" } satisfies T1; // Ok
const t5 = (m => m.substring(0)) satisfies T2; // Ok
const t6 = [1, 2] satisfies [number, number];
interface A {
a: string
}
let t7 = { a: 'test' } satisfies A;
let t8 = { a: 'test', b: 'test' } satisfies A;
~~~~~~~~~
!!! error TS1360: Type '{ a: string; b: string; }' does not satisfy the expected type 'A'.
!!! error TS1360: Object literal may only specify known properties, and 'b' does not exist in type 'A'.
@@ -0,0 +1,36 @@
//// [typeSatisfaction.ts]
interface I1 {
a: number;
}
type T1 = {
a: "a" | "b";
}
type T2 = (x: string) => void;
const t1 = { a: 1 } satisfies I1; // Ok
const t2 = { a: 1, b: 1 } satisfies I1; // Error
const t3 = { } satisfies I1; // Error
const t4: T1 = { a: "a" } satisfies T1; // Ok
const t5 = (m => m.substring(0)) satisfies T2; // Ok
const t6 = [1, 2] satisfies [number, number];
interface A {
a: string
}
let t7 = { a: 'test' } satisfies A;
let t8 = { a: 'test', b: 'test' } satisfies A;
//// [typeSatisfaction.js]
var t1 = { a: 1 }; // Ok
var t2 = { a: 1, b: 1 }; // Error
var t3 = {}; // Error
var t4 = { a: "a" }; // Ok
var t5 = (function (m) { return m.substring(0); }); // Ok
var t6 = [1, 2];
var t7 = { a: 'test' };
var t8 = { a: 'test', b: 'test' };
@@ -0,0 +1,68 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts ===
interface I1 {
>I1 : Symbol(I1, Decl(typeSatisfaction.ts, 0, 0))
a: number;
>a : Symbol(I1.a, Decl(typeSatisfaction.ts, 0, 14))
}
type T1 = {
>T1 : Symbol(T1, Decl(typeSatisfaction.ts, 2, 1))
a: "a" | "b";
>a : Symbol(a, Decl(typeSatisfaction.ts, 4, 11))
}
type T2 = (x: string) => void;
>T2 : Symbol(T2, Decl(typeSatisfaction.ts, 6, 1))
>x : Symbol(x, Decl(typeSatisfaction.ts, 8, 11))
const t1 = { a: 1 } satisfies I1; // Ok
>t1 : Symbol(t1, Decl(typeSatisfaction.ts, 10, 5))
>a : Symbol(a, Decl(typeSatisfaction.ts, 10, 12))
>I1 : Symbol(I1, Decl(typeSatisfaction.ts, 0, 0))
const t2 = { a: 1, b: 1 } satisfies I1; // Error
>t2 : Symbol(t2, Decl(typeSatisfaction.ts, 11, 5))
>a : Symbol(a, Decl(typeSatisfaction.ts, 11, 12))
>b : Symbol(b, Decl(typeSatisfaction.ts, 11, 18))
>I1 : Symbol(I1, Decl(typeSatisfaction.ts, 0, 0))
const t3 = { } satisfies I1; // Error
>t3 : Symbol(t3, Decl(typeSatisfaction.ts, 12, 5))
>I1 : Symbol(I1, Decl(typeSatisfaction.ts, 0, 0))
const t4: T1 = { a: "a" } satisfies T1; // Ok
>t4 : Symbol(t4, Decl(typeSatisfaction.ts, 14, 5))
>T1 : Symbol(T1, Decl(typeSatisfaction.ts, 2, 1))
>a : Symbol(a, Decl(typeSatisfaction.ts, 14, 16))
>T1 : Symbol(T1, Decl(typeSatisfaction.ts, 2, 1))
const t5 = (m => m.substring(0)) satisfies T2; // Ok
>t5 : Symbol(t5, Decl(typeSatisfaction.ts, 15, 5))
>m : Symbol(m, Decl(typeSatisfaction.ts, 15, 12))
>m.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
>m : Symbol(m, Decl(typeSatisfaction.ts, 15, 12))
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
>T2 : Symbol(T2, Decl(typeSatisfaction.ts, 6, 1))
const t6 = [1, 2] satisfies [number, number];
>t6 : Symbol(t6, Decl(typeSatisfaction.ts, 17, 5))
interface A {
>A : Symbol(A, Decl(typeSatisfaction.ts, 17, 45))
a: string
>a : Symbol(A.a, Decl(typeSatisfaction.ts, 19, 13))
}
let t7 = { a: 'test' } satisfies A;
>t7 : Symbol(t7, Decl(typeSatisfaction.ts, 22, 3))
>a : Symbol(a, Decl(typeSatisfaction.ts, 22, 10))
>A : Symbol(A, Decl(typeSatisfaction.ts, 17, 45))
let t8 = { a: 'test', b: 'test' } satisfies A;
>t8 : Symbol(t8, Decl(typeSatisfaction.ts, 23, 3))
>a : Symbol(a, Decl(typeSatisfaction.ts, 23, 10))
>b : Symbol(b, Decl(typeSatisfaction.ts, 23, 21))
>A : Symbol(A, Decl(typeSatisfaction.ts, 17, 45))
@@ -0,0 +1,84 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts ===
interface I1 {
a: number;
>a : number
}
type T1 = {
>T1 : { a: "a" | "b"; }
a: "a" | "b";
>a : "a" | "b"
}
type T2 = (x: string) => void;
>T2 : (x: string) => void
>x : string
const t1 = { a: 1 } satisfies I1; // Ok
>t1 : { a: number; }
>{ a: 1 } satisfies I1 : { a: number; }
>{ a: 1 } : { a: number; }
>a : number
>1 : 1
const t2 = { a: 1, b: 1 } satisfies I1; // Error
>t2 : { a: number; b: number; }
>{ a: 1, b: 1 } satisfies I1 : { a: number; b: number; }
>{ a: 1, b: 1 } : { a: number; b: number; }
>a : number
>1 : 1
>b : number
>1 : 1
const t3 = { } satisfies I1; // Error
>t3 : {}
>{ } satisfies I1 : {}
>{ } : {}
const t4: T1 = { a: "a" } satisfies T1; // Ok
>t4 : T1
>{ a: "a" } satisfies T1 : { a: "a"; }
>{ a: "a" } : { a: "a"; }
>a : "a"
>"a" : "a"
const t5 = (m => m.substring(0)) satisfies T2; // Ok
>t5 : (m: string) => string
>(m => m.substring(0)) satisfies T2 : (m: string) => string
>(m => m.substring(0)) : (m: string) => string
>m => m.substring(0) : (m: string) => string
>m : string
>m.substring(0) : string
>m.substring : (start: number, end?: number) => string
>m : string
>substring : (start: number, end?: number) => string
>0 : 0
const t6 = [1, 2] satisfies [number, number];
>t6 : [number, number]
>[1, 2] satisfies [number, number] : [number, number]
>[1, 2] : [number, number]
>1 : 1
>2 : 2
interface A {
a: string
>a : string
}
let t7 = { a: 'test' } satisfies A;
>t7 : { a: string; }
>{ a: 'test' } satisfies A : { a: string; }
>{ a: 'test' } : { a: string; }
>a : string
>'test' : "test"
let t8 = { a: 'test', b: 'test' } satisfies A;
>t8 : { a: string; b: string; }
>{ a: 'test', b: 'test' } satisfies A : { a: string; b: string; }
>{ a: 'test', b: 'test' } : { a: string; b: string; }
>a : string
>'test' : "test"
>b : string
>'test' : "test"
@@ -0,0 +1,20 @@
tests/cases/conformance/expressions/typeSatisfaction/a.ts(4,29): error TS1360: Type '{}' does not satisfy the expected type 'Foo'.
Property 'a' is missing in type '{}' but required in type 'Foo'.
==== tests/cases/conformance/expressions/typeSatisfaction/a.ts (1 errors) ====
interface Foo {
a: number;
}
export default {} satisfies Foo;
~~~
!!! error TS1360: Type '{}' does not satisfy the expected type 'Foo'.
!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'Foo'.
!!! related TS2728 tests/cases/conformance/expressions/typeSatisfaction/a.ts:2:5: 'a' is declared here.
==== tests/cases/conformance/expressions/typeSatisfaction/b.ts (0 errors) ====
interface Foo {
a: number;
}
export default { a: 1 } satisfies Foo;
@@ -0,0 +1,19 @@
//// [tests/cases/conformance/expressions/typeSatisfaction/typeSatisfactionWithDefaultExport.ts] ////
//// [a.ts]
interface Foo {
a: number;
}
export default {} satisfies Foo;
//// [b.ts]
interface Foo {
a: number;
}
export default { a: 1 } satisfies Foo;
//// [a.js]
export default {};
//// [b.js]
export default { a: 1 };
@@ -0,0 +1,21 @@
=== tests/cases/conformance/expressions/typeSatisfaction/a.ts ===
interface Foo {
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
a: number;
>a : Symbol(Foo.a, Decl(a.ts, 0, 15))
}
export default {} satisfies Foo;
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
=== tests/cases/conformance/expressions/typeSatisfaction/b.ts ===
interface Foo {
>Foo : Symbol(Foo, Decl(b.ts, 0, 0))
a: number;
>a : Symbol(Foo.a, Decl(b.ts, 0, 15))
}
export default { a: 1 } satisfies Foo;
>a : Symbol(a, Decl(b.ts, 3, 16))
>Foo : Symbol(Foo, Decl(b.ts, 0, 0))
@@ -0,0 +1,20 @@
=== tests/cases/conformance/expressions/typeSatisfaction/a.ts ===
interface Foo {
a: number;
>a : number
}
export default {} satisfies Foo;
>{} satisfies Foo : {}
>{} : {}
=== tests/cases/conformance/expressions/typeSatisfaction/b.ts ===
interface Foo {
a: number;
>a : number
}
export default { a: 1 } satisfies Foo;
>{ a: 1 } satisfies Foo : { a: number; }
>{ a: 1 } : { a: number; }
>a : number
>1 : 1
@@ -0,0 +1,14 @@
//// [typeSatisfaction_contextualTyping1.ts]
type Predicates = { [s: string]: (n: number) => boolean };
const p = {
isEven: n => n % 2 === 0,
isOdd: n => n % 2 === 1
} satisfies Predicates;
//// [typeSatisfaction_contextualTyping1.js]
var p = {
isEven: function (n) { return n % 2 === 0; },
isOdd: function (n) { return n % 2 === 1; }
};
@@ -0,0 +1,22 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping1.ts ===
type Predicates = { [s: string]: (n: number) => boolean };
>Predicates : Symbol(Predicates, Decl(typeSatisfaction_contextualTyping1.ts, 0, 0))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping1.ts, 0, 21))
>n : Symbol(n, Decl(typeSatisfaction_contextualTyping1.ts, 0, 34))
const p = {
>p : Symbol(p, Decl(typeSatisfaction_contextualTyping1.ts, 2, 5))
isEven: n => n % 2 === 0,
>isEven : Symbol(isEven, Decl(typeSatisfaction_contextualTyping1.ts, 2, 11))
>n : Symbol(n, Decl(typeSatisfaction_contextualTyping1.ts, 3, 11))
>n : Symbol(n, Decl(typeSatisfaction_contextualTyping1.ts, 3, 11))
isOdd: n => n % 2 === 1
>isOdd : Symbol(isOdd, Decl(typeSatisfaction_contextualTyping1.ts, 3, 29))
>n : Symbol(n, Decl(typeSatisfaction_contextualTyping1.ts, 4, 10))
>n : Symbol(n, Decl(typeSatisfaction_contextualTyping1.ts, 4, 10))
} satisfies Predicates;
>Predicates : Symbol(Predicates, Decl(typeSatisfaction_contextualTyping1.ts, 0, 0))
@@ -0,0 +1,33 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping1.ts ===
type Predicates = { [s: string]: (n: number) => boolean };
>Predicates : { [s: string]: (n: number) => boolean; }
>s : string
>n : number
const p = {
>p : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; }
>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} satisfies Predicates : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; }
>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; }
isEven: n => n % 2 === 0,
>isEven : (n: number) => boolean
>n => n % 2 === 0 : (n: number) => boolean
>n : number
>n % 2 === 0 : boolean
>n % 2 : number
>n : number
>2 : 2
>0 : 0
isOdd: n => n % 2 === 1
>isOdd : (n: number) => boolean
>n => n % 2 === 1 : (n: number) => boolean
>n : number
>n % 2 === 1 : boolean
>n % 2 : number
>n : number
>2 : 2
>1 : 1
} satisfies Predicates;
@@ -0,0 +1,14 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts(2,7): error TS7006: Parameter 's' implicitly has an 'any' type.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts (1 errors) ====
let obj: { f(s: string): void } & Record<string, unknown> = {
f(s) { }, // "incorrect" implicit any on 's'
~
!!! error TS7006: Parameter 's' implicitly has an 'any' type.
g(s) { }
} satisfies { g(s: string): void } & Record<string, unknown>;
// This needs to not crash (outer node is not expression)
({ f(x) { } }) satisfies { f(s: string): void };
@@ -0,0 +1,18 @@
//// [typeSatisfaction_contextualTyping2.ts]
let obj: { f(s: string): void } & Record<string, unknown> = {
f(s) { }, // "incorrect" implicit any on 's'
g(s) { }
} satisfies { g(s: string): void } & Record<string, unknown>;
// This needs to not crash (outer node is not expression)
({ f(x) { } }) satisfies { f(s: string): void };
//// [typeSatisfaction_contextualTyping2.js]
"use strict";
var obj = {
f: function (s) { },
g: function (s) { }
};
// This needs to not crash (outer node is not expression)
({ f: function (x) { } });
@@ -0,0 +1,27 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts ===
let obj: { f(s: string): void } & Record<string, unknown> = {
>obj : Symbol(obj, Decl(typeSatisfaction_contextualTyping2.ts, 0, 3))
>f : Symbol(f, Decl(typeSatisfaction_contextualTyping2.ts, 0, 10))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping2.ts, 0, 13))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
f(s) { }, // "incorrect" implicit any on 's'
>f : Symbol(f, Decl(typeSatisfaction_contextualTyping2.ts, 0, 61))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping2.ts, 1, 6))
g(s) { }
>g : Symbol(g, Decl(typeSatisfaction_contextualTyping2.ts, 1, 13))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping2.ts, 2, 6))
} satisfies { g(s: string): void } & Record<string, unknown>;
>g : Symbol(g, Decl(typeSatisfaction_contextualTyping2.ts, 3, 13))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping2.ts, 3, 16))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
// This needs to not crash (outer node is not expression)
({ f(x) { } }) satisfies { f(s: string): void };
>f : Symbol(f, Decl(typeSatisfaction_contextualTyping2.ts, 6, 2))
>x : Symbol(x, Decl(typeSatisfaction_contextualTyping2.ts, 6, 5))
>f : Symbol(f, Decl(typeSatisfaction_contextualTyping2.ts, 6, 26))
>s : Symbol(s, Decl(typeSatisfaction_contextualTyping2.ts, 6, 29))
@@ -0,0 +1,30 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts ===
let obj: { f(s: string): void } & Record<string, unknown> = {
>obj : { f(s: string): void; } & Record<string, unknown>
>f : (s: string) => void
>s : string
>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} satisfies { g(s: string): void } & Record<string, unknown> : { f(s: any): void; g(s: string): void; }
>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; }
f(s) { }, // "incorrect" implicit any on 's'
>f : (s: any) => void
>s : any
g(s) { }
>g : (s: string) => void
>s : string
} satisfies { g(s: string): void } & Record<string, unknown>;
>g : (s: string) => void
>s : string
// This needs to not crash (outer node is not expression)
({ f(x) { } }) satisfies { f(s: string): void };
>({ f(x) { } }) satisfies { f(s: string): void } : { f(x: string): void; }
>({ f(x) { } }) : { f(x: string): void; }
>{ f(x) { } } : { f(x: string): void; }
>f : (x: string) => void
>x : string
>f : (s: string) => void
>s : string
@@ -0,0 +1,22 @@
//// [typeSatisfaction_ensureInterfaceImpl.ts]
type Movable = {
move(distance: number): void;
};
const car = {
start() { },
move(d) {
// d should be number
},
stop() { }
} satisfies Movable & Record<string, unknown>;
//// [typeSatisfaction_ensureInterfaceImpl.js]
var car = {
start: function () { },
move: function (d) {
// d should be number
},
stop: function () { }
};
@@ -0,0 +1,29 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_ensureInterfaceImpl.ts ===
type Movable = {
>Movable : Symbol(Movable, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 0, 0))
move(distance: number): void;
>move : Symbol(move, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 0, 16))
>distance : Symbol(distance, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 1, 9))
};
const car = {
>car : Symbol(car, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 4, 5))
start() { },
>start : Symbol(start, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 4, 13))
move(d) {
>move : Symbol(move, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 5, 16))
>d : Symbol(d, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 6, 9))
// d should be number
},
stop() { }
>stop : Symbol(stop, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 8, 6))
} satisfies Movable & Record<string, unknown>;
>Movable : Symbol(Movable, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 0, 0))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
@@ -0,0 +1,29 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_ensureInterfaceImpl.ts ===
type Movable = {
>Movable : { move(distance: number): void; }
move(distance: number): void;
>move : (distance: number) => void
>distance : number
};
const car = {
>car : { start(): void; move(d: number): void; stop(): void; }
>{ start() { }, move(d) { // d should be number }, stop() { }} satisfies Movable & Record<string, unknown> : { start(): void; move(d: number): void; stop(): void; }
>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; }
start() { },
>start : () => void
move(d) {
>move : (d: number) => void
>d : number
// d should be number
},
stop() { }
>stop : () => void
} satisfies Movable & Record<string, unknown>;
@@ -0,0 +1,8 @@
/src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files.
==== /src/a.js (1 errors) ====
var v = undefined satisfies 1;
~
!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files.
@@ -0,0 +1,6 @@
//// [a.js]
var v = undefined satisfies 1;
//// [a.js]
var v = undefined;
@@ -0,0 +1,5 @@
=== /src/a.js ===
var v = undefined satisfies 1;
>v : Symbol(v, Decl(a.js, 0, 3))
>undefined : Symbol(undefined)
@@ -0,0 +1,6 @@
=== /src/a.js ===
var v = undefined satisfies 1;
>v : any
>undefined satisfies 1 : undefined
>undefined : undefined
@@ -0,0 +1,14 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts(7,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts (1 errors) ====
type Point2d = { x: number, y: number };
// Undesirable behavior today with type annotation
const a = { x: 10 } satisfies Partial<Point2d>;
// Should OK
console.log(a.x.toFixed());
// Should error
let p = a.y;
~
!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'.
@@ -0,0 +1,17 @@
//// [typeSatisfaction_optionalMemberConformance.ts]
type Point2d = { x: number, y: number };
// Undesirable behavior today with type annotation
const a = { x: 10 } satisfies Partial<Point2d>;
// Should OK
console.log(a.x.toFixed());
// Should error
let p = a.y;
//// [typeSatisfaction_optionalMemberConformance.js]
// Undesirable behavior today with type annotation
var a = { x: 10 };
// Should OK
console.log(a.x.toFixed());
// Should error
var p = a.y;
@@ -0,0 +1,29 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts ===
type Point2d = { x: number, y: number };
>Point2d : Symbol(Point2d, Decl(typeSatisfaction_optionalMemberConformance.ts, 0, 0))
>x : Symbol(x, Decl(typeSatisfaction_optionalMemberConformance.ts, 0, 16))
>y : Symbol(y, Decl(typeSatisfaction_optionalMemberConformance.ts, 0, 27))
// Undesirable behavior today with type annotation
const a = { x: 10 } satisfies Partial<Point2d>;
>a : Symbol(a, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 5))
>x : Symbol(x, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 11))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Point2d : Symbol(Point2d, Decl(typeSatisfaction_optionalMemberConformance.ts, 0, 0))
// Should OK
console.log(a.x.toFixed());
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>a.x.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>a.x : Symbol(x, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 11))
>a : Symbol(a, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 5))
>x : Symbol(x, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 11))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
// Should error
let p = a.y;
>p : Symbol(p, Decl(typeSatisfaction_optionalMemberConformance.ts, 6, 3))
>a : Symbol(a, Decl(typeSatisfaction_optionalMemberConformance.ts, 2, 5))
@@ -0,0 +1,34 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts ===
type Point2d = { x: number, y: number };
>Point2d : { x: number; y: number; }
>x : number
>y : number
// Undesirable behavior today with type annotation
const a = { x: 10 } satisfies Partial<Point2d>;
>a : { x: number; }
>{ x: 10 } satisfies Partial<Point2d> : { x: number; }
>{ x: 10 } : { x: number; }
>x : number
>10 : 10
// Should OK
console.log(a.x.toFixed());
>console.log(a.x.toFixed()) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>a.x.toFixed() : string
>a.x.toFixed : (fractionDigits?: number) => string
>a.x : number
>a : { x: number; }
>x : number
>toFixed : (fractionDigits?: number) => string
// Should error
let p = a.y;
>p : any
>a.y : any
>a : { x: number; }
>y : any
@@ -0,0 +1,25 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts(6,5): error TS1360: Type '{ a: number; b: string; x: number; }' does not satisfy the expected type 'Partial<Record<Keys, unknown>>'.
Object literal may only specify known properties, and 'x' does not exist in type 'Partial<Record<Keys, unknown>>'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts(13,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts (2 errors) ====
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
~~~~
!!! error TS1360: Type '{ a: number; b: string; x: number; }' does not satisfy the expected type 'Partial<Record<Keys, unknown>>'.
!!! error TS1360: Object literal may only specify known properties, and 'x' does not exist in type 'Partial<Record<Keys, unknown>>'.
} satisfies Partial<Record<Keys, unknown>>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
~
!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'.
@@ -0,0 +1,27 @@
//// [typeSatisfaction_propNameConstraining.ts]
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
} satisfies Partial<Record<Keys, unknown>>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
//// [typeSatisfaction_propNameConstraining.js]
var p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
};
// Should be OK -- retain info that a is number and b is string
var a = p.a.toFixed();
var b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
var d = p.d;
@@ -0,0 +1,43 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts ===
type Keys = 'a' | 'b' | 'c' | 'd';
>Keys : Symbol(Keys, Decl(typeSatisfaction_propNameConstraining.ts, 0, 0))
const p = {
>p : Symbol(p, Decl(typeSatisfaction_propNameConstraining.ts, 2, 5))
a: 0,
>a : Symbol(a, Decl(typeSatisfaction_propNameConstraining.ts, 2, 11))
b: "hello",
>b : Symbol(b, Decl(typeSatisfaction_propNameConstraining.ts, 3, 9))
x: 8 // Should error, 'x' isn't in 'Keys'
>x : Symbol(x, Decl(typeSatisfaction_propNameConstraining.ts, 4, 15))
} satisfies Partial<Record<Keys, unknown>>;
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>Keys : Symbol(Keys, Decl(typeSatisfaction_propNameConstraining.ts, 0, 0))
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
>a : Symbol(a, Decl(typeSatisfaction_propNameConstraining.ts, 9, 3))
>p.a.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>p.a : Symbol(a, Decl(typeSatisfaction_propNameConstraining.ts, 2, 11))
>p : Symbol(p, Decl(typeSatisfaction_propNameConstraining.ts, 2, 5))
>a : Symbol(a, Decl(typeSatisfaction_propNameConstraining.ts, 2, 11))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
let b = p.b.substring(1);
>b : Symbol(b, Decl(typeSatisfaction_propNameConstraining.ts, 10, 3))
>p.b.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
>p.b : Symbol(b, Decl(typeSatisfaction_propNameConstraining.ts, 3, 9))
>p : Symbol(p, Decl(typeSatisfaction_propNameConstraining.ts, 2, 5))
>b : Symbol(b, Decl(typeSatisfaction_propNameConstraining.ts, 3, 9))
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
// Should error even though 'd' is in 'Keys'
let d = p.d;
>d : Symbol(d, Decl(typeSatisfaction_propNameConstraining.ts, 12, 3))
>p : Symbol(p, Decl(typeSatisfaction_propNameConstraining.ts, 2, 5))
@@ -0,0 +1,50 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts ===
type Keys = 'a' | 'b' | 'c' | 'd';
>Keys : "a" | "b" | "c" | "d"
const p = {
>p : { a: number; b: string; x: number; }
>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} satisfies Partial<Record<Keys, unknown>> : { a: number; b: string; x: number; }
>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; }
a: 0,
>a : number
>0 : 0
b: "hello",
>b : string
>"hello" : "hello"
x: 8 // Should error, 'x' isn't in 'Keys'
>x : number
>8 : 8
} satisfies Partial<Record<Keys, unknown>>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
>a : string
>p.a.toFixed() : string
>p.a.toFixed : (fractionDigits?: number) => string
>p.a : number
>p : { a: number; b: string; x: number; }
>a : number
>toFixed : (fractionDigits?: number) => string
let b = p.b.substring(1);
>b : string
>p.b.substring(1) : string
>p.b.substring : (start: number, end?: number) => string
>p.b : string
>p : { a: number; b: string; x: number; }
>b : string
>substring : (start: number, end?: number) => string
>1 : 1
// Should error even though 'd' is in 'Keys'
let d = p.d;
>d : any
>p.d : any
>p : { a: number; b: string; x: number; }
>d : any
@@ -0,0 +1,25 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts(6,5): error TS1360: Type '{ a: number; b: string; x: number; }' does not satisfy the expected type 'Record<Keys, unknown>'.
Object literal may only specify known properties, and 'x' does not exist in type 'Record<Keys, unknown>'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts(13,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts (2 errors) ====
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
~~~~
!!! error TS1360: Type '{ a: number; b: string; x: number; }' does not satisfy the expected type 'Record<Keys, unknown>'.
!!! error TS1360: Object literal may only specify known properties, and 'x' does not exist in type 'Record<Keys, unknown>'.
} satisfies Record<Keys, unknown>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
~
!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'.
@@ -0,0 +1,27 @@
//// [typeSatisfaction_propertyNameFulfillment.ts]
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
} satisfies Record<Keys, unknown>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
//// [typeSatisfaction_propertyNameFulfillment.js]
var p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
};
// Should be OK -- retain info that a is number and b is string
var a = p.a.toFixed();
var b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
var d = p.d;
@@ -0,0 +1,42 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts ===
type Keys = 'a' | 'b' | 'c' | 'd';
>Keys : Symbol(Keys, Decl(typeSatisfaction_propertyNameFulfillment.ts, 0, 0))
const p = {
>p : Symbol(p, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 5))
a: 0,
>a : Symbol(a, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 11))
b: "hello",
>b : Symbol(b, Decl(typeSatisfaction_propertyNameFulfillment.ts, 3, 9))
x: 8 // Should error, 'x' isn't in 'Keys'
>x : Symbol(x, Decl(typeSatisfaction_propertyNameFulfillment.ts, 4, 15))
} satisfies Record<Keys, unknown>;
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>Keys : Symbol(Keys, Decl(typeSatisfaction_propertyNameFulfillment.ts, 0, 0))
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
>a : Symbol(a, Decl(typeSatisfaction_propertyNameFulfillment.ts, 9, 3))
>p.a.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>p.a : Symbol(a, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 11))
>p : Symbol(p, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 5))
>a : Symbol(a, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 11))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
let b = p.b.substring(1);
>b : Symbol(b, Decl(typeSatisfaction_propertyNameFulfillment.ts, 10, 3))
>p.b.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
>p.b : Symbol(b, Decl(typeSatisfaction_propertyNameFulfillment.ts, 3, 9))
>p : Symbol(p, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 5))
>b : Symbol(b, Decl(typeSatisfaction_propertyNameFulfillment.ts, 3, 9))
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
// Should error even though 'd' is in 'Keys'
let d = p.d;
>d : Symbol(d, Decl(typeSatisfaction_propertyNameFulfillment.ts, 12, 3))
>p : Symbol(p, Decl(typeSatisfaction_propertyNameFulfillment.ts, 2, 5))
@@ -0,0 +1,50 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts ===
type Keys = 'a' | 'b' | 'c' | 'd';
>Keys : "a" | "b" | "c" | "d"
const p = {
>p : { a: number; b: string; x: number; }
>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} satisfies Record<Keys, unknown> : { a: number; b: string; x: number; }
>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; }
a: 0,
>a : number
>0 : 0
b: "hello",
>b : string
>"hello" : "hello"
x: 8 // Should error, 'x' isn't in 'Keys'
>x : number
>8 : 8
} satisfies Record<Keys, unknown>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
>a : string
>p.a.toFixed() : string
>p.a.toFixed : (fractionDigits?: number) => string
>p.a : number
>p : { a: number; b: string; x: number; }
>a : number
>toFixed : (fractionDigits?: number) => string
let b = p.b.substring(1);
>b : string
>p.b.substring(1) : string
>p.b.substring : (start: number, end?: number) => string
>p.b : string
>p : { a: number; b: string; x: number; }
>b : string
>substring : (start: number, end?: number) => string
>1 : 1
// Should error even though 'd' is in 'Keys'
let d = p.d;
>d : any
>p.d : any
>p : { a: number; b: string; x: number; }
>d : any
@@ -0,0 +1,34 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts(13,15): error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts(22,5): error TS2322: Type 'string' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts (2 errors) ====
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
~
!!! error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
!!! related TS6501 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts:1:16: The expected type comes from this index signature.
} satisfies Facts;
@@ -0,0 +1,42 @@
//// [typeSatisfaction_propertyValueConformance1.ts]
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
//// [typeSatisfaction_propertyValueConformance1.js]
var x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
var m = x.m;
// Should be able to detect a failure here
var x2 = {
m: true,
s: "false"
};
@@ -0,0 +1,64 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts ===
type Facts = { [key: string]: boolean };
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
>key : Symbol(key, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 16))
declare function checkTruths(x: Facts): void;
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 29))
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
declare function checkM(x: { m: boolean }): void;
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 24))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 28))
const x = {
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
m: true
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
};
// Should be OK
checkTruths(x);
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should be OK
checkM(x);
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
const m: boolean = x.m;
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 5))
>x.m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
// Should be 'm'
type M = keyof typeof x;
>M : Symbol(M, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 23))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should be able to detect a failure here
const x2 = {
>x2 : Symbol(x2, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 5))
m: true,
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 12))
s: "false"
>s : Symbol(s, Decl(typeSatisfaction_propertyValueConformance1.ts, 20, 12))
} satisfies Facts;
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
@@ -0,0 +1,73 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts ===
type Facts = { [key: string]: boolean };
>Facts : { [key: string]: boolean; }
>key : string
declare function checkTruths(x: Facts): void;
>checkTruths : (x: Facts) => void
>x : Facts
declare function checkM(x: { m: boolean }): void;
>checkM : (x: { m: boolean;}) => void
>x : { m: boolean; }
>m : boolean
const x = {
>x : { m: boolean; }
>{ m: true} : { m: boolean; }
m: true
>m : boolean
>true : true
};
// Should be OK
checkTruths(x);
>checkTruths(x) : void
>checkTruths : (x: Facts) => void
>x : { m: boolean; }
// Should be OK
checkM(x);
>checkM(x) : void
>checkM : (x: { m: boolean; }) => void
>x : { m: boolean; }
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
>console.log(x.z) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>x.z : any
>x : { m: boolean; }
>z : any
const m: boolean = x.m;
>m : boolean
>x.m : boolean
>x : { m: boolean; }
>m : boolean
// Should be 'm'
type M = keyof typeof x;
>M : "m"
>x : { m: boolean; }
// Should be able to detect a failure here
const x2 = {
>x2 : { m: true; s: string; }
>{ m: true, s: "false"} satisfies Facts : { m: true; s: string; }
>{ m: true, s: "false"} : { m: true; s: string; }
m: true,
>m : true
>true : true
s: "false"
>s : string
>"false" : "false"
} satisfies Facts;
@@ -0,0 +1,34 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts(13,15): error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts(22,5): error TS2322: Type 'string' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts (2 errors) ====
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
~
!!! error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
!!! related TS6501 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts:1:16: The expected type comes from this index signature.
} satisfies Facts;
@@ -0,0 +1,42 @@
//// [typeSatisfaction_propertyValueConformance1.ts]
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
//// [typeSatisfaction_propertyValueConformance1.js]
var x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
var m = x.m;
// Should be able to detect a failure here
var x2 = {
m: true,
s: "false"
};
@@ -0,0 +1,64 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts ===
type Facts = { [key: string]: boolean };
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
>key : Symbol(key, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 16))
declare function checkTruths(x: Facts): void;
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 29))
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
declare function checkM(x: { m: boolean }): void;
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 24))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 2, 28))
const x = {
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
m: true
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
};
// Should be OK
checkTruths(x);
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should be OK
checkM(x);
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance1.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
const m: boolean = x.m;
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 5))
>x.m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 11))
// Should be 'm'
type M = keyof typeof x;
>M : Symbol(M, Decl(typeSatisfaction_propertyValueConformance1.ts, 13, 23))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance1.ts, 3, 5))
// Should be able to detect a failure here
const x2 = {
>x2 : Symbol(x2, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 5))
m: true,
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance1.ts, 19, 12))
s: "false"
>s : Symbol(s, Decl(typeSatisfaction_propertyValueConformance1.ts, 20, 12))
} satisfies Facts;
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance1.ts, 0, 0))
@@ -0,0 +1,73 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts ===
type Facts = { [key: string]: boolean };
>Facts : { [key: string]: boolean; }
>key : string
declare function checkTruths(x: Facts): void;
>checkTruths : (x: Facts) => void
>x : Facts
declare function checkM(x: { m: boolean }): void;
>checkM : (x: { m: boolean;}) => void
>x : { m: boolean; }
>m : boolean
const x = {
>x : { m: boolean; }
>{ m: true} : { m: boolean; }
m: true
>m : boolean
>true : true
};
// Should be OK
checkTruths(x);
>checkTruths(x) : void
>checkTruths : (x: Facts) => void
>x : { m: boolean; }
// Should be OK
checkM(x);
>checkM(x) : void
>checkM : (x: { m: boolean; }) => void
>x : { m: boolean; }
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
>console.log(x.z) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>x.z : any
>x : { m: boolean; }
>z : any
const m: boolean = x.m;
>m : boolean
>x.m : boolean
>x : { m: boolean; }
>m : boolean
// Should be 'm'
type M = keyof typeof x;
>M : "m"
>x : { m: boolean; }
// Should be able to detect a failure here
const x2 = {
>x2 : { m: true; s: string; }
>{ m: true, s: "false"} satisfies Facts : { m: true; s: string; }
>{ m: true, s: "false"} : { m: true; s: string; }
m: true,
>m : true
>true : true
s: "false"
>s : string
>"false" : "false"
} satisfies Facts;
@@ -0,0 +1,34 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts(12,15): error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts(22,5): error TS2322: Type 'string' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts (2 errors) ====
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
~
!!! error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
!!! related TS6501 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts:1:16: The expected type comes from this index signature.
} satisfies Facts;
@@ -0,0 +1,42 @@
//// [typeSatisfaction_propertyValueConformance2.ts]
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
//// [typeSatisfaction_propertyValueConformance2.js]
var x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
// Should be OK under --noUncheckedIndexedAccess
var m = x.m;
// Should be able to detect a failure here
var x2 = {
m: true,
s: "false"
};
@@ -0,0 +1,64 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts ===
type Facts = { [key: string]: boolean };
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
>key : Symbol(key, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 16))
declare function checkTruths(x: Facts): void;
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 29))
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
declare function checkM(x: { m: boolean }): void;
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 2, 24))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 2, 28))
const x = {
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
m: true
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
};
// Should be OK
checkTruths(x);
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be OK
checkM(x);
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
console.log(x.z);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 13, 5))
>x.m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
// Should be 'm'
type M = keyof typeof x;
>M : Symbol(M, Decl(typeSatisfaction_propertyValueConformance2.ts, 13, 23))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be able to detect a failure here
const x2 = {
>x2 : Symbol(x2, Decl(typeSatisfaction_propertyValueConformance2.ts, 19, 5))
m: true,
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 19, 12))
s: "false"
>s : Symbol(s, Decl(typeSatisfaction_propertyValueConformance2.ts, 20, 12))
} satisfies Facts;
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
@@ -0,0 +1,73 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts ===
type Facts = { [key: string]: boolean };
>Facts : { [key: string]: boolean; }
>key : string
declare function checkTruths(x: Facts): void;
>checkTruths : (x: Facts) => void
>x : Facts
declare function checkM(x: { m: boolean }): void;
>checkM : (x: { m: boolean;}) => void
>x : { m: boolean; }
>m : boolean
const x = {
>x : { m: boolean; }
>{ m: true} : { m: boolean; }
m: true
>m : boolean
>true : true
};
// Should be OK
checkTruths(x);
>checkTruths(x) : void
>checkTruths : (x: Facts) => void
>x : { m: boolean; }
// Should be OK
checkM(x);
>checkM(x) : void
>checkM : (x: { m: boolean; }) => void
>x : { m: boolean; }
console.log(x.z);
>console.log(x.z) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>x.z : any
>x : { m: boolean; }
>z : any
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
>m : boolean
>x.m : boolean
>x : { m: boolean; }
>m : boolean
// Should be 'm'
type M = keyof typeof x;
>M : "m"
>x : { m: boolean; }
// Should be able to detect a failure here
const x2 = {
>x2 : { m: true; s: string; }
>{ m: true, s: "false"} satisfies Facts : { m: true; s: string; }
>{ m: true, s: "false"} : { m: true; s: string; }
m: true,
>m : true
>true : true
s: "false"
>s : string
>"false" : "false"
} satisfies Facts;
@@ -0,0 +1,34 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts(12,15): error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts(22,5): error TS2322: Type 'string' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts (2 errors) ====
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
~
!!! error TS2339: Property 'z' does not exist on type '{ m: boolean; }'.
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
!!! related TS6501 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts:1:16: The expected type comes from this index signature.
} satisfies Facts;
@@ -0,0 +1,42 @@
//// [typeSatisfaction_propertyValueConformance2.ts]
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
//// [typeSatisfaction_propertyValueConformance2.js]
var x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
// Should be OK under --noUncheckedIndexedAccess
var m = x.m;
// Should be able to detect a failure here
var x2 = {
m: true,
s: "false"
};
@@ -0,0 +1,64 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts ===
type Facts = { [key: string]: boolean };
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
>key : Symbol(key, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 16))
declare function checkTruths(x: Facts): void;
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 29))
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
declare function checkM(x: { m: boolean }): void;
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 2, 24))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 2, 28))
const x = {
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
m: true
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
};
// Should be OK
checkTruths(x);
>checkTruths : Symbol(checkTruths, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 40))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be OK
checkM(x);
>checkM : Symbol(checkM, Decl(typeSatisfaction_propertyValueConformance2.ts, 1, 45))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
console.log(x.z);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 13, 5))
>x.m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 11))
// Should be 'm'
type M = keyof typeof x;
>M : Symbol(M, Decl(typeSatisfaction_propertyValueConformance2.ts, 13, 23))
>x : Symbol(x, Decl(typeSatisfaction_propertyValueConformance2.ts, 3, 5))
// Should be able to detect a failure here
const x2 = {
>x2 : Symbol(x2, Decl(typeSatisfaction_propertyValueConformance2.ts, 19, 5))
m: true,
>m : Symbol(m, Decl(typeSatisfaction_propertyValueConformance2.ts, 19, 12))
s: "false"
>s : Symbol(s, Decl(typeSatisfaction_propertyValueConformance2.ts, 20, 12))
} satisfies Facts;
>Facts : Symbol(Facts, Decl(typeSatisfaction_propertyValueConformance2.ts, 0, 0))
@@ -0,0 +1,73 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts ===
type Facts = { [key: string]: boolean };
>Facts : { [key: string]: boolean; }
>key : string
declare function checkTruths(x: Facts): void;
>checkTruths : (x: Facts) => void
>x : Facts
declare function checkM(x: { m: boolean }): void;
>checkM : (x: { m: boolean;}) => void
>x : { m: boolean; }
>m : boolean
const x = {
>x : { m: boolean; }
>{ m: true} : { m: boolean; }
m: true
>m : boolean
>true : true
};
// Should be OK
checkTruths(x);
>checkTruths(x) : void
>checkTruths : (x: Facts) => void
>x : { m: boolean; }
// Should be OK
checkM(x);
>checkM(x) : void
>checkM : (x: { m: boolean; }) => void
>x : { m: boolean; }
console.log(x.z);
>console.log(x.z) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>x.z : any
>x : { m: boolean; }
>z : any
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
>m : boolean
>x.m : boolean
>x : { m: boolean; }
>m : boolean
// Should be 'm'
type M = keyof typeof x;
>M : "m"
>x : { m: boolean; }
// Should be able to detect a failure here
const x2 = {
>x2 : { m: true; s: string; }
>{ m: true, s: "false"} satisfies Facts : { m: true; s: string; }
>{ m: true, s: "false"} : { m: true; s: string; }
m: true,
>m : true
>true : true
s: "false"
>s : string
>"false" : "false"
} satisfies Facts;
@@ -0,0 +1,17 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts(6,26): error TS2322: Type '{ r: number; g: number; d: number; }' is not assignable to type 'Color'.
Object literal may only specify known properties, and 'd' does not exist in type 'Color'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts (1 errors) ====
export type Color = { r: number, g: number, b: number };
// All of these should be Colors, but I only use some of them here.
export const Palette = {
white: { r: 255, g: 255, b: 255 },
black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b'
~~~~
!!! error TS2322: Type '{ r: number; g: number; d: number; }' is not assignable to type 'Color'.
!!! error TS2322: Object literal may only specify known properties, and 'd' does not exist in type 'Color'.
blue: { r: 0, g: 0, b: 255 },
} satisfies Record<string, Color>;
@@ -0,0 +1,21 @@
//// [typeSatisfaction_propertyValueConformance3.ts]
export type Color = { r: number, g: number, b: number };
// All of these should be Colors, but I only use some of them here.
export const Palette = {
white: { r: 255, g: 255, b: 255 },
black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b'
blue: { r: 0, g: 0, b: 255 },
} satisfies Record<string, Color>;
//// [typeSatisfaction_propertyValueConformance3.js]
"use strict";
exports.__esModule = true;
exports.Palette = void 0;
// All of these should be Colors, but I only use some of them here.
exports.Palette = {
white: { r: 255, g: 255, b: 255 },
black: { r: 0, g: 0, d: 0 },
blue: { r: 0, g: 0, b: 255 }
};
@@ -0,0 +1,33 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts ===
export type Color = { r: number, g: number, b: number };
>Color : Symbol(Color, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 0))
>r : Symbol(r, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 21))
>g : Symbol(g, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 32))
>b : Symbol(b, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 43))
// All of these should be Colors, but I only use some of them here.
export const Palette = {
>Palette : Symbol(Palette, Decl(typeSatisfaction_propertyValueConformance3.ts, 3, 12))
white: { r: 255, g: 255, b: 255 },
>white : Symbol(white, Decl(typeSatisfaction_propertyValueConformance3.ts, 3, 24))
>r : Symbol(r, Decl(typeSatisfaction_propertyValueConformance3.ts, 4, 12))
>g : Symbol(g, Decl(typeSatisfaction_propertyValueConformance3.ts, 4, 20))
>b : Symbol(b, Decl(typeSatisfaction_propertyValueConformance3.ts, 4, 28))
black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b'
>black : Symbol(black, Decl(typeSatisfaction_propertyValueConformance3.ts, 4, 38))
>r : Symbol(r, Decl(typeSatisfaction_propertyValueConformance3.ts, 5, 12))
>g : Symbol(g, Decl(typeSatisfaction_propertyValueConformance3.ts, 5, 18))
>d : Symbol(d, Decl(typeSatisfaction_propertyValueConformance3.ts, 5, 24))
blue: { r: 0, g: 0, b: 255 },
>blue : Symbol(blue, Decl(typeSatisfaction_propertyValueConformance3.ts, 5, 32))
>r : Symbol(r, Decl(typeSatisfaction_propertyValueConformance3.ts, 6, 11))
>g : Symbol(g, Decl(typeSatisfaction_propertyValueConformance3.ts, 6, 17))
>b : Symbol(b, Decl(typeSatisfaction_propertyValueConformance3.ts, 6, 23))
} satisfies Record<string, Color>;
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>Color : Symbol(Color, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 0))
@@ -0,0 +1,45 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts ===
export type Color = { r: number, g: number, b: number };
>Color : { r: number; g: number; b: number; }
>r : number
>g : number
>b : number
// All of these should be Colors, but I only use some of them here.
export const Palette = {
>Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; }
>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} satisfies Record<string, Color> : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; }
>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; }
white: { r: 255, g: 255, b: 255 },
>white : { r: number; g: number; b: number; }
>{ r: 255, g: 255, b: 255 } : { r: number; g: number; b: number; }
>r : number
>255 : 255
>g : number
>255 : 255
>b : number
>255 : 255
black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b'
>black : { r: number; g: number; d: number; }
>{ r: 0, g: 0, d: 0 } : { r: number; g: number; d: number; }
>r : number
>0 : 0
>g : number
>0 : 0
>d : number
>0 : 0
blue: { r: 0, g: 0, b: 255 },
>blue : { r: number; g: number; b: number; }
>{ r: 0, g: 0, b: 255 } : { r: number; g: number; b: number; }
>r : number
>0 : 0
>g : number
>0 : 0
>b : number
>255 : 255
} satisfies Record<string, Color>;
@@ -0,0 +1,16 @@
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts(1,7): error TS2322: Type '"foo"' is not assignable to type '"baz"'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts(2,7): error TS2322: Type '{ xyz: "foo"; }' is not assignable to type '{ xyz: "baz"; }'.
Types of property 'xyz' are incompatible.
Type '"foo"' is not assignable to type '"baz"'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts (2 errors) ====
const a: "baz" = "foo" satisfies "foo" | "bar";
~
!!! error TS2322: Type '"foo"' is not assignable to type '"baz"'.
const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };
~
!!! error TS2322: Type '{ xyz: "foo"; }' is not assignable to type '{ xyz: "baz"; }'.
!!! error TS2322: Types of property 'xyz' are incompatible.
!!! error TS2322: Type '"foo"' is not assignable to type '"baz"'.
@@ -0,0 +1,8 @@
//// [typeSatisfaction_vacuousIntersectionOfContextualTypes.ts]
const a: "baz" = "foo" satisfies "foo" | "bar";
const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };
//// [typeSatisfaction_vacuousIntersectionOfContextualTypes.js]
var a = "foo";
var b = { xyz: "foo" };
@@ -0,0 +1,10 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts ===
const a: "baz" = "foo" satisfies "foo" | "bar";
>a : Symbol(a, Decl(typeSatisfaction_vacuousIntersectionOfContextualTypes.ts, 0, 5))
const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };
>b : Symbol(b, Decl(typeSatisfaction_vacuousIntersectionOfContextualTypes.ts, 1, 5))
>xyz : Symbol(xyz, Decl(typeSatisfaction_vacuousIntersectionOfContextualTypes.ts, 1, 10))
>xyz : Symbol(xyz, Decl(typeSatisfaction_vacuousIntersectionOfContextualTypes.ts, 1, 27))
>xyz : Symbol(xyz, Decl(typeSatisfaction_vacuousIntersectionOfContextualTypes.ts, 1, 52))
@@ -0,0 +1,15 @@
=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts ===
const a: "baz" = "foo" satisfies "foo" | "bar";
>a : "baz"
>"foo" satisfies "foo" | "bar" : "foo"
>"foo" : "foo"
const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };
>b : { xyz: "baz"; }
>xyz : "baz"
>{ xyz: "foo" } satisfies { xyz: "foo" | "bar" } : { xyz: "foo"; }
>{ xyz: "foo" } : { xyz: "foo"; }
>xyz : "foo"
>"foo" : "foo"
>xyz : "foo" | "bar"
@@ -0,0 +1,24 @@
interface I1 {
a: number;
}
type T1 = {
a: "a" | "b";
}
type T2 = (x: string) => void;
const t1 = { a: 1 } satisfies I1; // Ok
const t2 = { a: 1, b: 1 } satisfies I1; // Error
const t3 = { } satisfies I1; // Error
const t4: T1 = { a: "a" } satisfies T1; // Ok
const t5 = (m => m.substring(0)) satisfies T2; // Ok
const t6 = [1, 2] satisfies [number, number];
interface A {
a: string
}
let t7 = { a: 'test' } satisfies A;
let t8 = { a: 'test', b: 'test' } satisfies A;
@@ -0,0 +1,13 @@
// @module: esnext
// @filename: ./a.ts
interface Foo {
a: number;
}
export default {} satisfies Foo;
// @filename: ./b.ts
interface Foo {
a: number;
}
export default { a: 1 } satisfies Foo;
@@ -0,0 +1,6 @@
type Predicates = { [s: string]: (n: number) => boolean };
const p = {
isEven: n => n % 2 === 0,
isOdd: n => n % 2 === 1
} satisfies Predicates;
@@ -0,0 +1,9 @@
// @strict: true
let obj: { f(s: string): void } & Record<string, unknown> = {
f(s) { }, // "incorrect" implicit any on 's'
g(s) { }
} satisfies { g(s: string): void } & Record<string, unknown>;
// This needs to not crash (outer node is not expression)
({ f(x) { } }) satisfies { f(s: string): void };
@@ -0,0 +1,11 @@
type Movable = {
move(distance: number): void;
};
const car = {
start() { },
move(d) {
// d should be number
},
stop() { }
} satisfies Movable & Record<string, unknown>;
@@ -0,0 +1,5 @@
// @allowJs: true
// @filename: /src/a.js
// @out: /lib/a.js
var v = undefined satisfies 1;
@@ -0,0 +1,7 @@
type Point2d = { x: number, y: number };
// Undesirable behavior today with type annotation
const a = { x: 10 } satisfies Partial<Point2d>;
// Should OK
console.log(a.x.toFixed());
// Should error
let p = a.y;
@@ -0,0 +1,13 @@
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
} satisfies Partial<Record<Keys, unknown>>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
@@ -0,0 +1,13 @@
type Keys = 'a' | 'b' | 'c' | 'd';
const p = {
a: 0,
b: "hello",
x: 8 // Should error, 'x' isn't in 'Keys'
} satisfies Record<Keys, unknown>;
// Should be OK -- retain info that a is number and b is string
let a = p.a.toFixed();
let b = p.b.substring(1);
// Should error even though 'd' is in 'Keys'
let d = p.d;
@@ -0,0 +1,25 @@
// @noPropertyAccessFromIndexSignature: true, false
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
// Should fail under --noPropertyAccessFromIndexSignature
console.log(x.z);
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
@@ -0,0 +1,25 @@
// @noUncheckedIndexedAccess: true, false
type Facts = { [key: string]: boolean };
declare function checkTruths(x: Facts): void;
declare function checkM(x: { m: boolean }): void;
const x = {
m: true
};
// Should be OK
checkTruths(x);
// Should be OK
checkM(x);
console.log(x.z);
// Should be OK under --noUncheckedIndexedAccess
const m: boolean = x.m;
// Should be 'm'
type M = keyof typeof x;
// Should be able to detect a failure here
const x2 = {
m: true,
s: "false"
} satisfies Facts;
@@ -0,0 +1,8 @@
export type Color = { r: number, g: number, b: number };
// All of these should be Colors, but I only use some of them here.
export const Palette = {
white: { r: 255, g: 255, b: 255 },
black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b'
blue: { r: 0, g: 0, b: 255 },
} satisfies Record<string, Color>;
@@ -0,0 +1,2 @@
const a: "baz" = "foo" satisfies "foo" | "bar";
const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };

Some files were not shown because too many files have changed in this diff Show More