Closed regseb closed 4 months ago
The issue is apparently instead that a generic cannot be indicated in the name like this: @typedef Foo<T>
. See the other examples for what is currently allowable.
Does TypeScript accept this form of JSDoc? I don't see it at https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template .
You're right, the error is reported with a single @typedef
.
I tested the following file in TS Playground. Without a generic or with an invalid generic, TypeScript returns the same errors (number not assignable to string). The <T>
shouldn't be added to the @typedef
.
/**
* @template {Object} T
* @typedef Foo<OUPS_I_MAKE_A_TYPO>
* @prop {T} bar
*/
/**
* @type {Foo<string>}
*/
const fooValid = { bar: "" };
/**
* @type {Foo<string>}
*/
const fooInvalid = { bar: 0 };
// ~~~
/**
* @template {Object} T
* @typedef Baz
* @prop {T} qux
*/
/**
* @type {Baz<string>}
*/
const bazValid = { qux: "" };
/**
* @type {Baz<string>}
*/
const bazInvalid = { qux: 0 };
// ~~~
eslint-plugin-jsdoc should report a syntax error for a JSDoc comment with <T>
.
Yeah, I think that is a dupe of #374.
The No parslet found for token: 'EOF'
error isn't related to @template
. I have the error with the following code.
/**
* @typedef Foo
* @prop {string} bar
*/
And no error with:
/**
* @typedef {Object} Foo
* @prop {string} bar
*/
In the examples in the TypeScript documentation, the type is always specified. But tsc
supports when it's not specified.
Ah, great to know the playground can have tsconfig set to JavaScript. Wasn't aware of that.
I have confirmed the bug as you report now, yes. For now, I can change to silently ignore such parse errors here as when there is no type present, but I'll leave the issue open to try to handle the case for use of @property
types. That sound reasonable?
:tada: This issue has been resolved in version 48.8.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Expected behavior
eslint-plugin-jsdoc should support two
@template
in one file.Actual behavior
ESLint Config
ESLint sample
Environment
eslint-plugin-jsdoc
version: 48.8.1