Back to Type Challenges

README

questions/02693-medium-endswith/README.md

latest1.8 KB
Original Source
<!--info-header-start--><h1>EndsWith </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/2693/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> </p><!--info-header-end-->

Implement EndsWith<T, U> which takes two exact string types and returns whether T ends with U

For example:

typescript
type a = EndsWith<'abc', 'bc'> // expected to be true
type b = EndsWith<'abc', 'abc'> // expected to be true
type c = EndsWith<'abc', 'd'> // expected to be false
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/2693/answer" target="_blank"></a> <a href="https://tsch.js.org/2693/solutions" target="_blank"></a> <hr><h3>Related Challenges</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/02688-medium-startswith/README.md" target="_blank"></a> <!--info-footer-end-->