Skip to content

Fix types of core getConfig#8362

Merged
devongovett merged 2 commits into
parcel-bundler:v2from
tanishqkancharla:core-getConfig-types
Oct 25, 2022
Merged

Fix types of core getConfig#8362
devongovett merged 2 commits into
parcel-bundler:v2from
tanishqkancharla:core-getConfig-types

Conversation

@tanishqkancharla

Copy link
Copy Markdown
Contributor

↪️ 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)
  • Included links to related issues/PRs

@devongovett devongovett merged commit 96d8f28 into parcel-bundler:v2 Oct 25, 2022
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

Successfully merging this pull request may close these issues.

2 participants