Skip to content

TypeScript generates invalid types if @import tags are spread over multiple linesΒ #59011

@remcohaszing

Description

@remcohaszing

πŸ”Ž Search Terms

β€œimport”

πŸ•— Version & Regression Information

  • This changed between versions 5.4 and 5.5
  • I was unable to test this on prior versions because this feature was introduced in TypeScript 5.5

⏯ Playground Link

https://github.com/remcohaszing/typescript-jsdoc-import-bug

πŸ’» Code

/**
 * @import {
 *   Program
 * } from 'estree'
 */

/**
 * @param {Program} program
 */
export function compile(program) {}

πŸ™ Actual behavior

TypeScript emits the following type invalid definition:

/**
 * @import {
 *   Program
 * } from 'estree'
 */
/**
 * @param {Program} program
 */
export function compile(program: *   Program): void;
import type { Program } from 'estree';

πŸ™‚ Expected behavior

TypeScript emits the following valid type definition:

/**
 * @import {
 *   Program
 * } from 'estree'
 */
/**
 * @param {Program} program
 */
export function compile(program: Program): void;
import type { Program } from 'estree';

Additional information about the issue

This bug does not appear in the playground, only when running tsc locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesDomain: JSDocRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallyFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions