Skip to content

Instantly share code, notes, and snippets.

@meandavejustice
Last active July 22, 2019 16:57
Show Gist options
  • Save meandavejustice/b2871b3eb91f991374783843eb762e58 to your computer and use it in GitHub Desktop.
Save meandavejustice/b2871b3eb91f991374783843eb762e58 to your computer and use it in GitHub Desktop.

exp_month and exp_year have a type of number

Argument of type 'string' is not assignable to parameter of type 'number'.  TS2345

  > 80 |   const expirationDate = dayjs().set("month", exp_month)
       |                                               ^
    81 |         .set("year", exp_year)
    82 |         .format("MMMM, YYYY");
    83 |

If I cast exp_year to a string and pass into set() I get the correct result and no error. Which is confusing because the type definition of set calls for a number as the second argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment