Skip to content

Fixes subset of bugs (three tests fixed) listed in issue #41974 #44367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9885,7 +9885,12 @@ namespace ts {
}
else {
type = errorType;
error(isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
if (declaration.kind === SyntaxKind.JSDocEnumTag) {
error(declaration.typeExpression.type, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
else {
error(isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
}
links.declaredType = type;
}
Expand Down Expand Up @@ -32799,7 +32804,7 @@ namespace ts {
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
const tag = isInJSFile(node) ? getJSDocTypeTag(node) : undefined;
if (tag) {
return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode);
}
return checkExpression(node.expression, checkMode);
}
Expand Down Expand Up @@ -35043,12 +35048,14 @@ namespace ts {
// Include the `<>` in the error message
: rangeOfTypeParameters(sourceFile, parent.typeParameters!);
const only = parent.typeParameters!.length === 1;
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
const message = only ? Diagnostics._0_is_declared_but_its_value_is_never_read : Diagnostics.All_type_parameters_are_unused;
const arg0 = only ? name : undefined;
addDiagnostic(typeParameter, UnusedKind.Parameter, createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0));
}
}
else {
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
addDiagnostic(typeParameter, UnusedKind.Parameter, createDiagnosticForNode(typeParameter, Diagnostics._0_is_declared_but_its_value_is_never_read, name));
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/enumTagCircularReference.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/jsdoc/bug27142.js(1,5): error TS2456: Type alias 'E' circularly references itself.
tests/cases/conformance/jsdoc/bug27142.js(1,12): error TS2456: Type alias 'E' circularly references itself.


==== tests/cases/conformance/jsdoc/bug27142.js (1 errors) ====
/** @enum {E} */
~~~~~~~~~~
~
!!! error TS2456: Type alias 'E' circularly references itself.
const E = { x: 0 };

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/compiler/Main.js(2,14): error TS2352: Conversion of type 'string' to type 'typeof _default' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/compiler/Main.js(2,21): error TS2352: Conversion of type 'string' to type 'typeof _default' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.


==== tests/cases/compiler/GeometryType.d.ts (0 errors) ====
Expand All @@ -12,7 +12,7 @@ tests/cases/compiler/Main.js(2,14): error TS2352: Conversion of type 'string' to
==== tests/cases/compiler/Main.js (1 errors) ====
export default function () {
return /** @type {import('./GeometryType.js').default} */ ('Point');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type 'string' to type 'typeof _default' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
}

20 changes: 10 additions & 10 deletions tests/baselines/reference/jsdocTypeTagCast.errors.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/conformance/jsdoc/b.js(4,13): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(45,16): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(4,20): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(45,23): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'.
tests/cases/conformance/jsdoc/b.js(49,19): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(49,26): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p
tests/cases/conformance/jsdoc/b.js(51,17): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(51,24): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'.
tests/cases/conformance/jsdoc/b.js(52,17): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/jsdoc/b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'.
tests/cases/conformance/jsdoc/b.js(58,1): error TS2322: Type 'SomeFakeClass' is not assignable to type 'SomeBase'.
Types of property 'p' are incompatible.
Expand All @@ -26,7 +26,7 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u
var W = /** @type {string} */(/** @type {*} */ (4));

var W = /** @type {string} */(4); // Error
~~~~~~~~~~~~~~~
~~~~~~
!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

/** @type {*} */
Expand Down Expand Up @@ -69,25 +69,25 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u
someBase = /** @type {SomeBase} */(someDerived);
someBase = /** @type {SomeBase} */(someBase);
someBase = /** @type {SomeBase} */(someOther); // Error
~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'.
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:17:9: 'p' is declared here.

someDerived = /** @type {SomeDerived} */(someDerived);
someDerived = /** @type {SomeDerived} */(someBase);
someDerived = /** @type {SomeDerived} */(someOther); // Error
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~
!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p

someOther = /** @type {SomeOther} */(someDerived); // Error
~~~~~~~~~~~~~~~~~~
~~~~~~~~~
!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'.
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:28:9: 'q' is declared here.
someOther = /** @type {SomeOther} */(someBase); // Error
~~~~~~~~~~~~~~~~~~
~~~~~~~~~
!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'.
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:28:9: 'q' is declared here.
Expand Down