Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Function setup-haskell.run has incorrect type #121

Open
wenkokke opened this issue Oct 14, 2022 · 0 comments
Open

Function setup-haskell.run has incorrect type #121

wenkokke opened this issue Oct 14, 2022 · 0 comments
Labels
re: inputs Concerning handling the inputs to this action refactor Concerning refactoring the code base
Milestone

Comments

@wenkokke
Copy link

The function run in setup-haskell.ts has the following type:

async function run(inputs: Record<string, string>): Promise<void>

The type Record<string, string> is the type of objects which map any string to a string. The inputs, however, only has the properties ghc-version, cabal-version, stack-version, enable-stack, stack-no-global, stack-setup-ghc, and disable-matcher, and will return undefined for any other properties.

Therefore a more correct type would be Record<string, string | undefined> and the exact type would be something along the lines of:

export type SetupInputName =
  | 'ghc-version'
  | 'cabal-version'
  | 'stack-version'
  | 'enable-stack'
  | 'stack-no-global'
  | 'stack-setup-ghc'
  | 'disable-matcher'

export type SetupInputs = Record<SetupInputName, string>

...or:

export interface SetupInputs {
  'ghc-version': string
  'cabal-version': string
  'stack-version': string
  'enable-stack': string
  'stack-no-global': string
  'stack-setup-ghc': string
  'disable-matcher': string
}

The same problem applies to the type given to yamlInputs in opts.ts, which promises a default value for every possible string, while one isn't even provided for all of the default options. Therefore, a more correct type would be either Record<string, {default: string} | undefined> or:

export type SetupInputWithDefaultName =
  | 'ghc-version'
  | 'cabal-version'
  | 'stack-version'

export type SetupInputDefaults = Record<SetupInputWithDefaultName, {default: string}>

...or the more-or-less equivalent interface, as above.

(When taking the first approach, you could embed SetupInputWithDefaultName into SetupInputName.)

@andreasabel andreasabel added refactor Concerning refactoring the code base re: inputs Concerning handling the inputs to this action labels Jan 5, 2023
@andreasabel andreasabel added this to the 3.0.0 milestone Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
re: inputs Concerning handling the inputs to this action refactor Concerning refactoring the code base
Projects
None yet
Development

No branches or pull requests

2 participants