parcel icon indicating copy to clipboard operation
parcel copied to clipboard

Fix types of core `getConfig`

Open tanishqkancharla opened this issue 1 year ago β€’ 0 comments

β†ͺ️ Pull Request

Previously getConfig was typed in flow as:

getConfig<T>(
    filePaths: Array<FilePath>,
    options: ?{|
      packageKey?: string,
      parse?: boolean,
      exclude?: boolean,
    |},
  ): Promise<?ConfigResultWithFilePath<T>>;

This generates the ts type definition

getConfig<WebsiteContext>(filePaths: string[], options: {
    packageKey?: string | undefined;
    parse?: boolean | undefined;
    exclude?: boolean | undefined;
} | null | undefined): Promise<…>

Unfortunately, this means the second argument is required in typescript when it’s really not. This PR makes it so the corresponding type definitions of typescript mark the argument as optional.

πŸ’» Examples

N/A

🚨 Test instructions

Run npm run build-ts and see if the output correctly generates optional types for getConfig and getConfigFrom.

βœ”οΈ PR Todo

  • [-] Added/updated unit tests for this change
  • [-] Filled out test instructions (In case there aren't any unit tests)
  • [x] Included links to related issues/PRs

tanishqkancharla avatar Aug 04 '22 04:08 tanishqkancharla