diff --git a/package-lock.json b/package-lock.json index 1e7fd508fb0..e9223981c56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -224,7 +224,7 @@ "@gulp-sourcemaps/map-sources": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", - "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", + "integrity": "sha512-o/EatdaGt8+x2qpb0vFLC/2Gug/xYPRXb6a+ET1wGYKozKN3krDWC/zZFZAtrzxJHuDL12mwdfEFKcKMNvc55A==", "dev": true, "requires": { "normalize-path": "^2.0.1", @@ -638,9 +638,9 @@ "dev": true }, "@types/node": { - "version": "17.0.32", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz", - "integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw==", + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz", + "integrity": "sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ==", "dev": true }, "@types/node-fetch": { @@ -951,7 +951,7 @@ "ansi-cyan": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", - "integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=", + "integrity": "sha512-eCjan3AVo/SxZ0/MyIYRtkpxIu/H3xZN7URr1vXVrISxeyz8fUFz0FJziamK4sS8I+t35y4rHg1b2PklyBe/7A==", "dev": true, "requires": { "ansi-wrap": "0.1.0" @@ -969,7 +969,7 @@ "ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", - "integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=", + "integrity": "sha512-ewaIr5y+9CUTGFwZfpECUbFlGcC0GCw1oqR9RI6h1gQCd9Aj2GxSckCnPsVJnmfMZbwFYE+leZGASgkWl06Jow==", "dev": true, "requires": { "ansi-wrap": "0.1.0" @@ -3151,17 +3151,16 @@ "dev": true }, "glob": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.1.tgz", - "integrity": "sha512-cF7FYZZ47YzmCu7dDy50xSRRfO3ErRfrXuLZcNIuyiJEco0XSrGtuilG19L5xp3NcwTx7Gn+X6Tv3fmsUPTbow==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "once": "^1.3.0" }, "dependencies": { "brace-expansion": { @@ -3447,18 +3446,27 @@ }, "dependencies": { "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } } } }, @@ -5162,7 +5170,7 @@ "arr-diff": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz", - "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", + "integrity": "sha512-OQwDZUqYaQwyyhDJHThmzId8daf4/RFNLaeh3AevmSeZ5Y7ug4Ga/yKc6l6kTZOBW781rCj103ZuTh8GAsB3+Q==", "dev": true, "requires": { "arr-flatten": "^1.0.1", @@ -5172,13 +5180,13 @@ "arr-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz", - "integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=", + "integrity": "sha512-t5db90jq+qdgk8aFnxEkjqta0B/GHrM1pxzuuZz2zWsOXc5nKu3t+76s/PQBA8FTcM/ipspIH9jWG4OxCBc2eA==", "dev": true }, "array-slice": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", + "integrity": "sha512-rlVfZW/1Ph2SNySXwR9QYkChp8EkOEiTMO5Vwx60usw04i4nWemkm9RXmQqgkQFaLHsqLuADvjp6IfgL9l2M8Q==", "dev": true }, "extend-shallow": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 025eeecc306..2e2c75eb384 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4110,8 +4110,10 @@ namespace ts { return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 && symbol.exportSymbol || symbol); } - function symbolIsValue(symbol: Symbol): boolean { - return !!(symbol.flags & SymbolFlags.Value || symbol.flags & SymbolFlags.Alias && resolveAlias(symbol).flags & SymbolFlags.Value && !getTypeOnlyAliasDeclaration(symbol)); + function symbolIsValue(symbol: Symbol, includeTypeOnlyMembers?: boolean): boolean { + return !!( + symbol.flags & SymbolFlags.Value || + symbol.flags & SymbolFlags.Alias && resolveAlias(symbol).flags & SymbolFlags.Value && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node: ClassLikeDeclaration): ConstructorDeclaration | undefined { @@ -12296,9 +12298,9 @@ namespace ts { t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType) : t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : - t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) : + t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType() : t.flags & TypeFlags.BooleanLike ? globalBooleanType : - t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : + t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType() : t.flags & TypeFlags.NonPrimitive ? emptyObjectType : t.flags & TypeFlags.Index ? keyofConstraintType : t.flags & TypeFlags.Unknown && !strictNullChecks ? emptyObjectType : @@ -12575,12 +12577,12 @@ namespace ts { * @param type a type to look up property from * @param name a name of property to look up in a given type */ - function getPropertyOfType(type: Type, name: __String, skipObjectFunctionPropertyAugment?: boolean): Symbol | undefined { + function getPropertyOfType(type: Type, name: __String, skipObjectFunctionPropertyAugment?: boolean, includeTypeOnlyMembers?: boolean): Symbol | undefined { type = getReducedApparentType(type); if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type as ObjectType); const symbol = resolved.members.get(name); - if (symbol && symbolIsValue(symbol)) { + if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { return symbol; } if (skipObjectFunctionPropertyAugment) return undefined; @@ -14024,8 +14026,8 @@ namespace ts { return deferredGlobalESSymbolConstructorTypeSymbol ||= getGlobalTypeSymbol("SymbolConstructor" as __String, reportErrors); } - function getGlobalESSymbolType(reportErrors: boolean) { - return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; + function getGlobalESSymbolType() { + return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType; } function getGlobalPromiseType(reportErrors: boolean) { @@ -14107,8 +14109,8 @@ namespace ts { return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol; } - function getGlobalBigIntType(reportErrors: boolean) { - return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; + function getGlobalBigIntType() { + return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType; } /** @@ -16208,7 +16210,7 @@ namespace ts { // the `exports` lookup process that only looks up namespace members which is used for most type references const mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); const next = node.isTypeOf - ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText) + ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); if (!next) { error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); @@ -18551,7 +18553,7 @@ namespace ts { if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) { + (getGlobalESSymbolType() === source && esSymbolType === target)) { reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -28995,9 +28997,9 @@ namespace ts { if (isIdentifier(left) && parentSymbol) { markAliasReferenced(parentSymbol, node); } - return isErrorType(apparentType) ? errorType : apparentType;; + return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === SyntaxKind.QualifiedName); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -33975,6 +33977,10 @@ namespace ts { case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: case SyntaxKind.ExclamationEqualsEqualsToken: + if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) { + const eqType = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.EqualsEqualsEqualsToken; + error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); + } reportOperatorErrorUnless((left, right) => isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left)); return booleanType; @@ -35383,6 +35389,10 @@ namespace ts { // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); + if (isMethodDeclaration(node) && node.asteriskToken && isIdentifier(node.name) && idText(node.name) === "constructor") { + error(node.name, Diagnostics.Class_constructor_may_not_be_a_generator); + } + // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); @@ -35535,6 +35545,9 @@ namespace ts { } function checkAccessorDeclaration(node: AccessorDeclaration) { + if (isIdentifier(node.name) && idText(node.name) === "constructor") { + error(node.name, Diagnostics.Class_constructor_may_not_be_an_accessor); + } addLazyDiagnostic(checkAccessorDeclarationDiagnostics); checkSourceElement(node.body); setNodeLinksForPrivateIdentifierScope(node); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fa6b9fd3efc..e7f5454e435 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -435,6 +435,10 @@ "category": "Error", "code": 1144 }, + "'{' or JSX element expected.": { + "category": "Error", + "code": 1145 + }, "Declaration expected.": { "category": "Error", "code": 1146 @@ -1016,6 +1020,10 @@ "category": "Error", "code": 1340 }, + "Class constructor may not be an accessor.": { + "category": "Error", + "code": 1341 + }, "Type arguments cannot be used here.": { "category": "Error", "code": 1342 @@ -1088,6 +1096,10 @@ "category": "Error", "code": 1359 }, + "Class constructor may not be a generator.": { + "category": "Error", + "code": 1360 + }, "'{0}' cannot be used as a value because it was imported using 'import type'.": { "category": "Error", "code": 1361 @@ -3455,6 +3467,10 @@ "category": "Error", "code": 2838 }, + "This condition will always return '{0}' since JavaScript compares objects by reference, not value.": { + "category": "Error", + "code": 2839 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 9028c521a13..4d171a842c2 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -4964,7 +4964,7 @@ namespace ts { } // @api - function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined) { + function createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined) { const node = createBaseNode(SyntaxKind.JsxAttribute); node.name = name; node.initializer = initializer; @@ -4976,7 +4976,7 @@ namespace ts { } // @api - function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) { + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) { return node.name !== name || node.initializer !== initializer ? update(createJsxAttribute(name, initializer), node) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 755c583b718..1b502dfc22f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5454,15 +5454,23 @@ namespace ts { scanJsxIdentifier(); const pos = getNodePos(); - return finishNode( - factory.createJsxAttribute( - parseIdentifierName(), - token() !== SyntaxKind.EqualsToken ? undefined : - scanJsxAttributeValue() === SyntaxKind.StringLiteral ? parseLiteralNode() as StringLiteral : - parseJsxExpression(/*inExpressionContext*/ true) - ), - pos - ); + return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); + } + + function parseJsxAttributeValue(): JsxAttributeValue | undefined { + if (token() === SyntaxKind.EqualsToken) { + if (scanJsxAttributeValue() === SyntaxKind.StringLiteral) { + return parseLiteralNode() as StringLiteral; + } + if (token() === SyntaxKind.OpenBraceToken) { + return parseJsxExpression(/*inExpressionContext*/ true); + } + if (token() === SyntaxKind.LessThanToken) { + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); + } + parseErrorAtCurrentToken(Diagnostics.or_JSX_element_expected); + } + return undefined; } function parseJsxSpreadAttribute(): JsxSpreadAttribute { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 8ab1cd7d1ca..48743e93034 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -966,6 +966,8 @@ namespace ts { Diagnostics.extends_clause_already_seen.code, Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code, + Diagnostics.Class_constructor_may_not_be_a_generator.code, + Diagnostics.Class_constructor_may_not_be_an_accessor.code, ]); /** diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index d321e74817b..2e6fe4ea1b9 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -400,26 +400,33 @@ namespace ts { return factory.createPropertyAssignment(name, expression); } - function transformJsxAttributeInitializer(node: StringLiteral | JsxExpression | undefined): Expression { + function transformJsxAttributeInitializer(node: JsxAttributeValue | undefined): Expression { if (node === undefined) { return factory.createTrue(); } - else if (node.kind === SyntaxKind.StringLiteral) { + if (node.kind === SyntaxKind.StringLiteral) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string const singleQuote = node.singleQuote !== undefined ? node.singleQuote : !isStringDoubleQuoted(node, currentSourceFile); const literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return setTextRange(literal, node); } - else if (node.kind === SyntaxKind.JsxExpression) { + if (node.kind === SyntaxKind.JsxExpression) { if (node.expression === undefined) { return factory.createTrue(); } return visitNode(node.expression, visitor, isExpression); } - else { - return Debug.failBadSyntaxKind(node); + if (isJsxElement(node)) { + return visitJsxElement(node, /*isChild*/ false); } + if (isJsxSelfClosingElement(node)) { + return visitJsxSelfClosingElement(node, /*isChild*/ false); + } + if (isJsxFragment(node)) { + return visitJsxFragment(node, /*isChild*/ false); + } + return Debug.failBadSyntaxKind(node); } function visitJsxText(node: JsxText): StringLiteral | undefined { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 717f8029178..db071689cd3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2612,9 +2612,16 @@ namespace ts { readonly parent: JsxAttributes; readonly name: Identifier; /// JSX attribute initializers are optional; is sugar for - readonly initializer?: StringLiteral | JsxExpression; + readonly initializer?: JsxAttributeValue; } + export type JsxAttributeValue = + | StringLiteral + | JsxExpression + | JsxElement + | JsxSelfClosingElement + | JsxFragment; + export interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; readonly parent: JsxAttributes; @@ -7680,8 +7687,8 @@ namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 2f4ed3b14cc..4eca9fefba2 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1114,6 +1114,19 @@ namespace ts { return isLiteralKind(node.kind); } + /** @internal */ + export function isLiteralExpressionOfObject(node: Node) { + switch (node.kind) { + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ClassExpression: + return true; + } + return false; + } + // Pseudo-literals /* @internal */ diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index c925046d67a..7d2c6818d33 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -513,6 +513,13 @@ namespace ts { ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", PackageJson: "package.json file", + ClosedScriptInfo: "Closed Script info", + ConfigFileForInferredRoot: "Config file for the inferred project root", + NodeModules: "node_modules for closed script infos and package.jsons affecting module specifier cache", + MissingSourceMapFile: "Missing source map file", + NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root", + MissingGeneratedFile: "Missing generated file", + NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation", }; export interface WatchTypeRegistry { @@ -527,6 +534,15 @@ namespace ts { ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", PackageJson: "package.json file", + + // Additional tsserver specific watch information + ClosedScriptInfo: "Closed Script info", + ConfigFileForInferredRoot: "Config file for the inferred project root", + NodeModules: "node_modules for closed script infos and package.jsons affecting module specifier cache", + MissingSourceMapFile: "Missing source map file", + NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root", + MissingGeneratedFile: "Missing generated file", + NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation", } interface WatchFactory extends ts.WatchFactory { diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8ef252de28c..758e90ecbf4 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3519,6 +3519,24 @@ + + + + + + + + + + + + + + + + + + @@ -8325,6 +8343,15 @@ + + + + + + + + + @@ -11115,6 +11142,15 @@ + + + + + + + + + @@ -13470,6 +13506,15 @@ + + + + + + + + + @@ -16404,6 +16449,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 19804537abd..abdf614f728 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8325,6 +8325,15 @@ + + + + + + + + + @@ -11115,6 +11124,15 @@ + + + + + + + + + @@ -16404,6 +16422,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 50cd9671cba..f23153e6d0d 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3528,6 +3528,24 @@ + + + + + + + + + + + + + + + + + + @@ -8334,6 +8352,15 @@ + + + + + + + + + @@ -13488,6 +13515,15 @@ + + + + + + + + + @@ -16422,6 +16458,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 88b3dc55306..09fb7d60d33 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8322,6 +8322,15 @@ + + + + + + + + + @@ -16407,6 +16416,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index e7aea94a458..4de3f85619d 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3531,6 +3531,24 @@ + + + + + + + + + + + + + + + + + + @@ -8337,6 +8355,15 @@ + + + + + + + + + @@ -13491,6 +13518,15 @@ + + + + + + + + + @@ -16425,6 +16461,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 10636017b21..2e741c3cf17 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3531,6 +3531,24 @@ + + + + + + + + + + + + + + + + + + @@ -8337,6 +8355,15 @@ + + + + + + + + + @@ -11127,6 +11154,15 @@ + + + + + + + + + @@ -13482,6 +13518,15 @@ + + + + + + + + + @@ -16416,6 +16461,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 71ae5fca880..8b0ef6d59c3 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8325,6 +8325,15 @@ + + + + + + + + + @@ -16413,6 +16422,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index fec7669b1c9..b726eda4716 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3519,6 +3519,24 @@ + + + + + + + + + + + + + + + + + + @@ -8325,6 +8343,15 @@ + + + + + + + + + @@ -13479,6 +13506,15 @@ + + + + + + + + + @@ -16413,6 +16449,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index f9dd5a79e33..7b67b250d52 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3519,6 +3519,24 @@ + + + + + + + + + + + + + + + + + + @@ -8325,6 +8343,15 @@ + + + + + + + + + @@ -13479,6 +13506,15 @@ + + + + + + + + + @@ -16413,6 +16449,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1d46dd5e3e2..d73a256e9bb 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8315,6 +8315,15 @@ + + + + + + + + + @@ -16400,6 +16409,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 509bab6694e..6f737dae47e 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3512,6 +3512,24 @@ + + + + + + + + + + + + + + + + + + @@ -8318,6 +8336,15 @@ + + + + + + + + + @@ -13469,6 +13496,15 @@ + + + + + + + + + @@ -16403,6 +16439,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index f57dcf78f02..e9e437101c7 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3518,6 +3518,24 @@ + + + + + + + + + + + + + + + + + + @@ -8324,6 +8342,15 @@ + + + + + + + + + @@ -13478,6 +13505,15 @@ + + + + + + + + + @@ -16412,6 +16448,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1641ebc6100..a90d048830d 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8318,6 +8318,15 @@ + + + + + + + + + @@ -11108,6 +11117,15 @@ + + + + + + + + + @@ -16397,6 +16415,15 @@ + + + + + + + + + diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index d25b6c1b1dd..0740910f933 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -18,7 +18,6 @@ "types.ts", "utilitiesPublic.ts", "utilities.ts", - "watchType.ts", "protocol.ts", "scriptInfo.ts", "typingsCache.ts", diff --git a/src/server/watchType.ts b/src/server/watchType.ts deleted file mode 100644 index 7893de0e26b..00000000000 --- a/src/server/watchType.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* @internal */ -namespace ts { - // Additional tsserver specific watch information - export interface WatchTypeRegistry { - ClosedScriptInfo: "Closed Script info", - ConfigFileForInferredRoot: "Config file for the inferred project root", - NodeModules: "node_modules for closed script infos and package.jsons affecting module specifier cache", - MissingSourceMapFile: "Missing source map file", - NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root", - MissingGeneratedFile: "Missing generated file", - NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation", - } - WatchType.ClosedScriptInfo = "Closed Script info"; - WatchType.ConfigFileForInferredRoot = "Config file for the inferred project root"; - WatchType.NodeModules = "node_modules for closed script infos and package.jsons affecting module specifier cache"; - WatchType.MissingSourceMapFile = "Missing source map file"; - WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root"; - WatchType.MissingGeneratedFile = "Missing generated file"; -} diff --git a/src/services/services.ts b/src/services/services.ts index afb6a108691..9ac9cf35400 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2880,7 +2880,7 @@ namespace ts { export function getDefaultLibFilePath(options: CompilerOptions): string { // Check __dirname is defined and that we are on a node.js system. if (typeof __dirname !== "undefined") { - return __dirname + directorySeparator + getDefaultLibFileName(options); + return combinePaths(__dirname, getDefaultLibFileName(options)); } throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index f2fbd2b0370..9bb0421d471 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1388,8 +1388,9 @@ declare namespace ts { readonly kind: SyntaxKind.JsxAttribute; readonly parent: JsxAttributes; readonly name: Identifier; - readonly initializer?: StringLiteral | JsxExpression; + readonly initializer?: JsxAttributeValue; } + export type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; export interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; readonly parent: JsxAttributes; @@ -3746,8 +3747,8 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; @@ -11370,9 +11371,9 @@ declare namespace ts { /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ const updateJsxFragment: (node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment) => JsxFragment; /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ - const createJsxAttribute: (name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const createJsxAttribute: (name: Identifier, initializer: JsxAttributeValue | undefined) => JsxAttribute; /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ - const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) => JsxAttribute; /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ const createJsxAttributes: (properties: readonly JsxAttributeLike[]) => JsxAttributes; /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index a1bde2444e7..2b3ffba10cb 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1388,8 +1388,9 @@ declare namespace ts { readonly kind: SyntaxKind.JsxAttribute; readonly parent: JsxAttributes; readonly name: Identifier; - readonly initializer?: StringLiteral | JsxExpression; + readonly initializer?: JsxAttributeValue; } + export type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; export interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; readonly parent: JsxAttributes; @@ -3746,8 +3747,8 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; @@ -7481,9 +7482,9 @@ declare namespace ts { /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ const updateJsxFragment: (node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment) => JsxFragment; /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ - const createJsxAttribute: (name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const createJsxAttribute: (name: Identifier, initializer: JsxAttributeValue | undefined) => JsxAttribute; /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ - const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) => JsxAttribute; /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ const createJsxAttributes: (properties: readonly JsxAttributeLike[]) => JsxAttributes; /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ diff --git a/tests/baselines/reference/bigintMissingES2020.errors.txt b/tests/baselines/reference/bigintMissingES2020.errors.txt deleted file mode 100644 index 768ee7214c8..00000000000 --- a/tests/baselines/reference/bigintMissingES2020.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS2318: Cannot find global type 'BigInt'. - - -!!! error TS2318: Cannot find global type 'BigInt'. -==== tests/cases/conformance/es2020/bigintMissingES2020.ts (0 errors) ==== - declare function test(): void; - - test<{t?: string}, object>(); - test<{t?: string}, bigint>(); - - // should have global error when bigint is used but ES2020 lib is not present - \ No newline at end of file diff --git a/tests/baselines/reference/bigintMissingES2020.js b/tests/baselines/reference/bigintMissingES2020.js index 83e2cde68e0..01e8c020895 100644 --- a/tests/baselines/reference/bigintMissingES2020.js +++ b/tests/baselines/reference/bigintMissingES2020.js @@ -4,10 +4,10 @@ declare function test(): void; test<{t?: string}, object>(); test<{t?: string}, bigint>(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present //// [bigintMissingES2020.js] test(); test(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingES2020.symbols b/tests/baselines/reference/bigintMissingES2020.symbols index 0757f97759e..61438c69122 100644 --- a/tests/baselines/reference/bigintMissingES2020.symbols +++ b/tests/baselines/reference/bigintMissingES2020.symbols @@ -13,5 +13,5 @@ test<{t?: string}, bigint>(); >test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0)) >t : Symbol(t, Decl(bigintMissingES2020.ts, 3, 6)) -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingES2020.types b/tests/baselines/reference/bigintMissingES2020.types index 36b26c3a43d..1be5a9eb27c 100644 --- a/tests/baselines/reference/bigintMissingES2020.types +++ b/tests/baselines/reference/bigintMissingES2020.types @@ -12,5 +12,5 @@ test<{t?: string}, bigint>(); >test : () => void >t : string -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingESNext.errors.txt b/tests/baselines/reference/bigintMissingESNext.errors.txt deleted file mode 100644 index 381223a9451..00000000000 --- a/tests/baselines/reference/bigintMissingESNext.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS2318: Cannot find global type 'BigInt'. - - -!!! error TS2318: Cannot find global type 'BigInt'. -==== tests/cases/conformance/es2020/bigintMissingESNext.ts (0 errors) ==== - declare function test(): void; - - test<{t?: string}, object>(); - test<{t?: string}, bigint>(); - - // should have global error when bigint is used but ES2020 lib is not present - \ No newline at end of file diff --git a/tests/baselines/reference/bigintMissingESNext.js b/tests/baselines/reference/bigintMissingESNext.js index 5029ca536c2..300fbe5db5f 100644 --- a/tests/baselines/reference/bigintMissingESNext.js +++ b/tests/baselines/reference/bigintMissingESNext.js @@ -4,10 +4,10 @@ declare function test(): void; test<{t?: string}, object>(); test<{t?: string}, bigint>(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present //// [bigintMissingESNext.js] test(); test(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingESNext.symbols b/tests/baselines/reference/bigintMissingESNext.symbols index bd500ba04b0..a517f40d971 100644 --- a/tests/baselines/reference/bigintMissingESNext.symbols +++ b/tests/baselines/reference/bigintMissingESNext.symbols @@ -13,5 +13,5 @@ test<{t?: string}, bigint>(); >test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0)) >t : Symbol(t, Decl(bigintMissingESNext.ts, 3, 6)) -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingESNext.types b/tests/baselines/reference/bigintMissingESNext.types index 6665aac1d5c..d34f9e5250e 100644 --- a/tests/baselines/reference/bigintMissingESNext.types +++ b/tests/baselines/reference/bigintMissingESNext.types @@ -12,5 +12,5 @@ test<{t?: string}, bigint>(); >test : () => void >t : string -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/conditionalEqualityOnLiteralObjects.errors.txt b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.errors.txt new file mode 100644 index 00000000000..f76436aa338 --- /dev/null +++ b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.errors.txt @@ -0,0 +1,130 @@ +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(4,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(6,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(8,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(10,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(12,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(14,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(17,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(19,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(21,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(23,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(25,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(27,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(30,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(32,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(34,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(36,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(38,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(40,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(43,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(45,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(47,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(49,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(51,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. +tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts(53,5): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + + +==== tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts (24 errors) ==== + const a = { a: 1 } + const b = [1] + + if ({ a: 1 } === { a: 1 }) { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ([1] === [1]) { + ~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if (a === { a: 1 }) { + ~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if (b === [1]) { + ~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ({ a: 1 } === a) { + ~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ([1] === b) { + ~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + + if ({ a: 1 } !== { a: 1 }) { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ([1] !== [1]) { + ~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if (a !== { a: 1 }) { + ~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if (b !== [1]) { + ~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ({ a: 1 } !== a) { + ~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ([1] !== b) { + ~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + + if ({ a: 1 } == { a: 1 }) { + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ([1] == [1]) { + ~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if (a == { a: 1 }) { + ~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if (b == [1]) { + ~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ({ a: 1 } == a) { + ~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + if ([1] == b) { + ~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + } + + if ({ a: 1 } != { a: 1 }) { + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ([1] != [1]) { + ~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if (a != { a: 1 }) { + ~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if (b != [1]) { + ~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ({ a: 1 } != a) { + ~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + if ([1] != b) { + ~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. + } + \ No newline at end of file diff --git a/tests/baselines/reference/conditionalEqualityOnLiteralObjects.js b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.js new file mode 100644 index 00000000000..ab1ca51bb72 --- /dev/null +++ b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.js @@ -0,0 +1,108 @@ +//// [conditionalEqualityOnLiteralObjects.ts] +const a = { a: 1 } +const b = [1] + +if ({ a: 1 } === { a: 1 }) { +} +if ([1] === [1]) { +} +if (a === { a: 1 }) { +} +if (b === [1]) { +} +if ({ a: 1 } === a) { +} +if ([1] === b) { +} + +if ({ a: 1 } !== { a: 1 }) { +} +if ([1] !== [1]) { +} +if (a !== { a: 1 }) { +} +if (b !== [1]) { +} +if ({ a: 1 } !== a) { +} +if ([1] !== b) { +} + +if ({ a: 1 } == { a: 1 }) { +} +if ([1] == [1]) { +} +if (a == { a: 1 }) { +} +if (b == [1]) { +} +if ({ a: 1 } == a) { +} +if ([1] == b) { +} + +if ({ a: 1 } != { a: 1 }) { +} +if ([1] != [1]) { +} +if (a != { a: 1 }) { +} +if (b != [1]) { +} +if ({ a: 1 } != a) { +} +if ([1] != b) { +} + + +//// [conditionalEqualityOnLiteralObjects.js] +var a = { a: 1 }; +var b = [1]; +if ({ a: 1 } === { a: 1 }) { +} +if ([1] === [1]) { +} +if (a === { a: 1 }) { +} +if (b === [1]) { +} +if ({ a: 1 } === a) { +} +if ([1] === b) { +} +if ({ a: 1 } !== { a: 1 }) { +} +if ([1] !== [1]) { +} +if (a !== { a: 1 }) { +} +if (b !== [1]) { +} +if ({ a: 1 } !== a) { +} +if ([1] !== b) { +} +if ({ a: 1 } == { a: 1 }) { +} +if ([1] == [1]) { +} +if (a == { a: 1 }) { +} +if (b == [1]) { +} +if ({ a: 1 } == a) { +} +if ([1] == b) { +} +if ({ a: 1 } != { a: 1 }) { +} +if ([1] != [1]) { +} +if (a != { a: 1 }) { +} +if (b != [1]) { +} +if ({ a: 1 } != a) { +} +if ([1] != b) { +} diff --git a/tests/baselines/reference/conditionalEqualityOnLiteralObjects.symbols b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.symbols new file mode 100644 index 00000000000..0be4f1e5c97 --- /dev/null +++ b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.symbols @@ -0,0 +1,92 @@ +=== tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts === +const a = { a: 1 } +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 11)) + +const b = [1] +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) + +if ({ a: 1 } === { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 3, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 3, 18)) +} +if ([1] === [1]) { +} +if (a === { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 7, 11)) +} +if (b === [1]) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} +if ({ a: 1 } === a) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 11, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +} +if ([1] === b) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} + +if ({ a: 1 } !== { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 16, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 16, 18)) +} +if ([1] !== [1]) { +} +if (a !== { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 20, 11)) +} +if (b !== [1]) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} +if ({ a: 1 } !== a) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 24, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +} +if ([1] !== b) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} + +if ({ a: 1 } == { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 29, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 29, 17)) +} +if ([1] == [1]) { +} +if (a == { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 33, 10)) +} +if (b == [1]) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} +if ({ a: 1 } == a) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 37, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +} +if ([1] == b) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} + +if ({ a: 1 } != { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 42, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 42, 17)) +} +if ([1] != [1]) { +} +if (a != { a: 1 }) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 46, 10)) +} +if (b != [1]) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} +if ({ a: 1 } != a) { +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 50, 5)) +>a : Symbol(a, Decl(conditionalEqualityOnLiteralObjects.ts, 0, 5)) +} +if ([1] != b) { +>b : Symbol(b, Decl(conditionalEqualityOnLiteralObjects.ts, 1, 5)) +} + diff --git a/tests/baselines/reference/conditionalEqualityOnLiteralObjects.types b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.types new file mode 100644 index 00000000000..8287257837c --- /dev/null +++ b/tests/baselines/reference/conditionalEqualityOnLiteralObjects.types @@ -0,0 +1,184 @@ +=== tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts === +const a = { a: 1 } +>a : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +const b = [1] +>b : number[] +>[1] : number[] +>1 : 1 + +if ({ a: 1 } === { a: 1 }) { +>{ a: 1 } === { a: 1 } : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if ([1] === [1]) { +>[1] === [1] : boolean +>[1] : number[] +>1 : 1 +>[1] : number[] +>1 : 1 +} +if (a === { a: 1 }) { +>a === { a: 1 } : boolean +>a : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if (b === [1]) { +>b === [1] : boolean +>b : number[] +>[1] : number[] +>1 : 1 +} +if ({ a: 1 } === a) { +>{ a: 1 } === a : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>a : { a: number; } +} +if ([1] === b) { +>[1] === b : boolean +>[1] : number[] +>1 : 1 +>b : number[] +} + +if ({ a: 1 } !== { a: 1 }) { +>{ a: 1 } !== { a: 1 } : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if ([1] !== [1]) { +>[1] !== [1] : boolean +>[1] : number[] +>1 : 1 +>[1] : number[] +>1 : 1 +} +if (a !== { a: 1 }) { +>a !== { a: 1 } : boolean +>a : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if (b !== [1]) { +>b !== [1] : boolean +>b : number[] +>[1] : number[] +>1 : 1 +} +if ({ a: 1 } !== a) { +>{ a: 1 } !== a : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>a : { a: number; } +} +if ([1] !== b) { +>[1] !== b : boolean +>[1] : number[] +>1 : 1 +>b : number[] +} + +if ({ a: 1 } == { a: 1 }) { +>{ a: 1 } == { a: 1 } : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if ([1] == [1]) { +>[1] == [1] : boolean +>[1] : number[] +>1 : 1 +>[1] : number[] +>1 : 1 +} +if (a == { a: 1 }) { +>a == { a: 1 } : boolean +>a : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if (b == [1]) { +>b == [1] : boolean +>b : number[] +>[1] : number[] +>1 : 1 +} +if ({ a: 1 } == a) { +>{ a: 1 } == a : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>a : { a: number; } +} +if ([1] == b) { +>[1] == b : boolean +>[1] : number[] +>1 : 1 +>b : number[] +} + +if ({ a: 1 } != { a: 1 }) { +>{ a: 1 } != { a: 1 } : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if ([1] != [1]) { +>[1] != [1] : boolean +>[1] : number[] +>1 : 1 +>[1] : number[] +>1 : 1 +} +if (a != { a: 1 }) { +>a != { a: 1 } : boolean +>a : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +} +if (b != [1]) { +>b != [1] : boolean +>b : number[] +>[1] : number[] +>1 : 1 +} +if ({ a: 1 } != a) { +>{ a: 1 } != a : boolean +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 +>a : { a: number; } +} +if ([1] != b) { +>[1] != b : boolean +>[1] : number[] +>1 : 1 +>b : number[] +} + diff --git a/tests/baselines/reference/constructorNameInAccessor.errors.txt b/tests/baselines/reference/constructorNameInAccessor.errors.txt new file mode 100644 index 00000000000..7033dec4e5b --- /dev/null +++ b/tests/baselines/reference/constructorNameInAccessor.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/salsa/constructorNameInAccessor.ts(2,9): error TS1341: Class constructor may not be an accessor. +tests/cases/conformance/salsa/constructorNameInAccessor.ts(3,9): error TS1341: Class constructor may not be an accessor. + + +==== tests/cases/conformance/salsa/constructorNameInAccessor.ts (2 errors) ==== + class C1 { + get constructor() { return } + ~~~~~~~~~~~ +!!! error TS1341: Class constructor may not be an accessor. + set constructor(value) {} + ~~~~~~~~~~~ +!!! error TS1341: Class constructor may not be an accessor. + } + \ No newline at end of file diff --git a/tests/baselines/reference/constructorNameInAccessor.js b/tests/baselines/reference/constructorNameInAccessor.js new file mode 100644 index 00000000000..041d812b016 --- /dev/null +++ b/tests/baselines/reference/constructorNameInAccessor.js @@ -0,0 +1,12 @@ +//// [constructorNameInAccessor.ts] +class C1 { + get constructor() { return } + set constructor(value) {} +} + + +//// [constructorNameInAccessor.js] +class C1 { + get constructor() { return; } + set constructor(value) { } +} diff --git a/tests/baselines/reference/constructorNameInAccessor.symbols b/tests/baselines/reference/constructorNameInAccessor.symbols new file mode 100644 index 00000000000..cea664a716f --- /dev/null +++ b/tests/baselines/reference/constructorNameInAccessor.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/salsa/constructorNameInAccessor.ts === +class C1 { +>C1 : Symbol(C1, Decl(constructorNameInAccessor.ts, 0, 0)) + + get constructor() { return } +>constructor : Symbol(C1.constructor, Decl(constructorNameInAccessor.ts, 0, 10), Decl(constructorNameInAccessor.ts, 1, 32)) + + set constructor(value) {} +>constructor : Symbol(C1.constructor, Decl(constructorNameInAccessor.ts, 0, 10), Decl(constructorNameInAccessor.ts, 1, 32)) +>value : Symbol(value, Decl(constructorNameInAccessor.ts, 2, 20)) +} + diff --git a/tests/baselines/reference/constructorNameInAccessor.types b/tests/baselines/reference/constructorNameInAccessor.types new file mode 100644 index 00000000000..b81c47ec3e2 --- /dev/null +++ b/tests/baselines/reference/constructorNameInAccessor.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/salsa/constructorNameInAccessor.ts === +class C1 { +>C1 : C1 + + get constructor() { return } +>constructor : void + + set constructor(value) {} +>constructor : void +>value : void +} + diff --git a/tests/baselines/reference/constructorNameInGenerator.errors.txt b/tests/baselines/reference/constructorNameInGenerator.errors.txt new file mode 100644 index 00000000000..061560615fb --- /dev/null +++ b/tests/baselines/reference/constructorNameInGenerator.errors.txt @@ -0,0 +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 (1 errors) ==== + class C2 { + *constructor() {} + ~~~~~~~~~~~ +!!! error TS1360: Class constructor may not be a generator. + } + \ No newline at end of file diff --git a/tests/baselines/reference/constructorNameInGenerator.js b/tests/baselines/reference/constructorNameInGenerator.js new file mode 100644 index 00000000000..fb7b318a192 --- /dev/null +++ b/tests/baselines/reference/constructorNameInGenerator.js @@ -0,0 +1,10 @@ +//// [constructorNameInGenerator.ts] +class C2 { + *constructor() {} +} + + +//// [constructorNameInGenerator.js] +class C2 { + *constructor() { } +} diff --git a/tests/baselines/reference/constructorNameInGenerator.symbols b/tests/baselines/reference/constructorNameInGenerator.symbols new file mode 100644 index 00000000000..ea64a07a651 --- /dev/null +++ b/tests/baselines/reference/constructorNameInGenerator.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/salsa/constructorNameInGenerator.ts === +class C2 { +>C2 : Symbol(C2, Decl(constructorNameInGenerator.ts, 0, 0)) + + *constructor() {} +>constructor : Symbol(C2.constructor, Decl(constructorNameInGenerator.ts, 0, 10)) +} + diff --git a/tests/baselines/reference/constructorNameInGenerator.types b/tests/baselines/reference/constructorNameInGenerator.types new file mode 100644 index 00000000000..ba5f4f243da --- /dev/null +++ b/tests/baselines/reference/constructorNameInGenerator.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/salsa/constructorNameInGenerator.ts === +class C2 { +>C2 : C2 + + *constructor() {} +>constructor : () => Generator +} + diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.js b/tests/baselines/reference/contextualSignatureInObjectFreeze.js new file mode 100644 index 00000000000..e25ef7ab247 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.js @@ -0,0 +1,13 @@ +//// [contextualSignatureInObjectFreeze.ts] +// #49101 + +Object.freeze({ + f: function () { } +}) + + +//// [contextualSignatureInObjectFreeze.js] +// #49101 +Object.freeze({ + f: function () { } +}); diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols b/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols new file mode 100644 index 00000000000..68e9d81c600 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts === +// #49101 + +Object.freeze({ +>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + f: function () { } +>f : Symbol(f, Decl(contextualSignatureInObjectFreeze.ts, 2, 15)) + +}) + diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.types b/tests/baselines/reference/contextualSignatureInObjectFreeze.types new file mode 100644 index 00000000000..a2d8418cbf0 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts === +// #49101 + +Object.freeze({ +>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }> +>Object.freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object : ObjectConstructor +>freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>{ f: function () { }} : { f: () => void; } + + f: function () { } +>f : () => void +>function () { } : () => void + +}) + diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index 5a9ebea09be..cdd16bc9027 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(40,1): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. -==== tests/cases/conformance/functions/functionImplementationErrors.ts (3 errors) ==== +==== tests/cases/conformance/functions/functionImplementationErrors.ts (4 errors) ==== // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { return ''; @@ -50,9 +51,14 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error // FunctionExpression with non -void return type annotation with a throw, no return, and other code // Should be error but isn't undefined === function (): number { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ throw undefined; + ~~~~~~~~~~~~~~~~~~~~ var x = 4; + ~~~~~~~~~~~~~~ }; + ~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. class Base { private x; } class AnotherClass { private y; } diff --git a/tests/baselines/reference/functionImplementations.errors.txt b/tests/baselines/reference/functionImplementations.errors.txt new file mode 100644 index 00000000000..e289bd7e400 --- /dev/null +++ b/tests/baselines/reference/functionImplementations.errors.txt @@ -0,0 +1,164 @@ +tests/cases/conformance/functions/functionImplementations.ts(90,1): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + + +==== tests/cases/conformance/functions/functionImplementations.ts (1 errors) ==== + // FunctionExpression with no return type annotation and no return statement returns void + var v: void = function () { } (); + + // FunctionExpression f with no return type annotation and directly references f in its body returns any + var a: any = function f() { + return f; + }; + var a: any = function f() { + return f(); + }; + + // FunctionExpression f with no return type annotation and indirectly references f in its body returns any + var a: any = function f() { + var x = f; + return x; + }; + + // Two mutually recursive function implementations with no return type annotations + function rec1() { + return rec2(); + } + function rec2() { + return rec1(); + } + var a = rec1(); + var a = rec2(); + + // Two mutually recursive function implementations with return type annotation in one + function rec3(): number { + return rec4(); + } + function rec4() { + return rec3(); + } + var n: number; + var n = rec3(); + var n = rec4(); + + // FunctionExpression with no return type annotation and returns a number + var n = function () { + return 3; + } (); + + // FunctionExpression with no return type annotation and returns null + var nu = null; + var nu = function () { + return null; + } (); + + // FunctionExpression with no return type annotation and returns undefined + var un = undefined; + var un = function () { + return undefined; + } (); + + // FunctionExpression with no return type annotation and returns a type parameter type + var n = function (x: T) { + return x; + } (4); + + // FunctionExpression with no return type annotation and returns a constrained type parameter type + var n = function (x: T) { + return x; + } (4); + + // FunctionExpression with no return type annotation with multiple return statements with identical types + var n = function () { + return 3; + return 5; + }(); + + // Otherwise, the inferred return type is the first of the types of the return statement expressions + // in the function body that is a supertype of each of the others, + // ignoring return statements with no expressions. + // A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. + // FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns + class Base { private m; } + class Derived extends Base { private q; } + var b: Base; + var b = function () { + return new Base(); return new Derived(); + } (); + + // FunctionExpression with no return type annotation with multiple return statements with one a recursive call + var a = function f() { + return new Base(); return new Derived(); return f(); // ? + } (); + + // FunctionExpression with non -void return type annotation with a single throw statement + undefined === function (): number { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + throw undefined; + ~~~~~~~~~~~~~~~~~~~~ + }; + ~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. + + // Type of 'this' in function implementation is 'any' + function thisFunc() { + var x = this; + var x: any; + } + + // Function signature with optional parameter, no type annotation and initializer has initializer's type + function opt1(n = 4) { + var m = n; + var m: number; + } + + // Function signature with optional parameter, no type annotation and initializer has initializer's widened type + function opt2(n = { x: null, y: undefined }) { + var m = n; + var m: { x: any; y: any }; + } + + // Function signature with initializer referencing other parameter to the left + function opt3(n: number, m = n) { + var y = m; + var y: number; + } + + // Function signature with optional parameter has correct codegen + // (tested above) + + // FunctionExpression with non -void return type annotation return with no expression + function f6(): number { + return; + } + + class Derived2 extends Base { private r: string; } + class AnotherClass { private x } + // if f is a contextually typed function expression, the inferred return type is the union type + // of the types of the return statement expressions in the function body, + // ignoring return statements with no expressions. + var f7: (x: number) => string | number = x => { // should be (x: number) => number | string + if (x < 0) { return x; } + return x.toString(); + } + var f8: (x: number) => any = x => { // should be (x: number) => Base + return new Base(); + return new Derived2(); + } + var f9: (x: number) => any = x => { // should be (x: number) => Base + return new Base(); + return new Derived(); + return new Derived2(); + } + var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 + return new Derived(); + return new Derived2(); + } + var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass + return new Base(); + return new AnotherClass(); + } + var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass + return new Base(); + return; // should be ignored + return new AnotherClass(); + } \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).errors.txt b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).errors.txt new file mode 100644 index 00000000000..83f39a9ccb4 --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/a.tsx(7,16): error TS1145: '{' or JSX element expected. + + +==== tests/cases/conformance/jsx/a.tsx (1 errors) ==== + declare var React: any; + +
+
/> +
foo
/> +
foo
/> +
+ ~ +!!! error TS1145: '{' or JSX element expected. +
+ \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).js b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).js new file mode 100644 index 00000000000..3feabccd94e --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).js @@ -0,0 +1,18 @@ +//// [a.tsx] +declare var React: any; + +
+
/> +
foo
/> +
foo
/> +
+
+ + +//// [a.jsx] +
+
/> +
foo
/> +
foo
/> +
+
; diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).symbols b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).symbols new file mode 100644 index 00000000000..efabdca743a --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : Symbol(React, Decl(a.tsx, 0, 11)) + +
+
/> +>attr : Symbol(attr, Decl(a.tsx, 3, 8)) + +
foo
/> +>attr : Symbol(attr, Decl(a.tsx, 4, 8)) + +
foo
/> +>attr : Symbol(attr, Decl(a.tsx, 5, 8)) + +
+>attr : Symbol(attr, Decl(a.tsx, 6, 8)) + +
+ diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).types b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).types new file mode 100644 index 00000000000..d401c53b96d --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=preserve).types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : any + +
+>
/>
foo
/>
foo
/>
: any +>div : any + +
/> +>
/> : any +>div : any +>attr : any +>
: any +>div : any + +
foo
/> +>
foo
/> : any +>div : any +>attr : any +>
foo
: any +>div : any +>div : any + +
foo
/> +>
foo
/> : any +>div : any +>attr : any +><>
foo
: any +>
foo
: any +>div : any +>div : any + +
+>
: any +>div : any +>attr : true + +
+>div : any + diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=react).errors.txt b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).errors.txt new file mode 100644 index 00000000000..83f39a9ccb4 --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/jsx/a.tsx(7,16): error TS1145: '{' or JSX element expected. + + +==== tests/cases/conformance/jsx/a.tsx (1 errors) ==== + declare var React: any; + +
+
/> +
foo
/> +
foo
/> +
+ ~ +!!! error TS1145: '{' or JSX element expected. +
+ \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=react).js b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).js new file mode 100644 index 00000000000..2839c345594 --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).js @@ -0,0 +1,18 @@ +//// [a.tsx] +declare var React: any; + +
+
/> +
foo
/> +
foo
/> +
+
+ + +//// [a.js] +React.createElement("div", null, + React.createElement("div", { attr: React.createElement("div", null) }), + React.createElement("div", { attr: React.createElement("div", null, "foo") }), + React.createElement("div", { attr: React.createElement(React.Fragment, null, + React.createElement("div", null, "foo")) }), + React.createElement("div", { attr: true })); diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=react).symbols b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).symbols new file mode 100644 index 00000000000..efabdca743a --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : Symbol(React, Decl(a.tsx, 0, 11)) + +
+
/> +>attr : Symbol(attr, Decl(a.tsx, 3, 8)) + +
foo
/> +>attr : Symbol(attr, Decl(a.tsx, 4, 8)) + +
foo
/> +>attr : Symbol(attr, Decl(a.tsx, 5, 8)) + +
+>attr : Symbol(attr, Decl(a.tsx, 6, 8)) + +
+ diff --git a/tests/baselines/reference/jsxAttributeInitializer(jsx=react).types b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).types new file mode 100644 index 00000000000..d401c53b96d --- /dev/null +++ b/tests/baselines/reference/jsxAttributeInitializer(jsx=react).types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : any + +
+>
/>
foo
/>
foo
/>
: any +>div : any + +
/> +>
/> : any +>div : any +>attr : any +>
: any +>div : any + +
foo
/> +>
foo
/> : any +>div : any +>attr : any +>
foo
: any +>div : any +>div : any + +
foo
/> +>
foo
/> : any +>div : any +>attr : any +><>
foo
: any +>
foo
: any +>div : any +>div : any + +
+>
: any +>div : any +>attr : true + +
+>div : any + diff --git a/tests/baselines/reference/jsxAttributeMissingInitializer.errors.txt b/tests/baselines/reference/jsxAttributeMissingInitializer.errors.txt index feeaaac525d..4f450b08b42 100644 --- a/tests/baselines/reference/jsxAttributeMissingInitializer.errors.txt +++ b/tests/baselines/reference/jsxAttributeMissingInitializer.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/jsxAttributeMissingInitializer.tsx(1,21): error TS1005: '{' expected. +tests/cases/compiler/jsxAttributeMissingInitializer.tsx(1,21): error TS1145: '{' or JSX element expected. ==== tests/cases/compiler/jsxAttributeMissingInitializer.tsx (1 errors) ==== const x =
; ~ -!!! error TS1005: '{' expected. +!!! error TS1145: '{' or JSX element expected. const y = 0; \ No newline at end of file diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt index 22f3c94b6e1..0475255c224 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.errors.txt @@ -1,13 +1,7 @@ -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,1): error TS2657: JSX expressions must have one parent element. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,17): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,23): error TS1005: ';' expected. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,23): error TS2304: Cannot find name 'right'. tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,41): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,57): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,58): error TS1109: Expression expected. -==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (7 errors) ==== +==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (1 errors) ==== declare var React: any; declare var 日本語; declare var AbC_def; @@ -48,20 +42,8 @@ tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,58): error TS1109: Expr

7x invalid-js-identifier
; right=monkeys /> gorillas />; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2657: JSX expressions must have one parent element. - ~ -!!! error TS1005: '{' expected. - ~~~~~ -!!! error TS1005: ';' expected. - ~~~~~ -!!! error TS2304: Cannot find name 'right'. ~ !!! error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1109: Expression expected. ; diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.js b/tests/baselines/reference/jsxEsprimaFbTestSuite.js index 7a6bec81dbf..e5b90a5c64a 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.js +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.js @@ -72,8 +72,7 @@ baz {/* this is a comment */};
@test content
;

7x invalid-js-identifier
; -, ; -right = monkeys /> gorillas / > ; + right=monkeys /> gorillas/>; ; ; (
) < x; diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols index 64d739a9d62..d336e0302ab 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols @@ -77,6 +77,7 @@ baz right=monkeys /> gorillas />; >LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11)) >left : Symbol(left, Decl(jsxEsprimaFbTestSuite.tsx, 39, 10)) +>right : Symbol(right, Decl(jsxEsprimaFbTestSuite.tsx, 39, 21)) ; >a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11)) diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.types b/tests/baselines/reference/jsxEsprimaFbTestSuite.types index 7061befb881..4b48d7c378d 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.types +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.types @@ -118,21 +118,15 @@ baz >div : any right=monkeys /> gorillas />; -> : any -> right=monkeys /> gorillas /> : any >LeftRight : any ->left : true +>left : any > : any >a : any ->right=monkeys /> gorillas /> : boolean >right : any ->monkeys /> gorillas /> : boolean ->monkeys /> gorillas / : number >monkeys /> gorillas : any >b : any >b : any -> : any -> : any ; > : any diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index 12698255485..cbe83ef6ece 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -57,10 +57,8 @@ tests/cases/conformance/jsx/25.tsx(1,39): error TS1109: Expression expected. tests/cases/conformance/jsx/26.tsx(1,4): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? tests/cases/conformance/jsx/27.tsx(1,5): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? tests/cases/conformance/jsx/28.tsx(1,2): error TS17008: JSX element 'a' has no corresponding closing tag. -tests/cases/conformance/jsx/28.tsx(1,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/28.tsx(1,6): error TS1145: '{' or JSX element expected. tests/cases/conformance/jsx/28.tsx(2,1): error TS1005: '; ~ -!!! error TS1005: '{' expected. +!!! error TS1145: '{' or JSX element expected. ==== tests/cases/conformance/jsx/5.tsx (2 errors) ==== ; ~ @@ -292,21 +290,16 @@ tests/cases/conformance/jsx/9.tsx(1,10): error TS2304: Cannot find name 'a:b'. ~ !!! error TS17008: JSX element 'a' has no corresponding closing tag. ~ -!!! error TS1005: '{' expected. +!!! error TS1145: '{' or JSX element expected. !!! error TS1005: '; - ~~~~~~~~~ - ~ -!!! error TS1005: '{' expected. ~ !!! error TS1003: Identifier expected. -!!! error TS2657: JSX expressions must have one parent element. - !!! error TS1005: '}; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index 0b215a47a7c..e0d10043838 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -150,8 +150,8 @@ var x =
one
/* intervening comment */, /* intervening comment */
; ; //// [29.jsx] -, <>; -; +; +/>; //// [30.jsx] }; //// [31.jsx] diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types index cb54dc62c3a..277d3da9da6 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types @@ -250,9 +250,8 @@ var x =
one
/* intervening comment */
two
;; === tests/cases/conformance/jsx/29.tsx === ; >; : any ->a : any ->b : true +>b : any ><}>; : any > : any diff --git a/tests/baselines/reference/namespaceImportTypeQuery.errors.txt b/tests/baselines/reference/namespaceImportTypeQuery.errors.txt index 5036215385d..928882d2b17 100644 --- a/tests/baselines/reference/namespaceImportTypeQuery.errors.txt +++ b/tests/baselines/reference/namespaceImportTypeQuery.errors.txt @@ -1,4 +1,5 @@ -/b.ts(2,21): error TS2339: Property 'A' does not exist on type 'typeof import("/a")'. +/b.ts(8,3): error TS2322: Type '{ A: any; B: any; }' is not assignable to type 'typeof import("/a")'. + Object literal may only specify known properties, and 'A' does not exist in type 'typeof import("/a")'. ==== /a.ts (0 errors) ==== @@ -9,7 +10,15 @@ ==== /b.ts (1 errors) ==== import * as types from './a'; let A: typeof types.A; - ~ -!!! error TS2339: Property 'A' does not exist on type 'typeof import("/a")'. let B: typeof types.B; + + let t: typeof types = { + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined as any, + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ A: any; B: any; }' is not assignable to type 'typeof import("/a")'. +!!! error TS2322: Object literal may only specify known properties, and 'A' does not exist in type 'typeof import("/a")'. + B: undefined as any, + } \ No newline at end of file diff --git a/tests/baselines/reference/namespaceImportTypeQuery.js b/tests/baselines/reference/namespaceImportTypeQuery.js index 18ea6343521..33746b223b1 100644 --- a/tests/baselines/reference/namespaceImportTypeQuery.js +++ b/tests/baselines/reference/namespaceImportTypeQuery.js @@ -9,6 +9,13 @@ export class B {}; import * as types from './a'; let A: typeof types.A; let B: typeof types.B; + +let t: typeof types = { + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined as any, + B: undefined as any, +} //// [a.js] @@ -32,3 +39,9 @@ exports.B = B; exports.__esModule = true; var A; var B; +var t = { + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined, + B: undefined +}; diff --git a/tests/baselines/reference/namespaceImportTypeQuery.symbols b/tests/baselines/reference/namespaceImportTypeQuery.symbols index 9851b31b6b0..30b8694f602 100644 --- a/tests/baselines/reference/namespaceImportTypeQuery.symbols +++ b/tests/baselines/reference/namespaceImportTypeQuery.symbols @@ -14,7 +14,9 @@ import * as types from './a'; let A: typeof types.A; >A : Symbol(A, Decl(b.ts, 1, 3)) +>types.A : Symbol(types.A, Decl(a.ts, 1, 13)) >types : Symbol(types, Decl(b.ts, 0, 6)) +>A : Symbol(types.A, Decl(a.ts, 1, 13)) let B: typeof types.B; >B : Symbol(B, Decl(b.ts, 2, 3)) @@ -22,3 +24,18 @@ let B: typeof types.B; >types : Symbol(types, Decl(b.ts, 0, 6)) >B : Symbol(types.B, Decl(a.ts, 1, 18)) +let t: typeof types = { +>t : Symbol(t, Decl(b.ts, 4, 3)) +>types : Symbol(types, Decl(b.ts, 0, 6)) + + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined as any, +>A : Symbol(A, Decl(b.ts, 4, 23)) +>undefined : Symbol(undefined) + + B: undefined as any, +>B : Symbol(B, Decl(b.ts, 7, 22)) +>undefined : Symbol(undefined) +} + diff --git a/tests/baselines/reference/namespaceImportTypeQuery.types b/tests/baselines/reference/namespaceImportTypeQuery.types index 273a46b1507..6023d0961d5 100644 --- a/tests/baselines/reference/namespaceImportTypeQuery.types +++ b/tests/baselines/reference/namespaceImportTypeQuery.types @@ -13,10 +13,10 @@ import * as types from './a'; >types : typeof types let A: typeof types.A; ->A : any ->types.A : any +>A : typeof types.A +>types.A : typeof types.A >types : typeof types ->A : any +>A : typeof types.A let B: typeof types.B; >B : typeof types.B @@ -24,3 +24,21 @@ let B: typeof types.B; >types : typeof types >B : typeof types.B +let t: typeof types = { +>t : typeof types +>types : typeof types +>{ // error: while you can ask for `typeof types.A`, // `typeof types` does not include `A` A: undefined as any, B: undefined as any,} : { A: any; B: any; } + + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined as any, +>A : any +>undefined as any : any +>undefined : undefined + + B: undefined as any, +>B : any +>undefined as any : any +>undefined : undefined +} + diff --git a/tests/baselines/reference/narrowByEquality.errors.txt b/tests/baselines/reference/narrowByEquality.errors.txt index 15610d6d1d4..a484b589515 100644 --- a/tests/baselines/reference/narrowByEquality.errors.txt +++ b/tests/baselines/reference/narrowByEquality.errors.txt @@ -1,10 +1,11 @@ +tests/cases/compiler/narrowByEquality.ts(41,5): error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. tests/cases/compiler/narrowByEquality.ts(54,15): error TS2322: Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/narrowByEquality.ts(55,9): error TS2322: Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. -==== tests/cases/compiler/narrowByEquality.ts (2 errors) ==== +==== tests/cases/compiler/narrowByEquality.ts (3 errors) ==== declare let x: number | string | boolean declare let n: number; declare let s: string; @@ -46,6 +47,8 @@ tests/cases/compiler/narrowByEquality.ts(55,9): error TS2322: Type 'string | num declare let xAndObj: number | string | boolean | object if (xAndObj == {}) { + ~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'false' since JavaScript compares objects by reference, not value. xAndObj; } diff --git a/tests/baselines/reference/parserRealSource7.errors.txt b/tests/baselines/reference/parserRealSource7.errors.txt index 250b589873b..a566f7212e3 100644 --- a/tests/baselines/reference/parserRealSource7.errors.txt +++ b/tests/baselines/reference/parserRealSource7.errors.txt @@ -265,6 +265,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(704,34): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(710,69): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(710,93): error TS2304: Cannot find name 'FuncDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(710,136): error TS2304: Cannot find name 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(722,17): error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(724,22): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(724,83): error TS2304: Cannot find name 'FncFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(729,44): error TS2304: Cannot find name 'SymbolKind'. @@ -303,7 +304,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(827,34): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error TS2304: Cannot find name 'popTypeCollectionScope'. -==== tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts (303 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts (304 errors) ==== // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -1562,6 +1563,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T fgSym.type && fgSym.type.construct && fgSym.type.construct.signatures != [] && + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2839: This condition will always return 'true' since JavaScript compares objects by reference, not value. (fgSym.type.construct.signatures[0].declAST == null || !hasFlag(fgSym.type.construct.signatures[0].declAST.fncFlags, FncFlags.Ambient)) && ~~~~~~~ diff --git a/tests/baselines/reference/typeofImportTypeOnlyExport.js b/tests/baselines/reference/typeofImportTypeOnlyExport.js new file mode 100644 index 00000000000..b9cbd6ec647 --- /dev/null +++ b/tests/baselines/reference/typeofImportTypeOnlyExport.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/declarationEmit/typeofImportTypeOnlyExport.ts] //// + +//// [button.ts] +import {classMap} from './lit.js'; +export const c = classMap(); + +//// [lit.ts] +class ClassMapDirective {} + +export type {ClassMapDirective}; + +export const directive = + (class_: C) => + () => ({ + directive: class_, + }); + +export const classMap = directive(ClassMapDirective); + + +//// [lit.js] +"use strict"; +exports.__esModule = true; +exports.classMap = exports.directive = void 0; +var ClassMapDirective = /** @class */ (function () { + function ClassMapDirective() { + } + return ClassMapDirective; +}()); +var directive = function (class_) { + return function () { return ({ + directive: class_ + }); }; +}; +exports.directive = directive; +exports.classMap = (0, exports.directive)(ClassMapDirective); +//// [button.js] +"use strict"; +exports.__esModule = true; +exports.c = void 0; +var lit_js_1 = require("./lit.js"); +exports.c = (0, lit_js_1.classMap)(); + + +//// [lit.d.ts] +declare class ClassMapDirective { +} +export type { ClassMapDirective }; +export declare const directive: (class_: C) => () => { + directive: C; +}; +export declare const classMap: () => { + directive: typeof ClassMapDirective; +}; +//// [button.d.ts] +export declare const c: { + directive: typeof import("./lit.js").ClassMapDirective; +}; diff --git a/tests/baselines/reference/typeofImportTypeOnlyExport.symbols b/tests/baselines/reference/typeofImportTypeOnlyExport.symbols new file mode 100644 index 00000000000..512c80aa946 --- /dev/null +++ b/tests/baselines/reference/typeofImportTypeOnlyExport.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/declarationEmit/button.ts === +import {classMap} from './lit.js'; +>classMap : Symbol(classMap, Decl(button.ts, 0, 8)) + +export const c = classMap(); +>c : Symbol(c, Decl(button.ts, 1, 12)) +>classMap : Symbol(classMap, Decl(button.ts, 0, 8)) + +=== tests/cases/conformance/declarationEmit/lit.ts === +class ClassMapDirective {} +>ClassMapDirective : Symbol(ClassMapDirective, Decl(lit.ts, 0, 0)) + +export type {ClassMapDirective}; +>ClassMapDirective : Symbol(ClassMapDirective, Decl(lit.ts, 2, 13)) + +export const directive = +>directive : Symbol(directive, Decl(lit.ts, 4, 12)) + + (class_: C) => +>C : Symbol(C, Decl(lit.ts, 5, 3)) +>class_ : Symbol(class_, Decl(lit.ts, 5, 6)) +>C : Symbol(C, Decl(lit.ts, 5, 3)) + + () => ({ + directive: class_, +>directive : Symbol(directive, Decl(lit.ts, 6, 10)) +>class_ : Symbol(class_, Decl(lit.ts, 5, 6)) + + }); + +export const classMap = directive(ClassMapDirective); +>classMap : Symbol(classMap, Decl(lit.ts, 10, 12)) +>directive : Symbol(directive, Decl(lit.ts, 4, 12)) +>ClassMapDirective : Symbol(ClassMapDirective, Decl(lit.ts, 0, 0)) + diff --git a/tests/baselines/reference/typeofImportTypeOnlyExport.types b/tests/baselines/reference/typeofImportTypeOnlyExport.types new file mode 100644 index 00000000000..6bc89508687 --- /dev/null +++ b/tests/baselines/reference/typeofImportTypeOnlyExport.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/declarationEmit/button.ts === +import {classMap} from './lit.js'; +>classMap : () => { directive: typeof import("tests/cases/conformance/declarationEmit/lit").ClassMapDirective; } + +export const c = classMap(); +>c : { directive: typeof import("tests/cases/conformance/declarationEmit/lit").ClassMapDirective; } +>classMap() : { directive: typeof import("tests/cases/conformance/declarationEmit/lit").ClassMapDirective; } +>classMap : () => { directive: typeof import("tests/cases/conformance/declarationEmit/lit").ClassMapDirective; } + +=== tests/cases/conformance/declarationEmit/lit.ts === +class ClassMapDirective {} +>ClassMapDirective : ClassMapDirective + +export type {ClassMapDirective}; +>ClassMapDirective : ClassMapDirective + +export const directive = +>directive : (class_: C) => () => { directive: C; } + + (class_: C) => +>(class_: C) => () => ({ directive: class_, }) : (class_: C) => () => { directive: C; } +>class_ : C + + () => ({ +>() => ({ directive: class_, }) : () => { directive: C; } +>({ directive: class_, }) : { directive: C; } +>{ directive: class_, } : { directive: C; } + + directive: class_, +>directive : C +>class_ : C + + }); + +export const classMap = directive(ClassMapDirective); +>classMap : () => { directive: typeof ClassMapDirective; } +>directive(ClassMapDirective) : () => { directive: typeof ClassMapDirective; } +>directive : (class_: C) => () => { directive: C; } +>ClassMapDirective : typeof ClassMapDirective + diff --git a/tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts b/tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts new file mode 100644 index 00000000000..ef4a6f949c4 --- /dev/null +++ b/tests/cases/compiler/conditionalEqualityOnLiteralObjects.ts @@ -0,0 +1,54 @@ +const a = { a: 1 } +const b = [1] + +if ({ a: 1 } === { a: 1 }) { +} +if ([1] === [1]) { +} +if (a === { a: 1 }) { +} +if (b === [1]) { +} +if ({ a: 1 } === a) { +} +if ([1] === b) { +} + +if ({ a: 1 } !== { a: 1 }) { +} +if ([1] !== [1]) { +} +if (a !== { a: 1 }) { +} +if (b !== [1]) { +} +if ({ a: 1 } !== a) { +} +if ([1] !== b) { +} + +if ({ a: 1 } == { a: 1 }) { +} +if ([1] == [1]) { +} +if (a == { a: 1 }) { +} +if (b == [1]) { +} +if ({ a: 1 } == a) { +} +if ([1] == b) { +} + +if ({ a: 1 } != { a: 1 }) { +} +if ([1] != [1]) { +} +if (a != { a: 1 }) { +} +if (b != [1]) { +} +if ({ a: 1 } != a) { +} +if ([1] != b) { +} diff --git a/tests/cases/compiler/contextualSignatureInObjectFreeze.ts b/tests/cases/compiler/contextualSignatureInObjectFreeze.ts new file mode 100644 index 00000000000..1f2c561c13d --- /dev/null +++ b/tests/cases/compiler/contextualSignatureInObjectFreeze.ts @@ -0,0 +1,7 @@ +// #49101 +// @target: es2020 +// @lib: es2019 + +Object.freeze({ + f: function () { } +}) diff --git a/tests/cases/conformance/declarationEmit/typeofImportTypeOnlyExport.ts b/tests/cases/conformance/declarationEmit/typeofImportTypeOnlyExport.ts new file mode 100644 index 00000000000..aabf57bcc01 --- /dev/null +++ b/tests/cases/conformance/declarationEmit/typeofImportTypeOnlyExport.ts @@ -0,0 +1,18 @@ +// @declaration: true + +// @Filename: button.ts +import {classMap} from './lit.js'; +export const c = classMap(); + +// @Filename: lit.ts +class ClassMapDirective {} + +export type {ClassMapDirective}; + +export const directive = + (class_: C) => + () => ({ + directive: class_, + }); + +export const classMap = directive(ClassMapDirective); diff --git a/tests/cases/conformance/es2020/bigintMissingES2020.ts b/tests/cases/conformance/es2020/bigintMissingES2020.ts index dc2f459e034..bd378f411eb 100644 --- a/tests/cases/conformance/es2020/bigintMissingES2020.ts +++ b/tests/cases/conformance/es2020/bigintMissingES2020.ts @@ -5,4 +5,4 @@ declare function test(): void; test<{t?: string}, object>(); test<{t?: string}, bigint>(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/cases/conformance/es2020/bigintMissingESNext.ts b/tests/cases/conformance/es2020/bigintMissingESNext.ts index f3d90f64bde..8ea758777cc 100644 --- a/tests/cases/conformance/es2020/bigintMissingESNext.ts +++ b/tests/cases/conformance/es2020/bigintMissingESNext.ts @@ -5,4 +5,4 @@ declare function test(): void; test<{t?: string}, object>(); test<{t?: string}, bigint>(); -// should have global error when bigint is used but ES2020 lib is not present +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery.ts b/tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery.ts index 10e8e020158..f82f26607b0 100644 --- a/tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery.ts +++ b/tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery.ts @@ -7,3 +7,10 @@ export class B {}; import * as types from './a'; let A: typeof types.A; let B: typeof types.B; + +let t: typeof types = { + // error: while you can ask for `typeof types.A`, + // `typeof types` does not include `A` + A: undefined as any, + B: undefined as any, +} diff --git a/tests/cases/conformance/jsx/jsxAttributeInitializer.ts b/tests/cases/conformance/jsx/jsxAttributeInitializer.ts new file mode 100644 index 00000000000..95e4c668205 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxAttributeInitializer.ts @@ -0,0 +1,10 @@ +// @jsx: preserve, react +// @filename: a.tsx +declare var React: any; + +
+
/> +
foo
/> +
foo
/> +
+
diff --git a/tests/cases/conformance/salsa/constructorNameInAccessor.ts b/tests/cases/conformance/salsa/constructorNameInAccessor.ts new file mode 100644 index 00000000000..878c4b8dc78 --- /dev/null +++ b/tests/cases/conformance/salsa/constructorNameInAccessor.ts @@ -0,0 +1,5 @@ +// @target: esnext +class C1 { + get constructor() { return } + set constructor(value) {} +} diff --git a/tests/cases/conformance/salsa/constructorNameInGenerator.ts b/tests/cases/conformance/salsa/constructorNameInGenerator.ts new file mode 100644 index 00000000000..7040fb40baa --- /dev/null +++ b/tests/cases/conformance/salsa/constructorNameInGenerator.ts @@ -0,0 +1,4 @@ +// @target: esnext +class C2 { + *constructor() {} +}