Skip to content

factory.createSourceFile doesn't accept JSDoc node (typings issue)Β #44151

Closed
@bali182

Description

@bali182

Bug Report

πŸ”Ž Search Terms

  • factory
  • createSourceFile
  • typings

πŸ•— Version & Regression Information

In v4.2.4 (current latest)

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

import { factory as f, SyntaxKind, NodeFlags } from 'typescript'

const comment = f.createJSDocComment('test', [])
const file = f.createSourceFile(
    [comment], // Error here as createSourceFile needs a Statement array.
    f.createToken(SyntaxKind.EndOfFileToken), 
    NodeFlags.None
)

πŸ™ Actual behavior

Compiler error in factory#createSourceFile when a JSDoc[] node supplied as Statement[] is expected. If it's casted to any, its fine at runtime, so I assume it's just an issue with typings.

πŸ™‚ Expected behavior

Accept JSDoc as a root level element for factory#createSourceFile

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions