Skip to content

Typings - Lack of optional parameters #140

@aistrych

Description

@aistrych

ForkTsCheckerWebpackPlugin require Option type as a parameter but all keys in it are required. For that reason user has to pass all options to the plugin which shouldn't be the case. What with default values? It's also impossible to cast passed object to Option type: Options interface is not exported. This is now impossible:

new ForkTsCheckerWebpackPlugin({
    tsconfig: "../../tsconfig.json",
    tslint: "../../tslint.json",
    watch: ["./app"],
    workers: ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE
})

because Typescript emits:

[ts]
Argument of type '{ tsconfig: string; tslint: string; watch: string[]; workers: number; }' is not assignable to parameter of type 'Options'.
  Property 'async' is missing in type '{ tsconfig: string; tslint: string; watch: string[]; workers: number; }'.

After adding 'async' it starts to complain about other parameters.

I believe some keys in that interface should be optional:

interface Options {
  tsconfig: string;
  tslint: string | true;
  watch: string | string[];
  async: boolean;
  ignoreDiagnostics: number[];
  ignoreLints: string[];
  colors: boolean;
  logger: Console;
  formatter: 'default' | 'codeframe' | Formatter;
  formatterOptions: any;
  silent: boolean;
  checkSyntacticErrors: boolean;
  memoryLimit: number;
  workers: number;
  vue: boolean;
}

typescript version: 3.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions