You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type not assignable for string literal in signature #38201
Search Terms:
string literal
string alias
is not assignable to parameter of type
Expected behavior:
No type check errors
Actual behavior:
No overload matches this call.
The last overload gave the following error.
Argument of type 'tAlgorithm' is not assignable to parameter of type '"oct"'.
Type '"EC"' is not assignable to type '"oct"'.
Sorry to not also link to the more general problem earlier on (it would've spared you some time): #1805 has some explanation on why the pattern is currently not supported.
Though, since then, I can sort of imagine us doing better given some of the work that went into #30779.
However, I think that even with the ideas of #30799 incorporated, it wouldn't help you write the original code easily without a type assertion or duplicate overloads.
Activity
WangHansen commentedon Apr 26, 2020
Another reproduction link: https://codesandbox.io/s/laughing-shockley-hlpr1?file=/src/index.ts
DanielRosenwasser commentedon Apr 27, 2020
This clearly shouldn't work given that
generateKey("EC", 128)can be substituted withand shouldn't match any overload.
WangHansen commentedon Apr 27, 2020
Daniel Rosenwasser (@DanielRosenwasser) Correct, but that is not what the error message is suggesting.
Also, what about the following?
This still gives the error.
Playground
Also, could you provide an alternative approach for this function if I want to pass string literals as a parameter of the function?
DanielRosenwasser commentedon Apr 27, 2020
Sorry to not also link to the more general problem earlier on (it would've spared you some time): #1805 has some explanation on why the pattern is currently not supported.
Though, since then, I can sort of imagine us doing better given some of the work that went into #30779.
DanielRosenwasser commentedon Apr 27, 2020
However, I think that even with the ideas of #30799 incorporated, it wouldn't help you write the original code easily without a type assertion or duplicate overloads.
typescript-bot commentedon Apr 29, 2020
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.