Skip to content

Is transform overload unnecessary? #3089

@zoeyzhao19

Description

@zoeyzhao19

esbuild transform api has an overload type declaration

export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>>
export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>

Which I might think it respect custom options extended from TransformOptions, But when I pass my option which is extended from TransformOptions,

transform('function(){console.log("Hello World")}', {
  loader: 'ts',
  customOptionFlag: true,
})

My custom option could not pass and it reported Error: Invalid option in transform() call: "customOptionFlag".
and my ts check does not report the wrong type. Since esbuild does not handle user's custom transform option, so I doubt that whether is this transform overload necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions