Skip to content

Commit 9c50cb9

Browse files
authored
Fixes subset of bugs (three tests fixed) listed in issue #41974 (#44367)
* some fixes for 41974 * linted * fixed todo messages for readability
1 parent df6e3af commit 9c50cb9

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/compiler/checker.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -9896,7 +9896,12 @@ namespace ts {
98969896
}
98979897
else {
98989898
type = errorType;
9899-
error(isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
9899+
if (declaration.kind === SyntaxKind.JSDocEnumTag) {
9900+
error(declaration.typeExpression.type, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
9901+
}
9902+
else {
9903+
error(isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
9904+
}
99009905
}
99019906
links.declaredType = type;
99029907
}
@@ -32821,7 +32826,7 @@ namespace ts {
3282132826
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
3282232827
const tag = isInJSFile(node) ? getJSDocTypeTag(node) : undefined;
3282332828
if (tag) {
32824-
return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
32829+
return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode);
3282532830
}
3282632831
return checkExpression(node.expression, checkMode);
3282732832
}
@@ -35065,12 +35070,14 @@ namespace ts {
3506535070
// Include the `<>` in the error message
3506635071
: rangeOfTypeParameters(sourceFile, parent.typeParameters!);
3506735072
const only = parent.typeParameters!.length === 1;
35073+
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
3506835074
const message = only ? Diagnostics._0_is_declared_but_its_value_is_never_read : Diagnostics.All_type_parameters_are_unused;
3506935075
const arg0 = only ? name : undefined;
3507035076
addDiagnostic(typeParameter, UnusedKind.Parameter, createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0));
3507135077
}
3507235078
}
3507335079
else {
35080+
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
3507435081
addDiagnostic(typeParameter, UnusedKind.Parameter, createDiagnosticForNode(typeParameter, Diagnostics._0_is_declared_but_its_value_is_never_read, name));
3507535082
}
3507635083
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/jsdoc/bug27142.js(1,5): error TS2456: Type alias 'E' circularly references itself.
1+
tests/cases/conformance/jsdoc/bug27142.js(1,12): error TS2456: Type alias 'E' circularly references itself.
22

33

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

tests/baselines/reference/jsdocImportTypeNodeNamespace.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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.
1+
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.
22

33

44
==== tests/cases/compiler/GeometryType.d.ts (0 errors) ====
@@ -12,7 +12,7 @@ tests/cases/compiler/Main.js(2,14): error TS2352: Conversion of type 'string' to
1212
==== tests/cases/compiler/Main.js (1 errors) ====
1313
export default function () {
1414
return /** @type {import('./GeometryType.js').default} */ ('Point');
15-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616
!!! 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.
1717
}
1818

tests/baselines/reference/jsdocTypeTagCast.errors.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
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.
2-
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.
1+
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.
2+
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.
33
Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'.
4-
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.
4+
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.
55
Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p
6-
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.
6+
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.
77
Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'.
8-
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.
8+
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.
99
Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'.
1010
tests/cases/conformance/jsdoc/b.js(58,1): error TS2322: Type 'SomeFakeClass' is not assignable to type 'SomeBase'.
1111
Types of property 'p' are incompatible.
@@ -26,7 +26,7 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u
2626
var W = /** @type {string} */(/** @type {*} */ (4));
2727

2828
var W = /** @type {string} */(4); // Error
29-
~~~~~~~~~~~~~~~
29+
~~~~~~
3030
!!! 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.
3131

3232
/** @type {*} */
@@ -69,25 +69,25 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u
6969
someBase = /** @type {SomeBase} */(someDerived);
7070
someBase = /** @type {SomeBase} */(someBase);
7171
someBase = /** @type {SomeBase} */(someOther); // Error
72-
~~~~~~~~~~~~~~~~~
72+
~~~~~~~~
7373
!!! 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.
7474
!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'.
7575
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:17:9: 'p' is declared here.
7676

7777
someDerived = /** @type {SomeDerived} */(someDerived);
7878
someDerived = /** @type {SomeDerived} */(someBase);
7979
someDerived = /** @type {SomeDerived} */(someOther); // Error
80-
~~~~~~~~~~~~~~~~~~~~
80+
~~~~~~~~~~~
8181
!!! 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.
8282
!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p
8383

8484
someOther = /** @type {SomeOther} */(someDerived); // Error
85-
~~~~~~~~~~~~~~~~~~
85+
~~~~~~~~~
8686
!!! 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.
8787
!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'.
8888
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:28:9: 'q' is declared here.
8989
someOther = /** @type {SomeOther} */(someBase); // Error
90-
~~~~~~~~~~~~~~~~~~
90+
~~~~~~~~~
9191
!!! 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.
9292
!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'.
9393
!!! related TS2728 tests/cases/conformance/jsdoc/b.js:28:9: 'q' is declared here.

0 commit comments

Comments
 (0)