Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings - Lack of optional parameters #140

Closed
aistrych opened this issue Aug 8, 2018 · 3 comments
Closed

Typings - Lack of optional parameters #140

aistrych opened this issue Aug 8, 2018 · 3 comments

Comments

@aistrych
Copy link

aistrych commented Aug 8, 2018

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

@johnnyreilly
Copy link
Member

Sure - if you'd like to submit a PR we can get it in the next release?

@aistrych
Copy link
Author

aistrych commented Aug 8, 2018

Ok, thanks. I will do it tomorrow.

@Larry1123
Copy link
Contributor

Oh I just submitted a PR for this #141

@aistrych aistrych closed this as completed Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants