是否可以使传递给函数的value成为TypeScript
中的部分字符串(即子字符串
有没有类似的事情?
function transform( str: Substring<'Hello world'> ) {
// ...
}
然后,当我调用该函数时,我可以传递该字符串的子字符串
transform( 'world' );
// or
transform( 'Hello' );
// or
transform( 'ello' ); // Is valid because it exists in hello
// or
transform( 'orl' ); // Is valid because it exists in world
// Is not valid, altough individual letters exists
// they are not in the right order
transform( 'hlowrld' )