3b222fe80c
Previously, the error span was too large on @type errors on functions when the type was not a function. The span covered the entire tag. This PR changes the error node just to be the type of the type tag. In other words, the error span was previously this: ``` @type {IncorrectType} ``` But is now just this: ``` IncorrectType ``` Fixes the first error from #41974, but not the other two. Co-authored-by: Ashya Manning <ashyamanning@pursuit.org> Co-authored-by: Nilber Remon <nilberremon@gmail.com> Co-authored-by: Ashya Manning <ashyamanning@pursuit.org> Co-authored-by: Nilber Remon <nilberremon@gmail.com>
64 lines
2.9 KiB
Plaintext
64 lines
2.9 KiB
Plaintext
tests/cases/conformance/jsdoc/test.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(7,24): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(10,17): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(14,24): error TS2322: Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/jsdoc/test.js(28,12): error TS8030: The type of a function declaration must match the function's signature.
|
|
tests/cases/conformance/jsdoc/test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'.
|
|
Type '1' is not assignable to type '2 | 3'.
|
|
|
|
|
|
==== tests/cases/conformance/jsdoc/test.js (8 errors) ====
|
|
// all 6 should error on return statement/expression
|
|
/** @type {(x: number) => string} */
|
|
function h(x) { return x }
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
/** @type {(x: number) => string} */
|
|
var f = x => x
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
/** @type {(x: number) => string} */
|
|
var g = function (x) { return x }
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
|
|
/** @type {{ (x: number): string }} */
|
|
function i(x) { return x }
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
/** @type {{ (x: number): string }} */
|
|
var j = x => x
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
/** @type {{ (x: number): string }} */
|
|
var k = function (x) { return x }
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
|
|
|
|
/** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */
|
|
/** @type {Argle} */
|
|
function blargle(s) {
|
|
return 0;
|
|
}
|
|
|
|
/** @type {0 | 1 | 2} - assignment should not error */
|
|
var zeroonetwo = blargle('hi')
|
|
|
|
/** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */
|
|
|
|
/** @type {Gioconda} */
|
|
~~~~~~~~
|
|
!!! error TS8030: The type of a function declaration must match the function's signature.
|
|
function monaLisa(sb) {
|
|
return typeof sb === 'string' ? 1 : 2;
|
|
}
|
|
|
|
/** @type {2 | 3} - overloads are not supported, so there will be an error */
|
|
var twothree = monaLisa(false);
|
|
~~~~~~~~
|
|
!!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'.
|
|
!!! error TS2322: Type '1' is not assignable to type '2 | 3'.
|
|
|