Skip to content

More invalid JSDoc generate cases #38626

Closed

Description

TypeScript Version: 4.0.0-dev.20200516

Search Terms:: JSDoc invalid dts

Code

/**
  * @param {Array=} y desc
  */
function x(y) {}

/**
  * @param {function (Olm.InboundGroupSession)} func Invoked
 */
function y(func) {}

/**
 * @return {(Array.<> | null)} list of devices
 */
function z() {}

/**
 * 
 * @return {?Promise} A promise
 */
function w() {}
Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "checkJs": true,
    "allowJs": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}

Invalid outputs:

/**
  * @param {Array=} y desc
  */
declare function x(y?: Array | undefined): void;
// ~~~~~~~~~~~~~~~~~~~~~~~~~^ Missing generics

/**
  * @param {function (Olm.InboundGroupSession)} func Invoked
 */
declare function y(func: (arg0: any) => ): void;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ invalid type signature

/**
 * @return {(Array.<> | null)} list of devices
 */
declare function z(): (Array | null);
// ~~~~~~~~~~~~~~~~~~~~~~~~~^ missing generics

/**
 *
 * @return {?Promise} A promise
 */
declare function w(): Promise | null;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~^ missing generics

Playground Link: Provided

Activity

  1. Jack-Works commented on May 18, 2020

    @Jack-Works
    ContributorAuthor

    And seems like fix in #38368 doesn't work on the return value

    /**
     * 
     * @return {promise} A promise
     */
    function w() {}
    /**
     *
     * @return {promise} A promise
     */
    declare function w(): any;
  2. Jack-Works commented on May 25, 2020

    @Jack-Works
    ContributorAuthor
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions