diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0999b8b4eb030..321592bcd44bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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: diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e1f62fe842b32..2656c48383cb1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d3008431abe2e..4e571c49a8c8c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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("."); diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 399dfd9d64640..f072083e15401 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -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(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(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: diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index 903dea149a191..f44c91364081a 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -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; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 9fbbdb165d22b..7cb707a90a53f 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -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; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 93939b6f4f2d1..faab2b0620326 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -393,6 +393,9 @@ namespace ts { [SyntaxKind.NonNullExpression]: function forEachChildInNonNullExpression(node: NonNullExpression, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined { return visitNode(cbNode, node.expression); }, + [SyntaxKind.SatisfiesExpression]: function forEachChildInSatisfiesExpression(node: SatisfiesExpression, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined { + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); + }, [SyntaxKind.MetaProperty]: function forEachChildInMetaProperty(node: MetaProperty, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray) => 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>)[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); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e7c0f363ea8df..2c71fde33d302 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -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. } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 107ff3a143efa..05ae6268d7153 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -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, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 61b982d7f2916..0f2725559067b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -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, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 73fefe7637525..31bdb48f757ab 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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 diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 62a941df1f79f..c2ff0ab4fc7b0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -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; } diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 229620a1191b9..bc80f301e3ff8 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1642,6 +1642,7 @@ namespace ts { case SyntaxKind.OmittedExpression: case SyntaxKind.CommaListExpression: case SyntaxKind.PartiallyEmittedExpression: + case SyntaxKind.SatisfiesExpression: return true; default: return isUnaryExpressionKind(kind); diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 29a112b062294..02eeee55ad72f 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -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, diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 93508a079ab5a..c43b8f0bc4cdd 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -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", diff --git a/src/services/callHierarchy.ts b/src/services/callHierarchy.ts index 1cbe4e58ada82..5219698a4450c 100644 --- a/src/services/callHierarchy.ts +++ b/src/services/callHierarchy.ts @@ -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)) { diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 1b6705efed820..ac15be962ab47 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -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: diff --git a/src/services/completions.ts b/src/services/completions.ts index bcc6efca67577..36724b760a966 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -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); } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 76cd5aa6e4f8e..144f97831bb17 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -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]]) diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index a6c67a17ee186..ced86a57713c4 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -143,6 +143,8 @@ namespace Harness { "exactOptionalPropertyTypes", "useDefineForClassFields", "useUnknownInCatchVariables", + "noUncheckedIndexedAccess", + "noPropertyAccessFromIndexSignature", ]; private fileName: string; private justName: string; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 89e52380ac983..e377bbec1710a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -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; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1a135d9fcba4a..857e3398c4c23 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -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; diff --git a/tests/baselines/reference/completionsCommentsClass.baseline b/tests/baselines/reference/completionsCommentsClass.baseline index 5dce64b756ea7..7c01a94bdee8b 100644 --- a/tests/baselines/reference/completionsCommentsClass.baseline +++ b/tests/baselines/reference/completionsCommentsClass.baseline @@ -3115,6 +3115,18 @@ } ] }, + { + "name": "satisfies", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "satisfies", + "kind": "keyword" + } + ] + }, { "name": "string", "kind": "keyword", diff --git a/tests/baselines/reference/completionsCommentsClassMembers.baseline b/tests/baselines/reference/completionsCommentsClassMembers.baseline index c09142c2a916f..aae31c8f975de 100644 --- a/tests/baselines/reference/completionsCommentsClassMembers.baseline +++ b/tests/baselines/reference/completionsCommentsClassMembers.baseline @@ -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", diff --git a/tests/baselines/reference/completionsCommentsCommentParsing.baseline b/tests/baselines/reference/completionsCommentsCommentParsing.baseline index 99a71cece8017..1622a0c8f39b2 100644 --- a/tests/baselines/reference/completionsCommentsCommentParsing.baseline +++ b/tests/baselines/reference/completionsCommentsCommentParsing.baseline @@ -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", diff --git a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline index 4e3bcb801455d..0cd4ca2b6398e 100644 --- a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline @@ -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", diff --git a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline index 4fac96f0abb80..5e5e0b5e1d905 100644 --- a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline @@ -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", diff --git a/tests/baselines/reference/constructorNameInGenerator.errors.txt b/tests/baselines/reference/constructorNameInGenerator.errors.txt index 061560615fb0c..493f79bd4a9a7 100644 --- a/tests/baselines/reference/constructorNameInGenerator.errors.txt +++ b/tests/baselines/reference/constructorNameInGenerator.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/tsserver/moduleSpecifierCache/invalidates-module-specifiers-when-changes-happen-in-contained-node_modules-directories.js b/tests/baselines/reference/tsserver/moduleSpecifierCache/invalidates-module-specifiers-when-changes-happen-in-contained-node_modules-directories.js index a5365671bef02..0980d5d06cb46 100644 --- a/tests/baselines/reference/tsserver/moduleSpecifierCache/invalidates-module-specifiers-when-changes-happen-in-contained-node_modules-directories.js +++ b/tests/baselines/reference/tsserver/moduleSpecifierCache/invalidates-module-specifiers-when-changes-happen-in-contained-node_modules-directories.js @@ -128,7 +128,7 @@ collectAutoImports: response is incomplete collectAutoImports: * getCompletionData: Semantic work: * getCompletionsAtPosition: getCompletionEntriesFromSymbols: * -response:{"response":{"flags":1,"isGlobalCompletion":true,"isMemberCompletion":false,"isNewIdentifierLocation":false,"optionalReplacementSpan":{"start":{"line":1,"offset":1},"end":{"line":1,"offset":4}},"entries":[{"name":"abstract","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"any","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"as","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"asserts","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"async","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"await","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"bigint","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"boolean","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"break","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"case","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"catch","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"class","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"const","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"continue","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"debugger","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"declare","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"default","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"delete","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"do","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"else","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"enum","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"export","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"extends","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"false","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"finally","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"for","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"function","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"globalThis","kind":"module","kindModifiers":"","sortText":"15"},{"name":"if","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"implements","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"import","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"in","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"infer","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"instanceof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"interface","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"keyof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"let","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"module","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"namespace","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"never","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"new","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"null","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"number","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"object","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"package","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"readonly","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"return","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"string","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"super","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"switch","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"symbol","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"this","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"throw","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"true","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"try","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"type","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"typeof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"undefined","kind":"var","kindModifiers":"","sortText":"15"},{"name":"unique","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"unknown","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"var","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"void","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"while","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"with","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"yield","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"foo","kind":"const","kindModifiers":"export","sortText":"16","hasAction":true,"source":"/src/a","data":{"exportName":"foo","exportMapKey":"foo|*|","fileName":"/src/a.ts"}}]},"responseRequired":true} +response:{"response":{"flags":1,"isGlobalCompletion":true,"isMemberCompletion":false,"isNewIdentifierLocation":false,"optionalReplacementSpan":{"start":{"line":1,"offset":1},"end":{"line":1,"offset":4}},"entries":[{"name":"abstract","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"any","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"as","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"asserts","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"async","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"await","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"bigint","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"boolean","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"break","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"case","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"catch","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"class","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"const","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"continue","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"debugger","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"declare","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"default","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"delete","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"do","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"else","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"enum","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"export","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"extends","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"false","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"finally","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"for","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"function","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"globalThis","kind":"module","kindModifiers":"","sortText":"15"},{"name":"if","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"implements","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"import","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"in","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"infer","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"instanceof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"interface","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"keyof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"let","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"module","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"namespace","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"never","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"new","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"null","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"number","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"object","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"package","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"readonly","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"return","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"satisfies","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"string","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"super","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"switch","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"symbol","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"this","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"throw","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"true","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"try","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"type","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"typeof","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"undefined","kind":"var","kindModifiers":"","sortText":"15"},{"name":"unique","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"unknown","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"var","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"void","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"while","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"with","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"yield","kind":"keyword","kindModifiers":"","sortText":"15"},{"name":"foo","kind":"const","kindModifiers":"export","sortText":"16","hasAction":true,"source":"/src/a","data":{"exportName":"foo","exportMapKey":"foo|*|","fileName":"/src/a.ts"}}]},"responseRequired":true} request:{"seq":0,"type":"request","command":"completionInfo","arguments":{"file":"/src/c.ts","line":1,"offset":8}} getCompletionData: Get current token: * getCompletionData: Is inside comment: * diff --git a/tests/baselines/reference/typeSatisfaction.errors.txt b/tests/baselines/reference/typeSatisfaction.errors.txt new file mode 100644 index 0000000000000..c4b51c47684ac --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction.errors.txt @@ -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'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction.js b/tests/baselines/reference/typeSatisfaction.js new file mode 100644 index 0000000000000..646ac82d2b3c4 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction.js @@ -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' }; diff --git a/tests/baselines/reference/typeSatisfaction.symbols b/tests/baselines/reference/typeSatisfaction.symbols new file mode 100644 index 0000000000000..fb1f272825c7b --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction.symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction.types b/tests/baselines/reference/typeSatisfaction.types new file mode 100644 index 0000000000000..1addf9346e217 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction.types @@ -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" + diff --git a/tests/baselines/reference/typeSatisfactionWithDefaultExport.errors.txt b/tests/baselines/reference/typeSatisfactionWithDefaultExport.errors.txt new file mode 100644 index 0000000000000..f960726de5da9 --- /dev/null +++ b/tests/baselines/reference/typeSatisfactionWithDefaultExport.errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfactionWithDefaultExport.js b/tests/baselines/reference/typeSatisfactionWithDefaultExport.js new file mode 100644 index 0000000000000..ba29570420701 --- /dev/null +++ b/tests/baselines/reference/typeSatisfactionWithDefaultExport.js @@ -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 }; diff --git a/tests/baselines/reference/typeSatisfactionWithDefaultExport.symbols b/tests/baselines/reference/typeSatisfactionWithDefaultExport.symbols new file mode 100644 index 0000000000000..135876487d71f --- /dev/null +++ b/tests/baselines/reference/typeSatisfactionWithDefaultExport.symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfactionWithDefaultExport.types b/tests/baselines/reference/typeSatisfactionWithDefaultExport.types new file mode 100644 index 0000000000000..6f281cea3c955 --- /dev/null +++ b/tests/baselines/reference/typeSatisfactionWithDefaultExport.types @@ -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 + diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping1.js b/tests/baselines/reference/typeSatisfaction_contextualTyping1.js new file mode 100644 index 0000000000000..e8b5cd7246e0d --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping1.js @@ -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; } +}; diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping1.symbols b/tests/baselines/reference/typeSatisfaction_contextualTyping1.symbols new file mode 100644 index 0000000000000..0b44d64dd6ea4 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping1.symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping1.types b/tests/baselines/reference/typeSatisfaction_contextualTyping1.types new file mode 100644 index 0000000000000..31e193b6f98ba --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping1.types @@ -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; + diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping2.errors.txt b/tests/baselines/reference/typeSatisfaction_contextualTyping2.errors.txt new file mode 100644 index 0000000000000..2014bb3930a1a --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping2.errors.txt @@ -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 = { + f(s) { }, // "incorrect" implicit any on 's' + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. + g(s) { } + } satisfies { g(s: string): void } & Record; + + // This needs to not crash (outer node is not expression) + ({ f(x) { } }) satisfies { f(s: string): void }; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping2.js b/tests/baselines/reference/typeSatisfaction_contextualTyping2.js new file mode 100644 index 0000000000000..a8c0bb41ece47 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping2.js @@ -0,0 +1,18 @@ +//// [typeSatisfaction_contextualTyping2.ts] +let obj: { f(s: string): void } & Record = { + f(s) { }, // "incorrect" implicit any on 's' + g(s) { } +} satisfies { g(s: string): void } & Record; + +// 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) { } }); diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping2.symbols b/tests/baselines/reference/typeSatisfaction_contextualTyping2.symbols new file mode 100644 index 0000000000000..d7bda841fb6d7 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping2.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts === +let obj: { f(s: string): void } & Record = { +>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; +>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)) + diff --git a/tests/baselines/reference/typeSatisfaction_contextualTyping2.types b/tests/baselines/reference/typeSatisfaction_contextualTyping2.types new file mode 100644 index 0000000000000..a23bf1ee8d80f --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_contextualTyping2.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts === +let obj: { f(s: string): void } & Record = { +>obj : { f(s: string): void; } & Record +>f : (s: string) => void +>s : string +>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} satisfies { g(s: string): void } & Record : { 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; +>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 + diff --git a/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.js b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.js new file mode 100644 index 0000000000000..e33ac953b454a --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.js @@ -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; + + +//// [typeSatisfaction_ensureInterfaceImpl.js] +var car = { + start: function () { }, + move: function (d) { + // d should be number + }, + stop: function () { } +}; diff --git a/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.symbols b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.symbols new file mode 100644 index 0000000000000..afcab39149964 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.symbols @@ -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; +>Movable : Symbol(Movable, Decl(typeSatisfaction_ensureInterfaceImpl.ts, 0, 0)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.types b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.types new file mode 100644 index 0000000000000..6c839be872fc7 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_ensureInterfaceImpl.types @@ -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 : { 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; + diff --git a/tests/baselines/reference/typeSatisfaction_js.errors.txt b/tests/baselines/reference/typeSatisfaction_js.errors.txt new file mode 100644 index 0000000000000..0858b35c7e426 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_js.errors.txt @@ -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. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_js.js b/tests/baselines/reference/typeSatisfaction_js.js new file mode 100644 index 0000000000000..3d28ea0e2675d --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_js.js @@ -0,0 +1,6 @@ +//// [a.js] +var v = undefined satisfies 1; + + +//// [a.js] +var v = undefined; diff --git a/tests/baselines/reference/typeSatisfaction_js.symbols b/tests/baselines/reference/typeSatisfaction_js.symbols new file mode 100644 index 0000000000000..e5424113f5b8b --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_js.symbols @@ -0,0 +1,5 @@ +=== /src/a.js === +var v = undefined satisfies 1; +>v : Symbol(v, Decl(a.js, 0, 3)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/typeSatisfaction_js.types b/tests/baselines/reference/typeSatisfaction_js.types new file mode 100644 index 0000000000000..dde08ce298036 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_js.types @@ -0,0 +1,6 @@ +=== /src/a.js === +var v = undefined satisfies 1; +>v : any +>undefined satisfies 1 : undefined +>undefined : undefined + diff --git a/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.errors.txt b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.errors.txt new file mode 100644 index 0000000000000..c45de3250dcd0 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.errors.txt @@ -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; + // Should OK + console.log(a.x.toFixed()); + // Should error + let p = a.y; + ~ +!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.js b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.js new file mode 100644 index 0000000000000..d21648cfb19f9 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.js @@ -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; +// 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; diff --git a/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.symbols b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.symbols new file mode 100644 index 0000000000000..d1f6bbc0470d2 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.symbols @@ -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; +>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)) + diff --git a/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.types b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.types new file mode 100644 index 0000000000000..50d2c335ea3c7 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_optionalMemberConformance.types @@ -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; +>a : { x: number; } +>{ x: 10 } satisfies Partial : { 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 + diff --git a/tests/baselines/reference/typeSatisfaction_propNameConstraining.errors.txt b/tests/baselines/reference/typeSatisfaction_propNameConstraining.errors.txt new file mode 100644 index 0000000000000..a0162567a7f91 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propNameConstraining.errors.txt @@ -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>'. + Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. +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>'. +!!! error TS1360: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. + } satisfies Partial>; + + // 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; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propNameConstraining.js b/tests/baselines/reference/typeSatisfaction_propNameConstraining.js new file mode 100644 index 0000000000000..64490c480a682 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propNameConstraining.js @@ -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>; + +// 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; diff --git a/tests/baselines/reference/typeSatisfaction_propNameConstraining.symbols b/tests/baselines/reference/typeSatisfaction_propNameConstraining.symbols new file mode 100644 index 0000000000000..d846ceda53396 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propNameConstraining.symbols @@ -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>; +>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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propNameConstraining.types b/tests/baselines/reference/typeSatisfaction_propNameConstraining.types new file mode 100644 index 0000000000000..f97f675c9dfb8 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propNameConstraining.types @@ -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> : { 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>; + +// 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 + diff --git a/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.errors.txt b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.errors.txt new file mode 100644 index 0000000000000..dbcb6fd41950c --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.errors.txt @@ -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'. + Object literal may only specify known properties, and 'x' does not exist in type 'Record'. +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'. +!!! error TS1360: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. + } satisfies Record; + + // 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; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.js b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.js new file mode 100644 index 0000000000000..1bea49e03def3 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.js @@ -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; + +// 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; diff --git a/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.symbols b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.symbols new file mode 100644 index 0000000000000..824fa99634540 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.symbols @@ -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; +>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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.types b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.types new file mode 100644 index 0000000000000..09c2c4300edd5 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyNameFulfillment.types @@ -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 : { 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; + +// 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 + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).errors.txt b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).errors.txt new file mode 100644 index 0000000000000..fd603a7727578 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).js b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).js new file mode 100644 index 0000000000000..f0afe57b996ee --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).js @@ -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" +}; diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).symbols b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).symbols new file mode 100644 index 0000000000000..640357f878186 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).types b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).types new file mode 100644 index 0000000000000..28aefdb9c6f24 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=false).types @@ -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; + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).errors.txt b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).errors.txt new file mode 100644 index 0000000000000..fd603a7727578 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).js b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).js new file mode 100644 index 0000000000000..f0afe57b996ee --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).js @@ -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" +}; diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).symbols b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).symbols new file mode 100644 index 0000000000000..640357f878186 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).types b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).types new file mode 100644 index 0000000000000..28aefdb9c6f24 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance1(nopropertyaccessfromindexsignature=true).types @@ -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; + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).errors.txt b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).errors.txt new file mode 100644 index 0000000000000..57f58d646f60e --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).js b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).js new file mode 100644 index 0000000000000..450bf97193f95 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).js @@ -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" +}; diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).symbols b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).symbols new file mode 100644 index 0000000000000..d2526bf40f2df --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).types b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).types new file mode 100644 index 0000000000000..532ee99a6d9c5 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=false).types @@ -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; + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).errors.txt b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).errors.txt new file mode 100644 index 0000000000000..57f58d646f60e --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).js b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).js new file mode 100644 index 0000000000000..450bf97193f95 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).js @@ -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" +}; diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).symbols b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).symbols new file mode 100644 index 0000000000000..d2526bf40f2df --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).types b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).types new file mode 100644 index 0000000000000..532ee99a6d9c5 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance2(nouncheckedindexedaccess=true).types @@ -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; + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.errors.txt b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.errors.txt new file mode 100644 index 0000000000000..0ae5d8fffb313 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.js b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.js new file mode 100644 index 0000000000000..c8c885e74e365 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.js @@ -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; + + +//// [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 } +}; diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.symbols b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.symbols new file mode 100644 index 0000000000000..4cbc5cf907540 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.symbols @@ -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; +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Color : Symbol(Color, Decl(typeSatisfaction_propertyValueConformance3.ts, 0, 0)) + diff --git a/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.types b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.types new file mode 100644 index 0000000000000..cbcec4aedc805 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_propertyValueConformance3.types @@ -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 : { 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; + diff --git a/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.errors.txt b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.errors.txt new file mode 100644 index 0000000000000..5145035e8159f --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.errors.txt @@ -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"'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.js b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.js new file mode 100644 index 0000000000000..65d5dc56a40a1 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.js @@ -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" }; diff --git a/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.symbols b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.symbols new file mode 100644 index 0000000000000..e42d85f578765 --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.symbols @@ -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)) + diff --git a/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.types b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.types new file mode 100644 index 0000000000000..5b574cf380eda --- /dev/null +++ b/tests/baselines/reference/typeSatisfaction_vacuousIntersectionOfContextualTypes.types @@ -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" + diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts new file mode 100644 index 0000000000000..5e268ffb1e1cc --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfactionWithDefaultExport.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfactionWithDefaultExport.ts new file mode 100644 index 0000000000000..247accb875863 --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfactionWithDefaultExport.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping1.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping1.ts new file mode 100644 index 0000000000000..d099059d8545f --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping1.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts new file mode 100644 index 0000000000000..597a1eed2bdbd --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts @@ -0,0 +1,9 @@ +// @strict: true + +let obj: { f(s: string): void } & Record = { + f(s) { }, // "incorrect" implicit any on 's' + g(s) { } +} satisfies { g(s: string): void } & Record; + +// This needs to not crash (outer node is not expression) +({ f(x) { } }) satisfies { f(s: string): void }; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_ensureInterfaceImpl.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_ensureInterfaceImpl.ts new file mode 100644 index 0000000000000..a3dbaf484a8ae --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_ensureInterfaceImpl.ts @@ -0,0 +1,11 @@ +type Movable = { + move(distance: number): void; +}; + +const car = { + start() { }, + move(d) { + // d should be number + }, + stop() { } +} satisfies Movable & Record; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_js.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_js.ts new file mode 100644 index 0000000000000..5826e4a20971d --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_js.ts @@ -0,0 +1,5 @@ +// @allowJs: true +// @filename: /src/a.js +// @out: /lib/a.js + +var v = undefined satisfies 1; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts new file mode 100644 index 0000000000000..939c6fc60a688 --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_optionalMemberConformance.ts @@ -0,0 +1,7 @@ +type Point2d = { x: number, y: number }; +// Undesirable behavior today with type annotation +const a = { x: 10 } satisfies Partial; +// Should OK +console.log(a.x.toFixed()); +// Should error +let p = a.y; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts new file mode 100644 index 0000000000000..4745de6e77dcb --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propNameConstraining.ts @@ -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>; + +// 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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts new file mode 100644 index 0000000000000..e344bcfbff24d --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyNameFulfillment.ts @@ -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; + +// 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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts new file mode 100644 index 0000000000000..62a51f2ac7102 --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance1.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts new file mode 100644 index 0000000000000..762a9b0f4e786 --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance2.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts new file mode 100644 index 0000000000000..178da1c2c438a --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_propertyValueConformance3.ts @@ -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; diff --git a/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts new file mode 100644 index 0000000000000..92af1c521b207 --- /dev/null +++ b/tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts @@ -0,0 +1,2 @@ +const a: "baz" = "foo" satisfies "foo" | "bar"; +const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" }; diff --git a/tests/cases/fourslash/completionSatisfiesKeyword.ts b/tests/cases/fourslash/completionSatisfiesKeyword.ts new file mode 100644 index 0000000000000..c44ca016c3f6f --- /dev/null +++ b/tests/cases/fourslash/completionSatisfiesKeyword.ts @@ -0,0 +1,11 @@ +/// + +////const x = { a: 1 } /*1*/ +////function foo() { +//// const x = { a: 1 } /*2*/ +////} + +verify.completions({ + marker: ["1", "2"], + includes: [{ name: "satisfies", sortText: completion.SortText.GlobalsOrKeywords }] +}); diff --git a/tests/cases/fourslash/satisfiesOperatorCompletion.ts b/tests/cases/fourslash/satisfiesOperatorCompletion.ts new file mode 100644 index 0000000000000..94b07db40da32 --- /dev/null +++ b/tests/cases/fourslash/satisfiesOperatorCompletion.ts @@ -0,0 +1,7 @@ +/// + +//// type T = number; +//// var x; +//// var y = x satisfies /**/ + +verify.completions({ marker: "", includes: "T" });