Back to Type Challenges

README

questions/04518-medium-fill/README.md

latest1.6 KB
Original Source
<!--info-header-start--><h1>Fill </h1><blockquote><p>by キリサメ qianxi <a href="https://github.com/qianxi0410" target="_blank">@qianxi0410</a></p></blockquote><p><a href="https://tsch.js.org/4518/play" target="_blank"></a> </p><!--info-header-end-->

Fill, a common JavaScript function, now let us implement it with types. Fill<T, N, Start?, End?>, as you can see,Fill accepts four types of parameters, of which T and N are required parameters, and Start and End are optional parameters. The requirements for these parameters are: T must be a tuple, N can be any type of value, Start and End must be integers greater than or equal to 0.

ts
type exp = Fill<[1, 2, 3], 0> // expected to be [0, 0, 0]

In order to simulate the real function, the test may contain some boundary conditions, I hope you can enjoy it :)

<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/4518/answer" target="_blank"></a> <a href="https://tsch.js.org/4518/solutions" target="_blank"></a> <!--info-footer-end-->