File tree Expand file tree Collapse file tree 4 files changed +26
-9
lines changed
Expand file tree Collapse file tree 4 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 11import _ = require( "../index" ) ;
2- // eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
2+ // eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers, @typescript-eslint/no-unsafe-function-type
33type GlobalFunction = Function ;
44declare module "../index" {
55 type FunctionBase = GlobalFunction ;
Original file line number Diff line number Diff line change @@ -29,19 +29,19 @@ declare module "../index" {
2929 * @param string The string to capitalize.
3030 * @return Returns the capitalized string.
3131 */
32- capitalize ( string ?: string ) : string ;
32+ capitalize < T extends string > ( string ?: T ) : Capitalize < Lowercase < T > > ;
3333 }
3434 interface LoDashImplicitWrapper < TValue > {
3535 /**
3636 * @see _.capitalize
3737 */
38- capitalize ( ) : string ;
38+ capitalize ( ) : Capitalize < Lowercase < TValue extends string ? TValue : never > > ;
3939 }
4040 interface LoDashExplicitWrapper < TValue > {
4141 /**
4242 * @see _.capitalize
4343 */
44- capitalize ( ) : StringChain ;
44+ capitalize ( ) : StringChain < Capitalize < Lowercase < TValue extends string ? TValue : never > > > ;
4545 }
4646
4747 interface LoDashStatic {
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ declare namespace _ {
240240 type LodashBindKey1x1 = ( key : string ) => ( ...args : any [ ] ) => any ;
241241 type LodashBindKey1x2 = ( object : object ) => ( ...args : any [ ] ) => any ;
242242 type LodashCamelCase = ( string : string ) => string ;
243- type LodashCapitalize = ( string : string ) => string ;
243+ type LodashCapitalize = < T extends string > ( string : T ) => Capitalize < Lowercase < T > > ;
244244 type LodashCastArray = < T > ( value : lodash . Many < T > ) => T [ ] ;
245245 type LodashCeil = ( n : number ) => number ;
246246 interface LodashChunk {
Original file line number Diff line number Diff line change @@ -6623,10 +6623,27 @@ fp.now(); // $ExpectType number
66236623
66246624// _.capitalize
66256625{
6626- _ . capitalize ( "fred" ) ; // $ExpectType string
6627- _ ( "fred" ) . capitalize ( ) ; // $ExpectType string
6628- _ . chain ( "fred" ) . capitalize ( ) ; // $ExpectType StringChain<string>
6629- fp . capitalize ( "fred" ) ; // $ExpectType string
6626+ _ . capitalize ( "fred" ) ; // $ExpectType "Fred"
6627+ _ . capitalize ( "FRED" ) ; // $ExpectType "Fred"
6628+ _ . capitalize ( "fred" as string ) ; // $ExpectType Capitalize<Lowercase<string>>
6629+ // @ts -expect-error cannot assign non string type
6630+ _ . capitalize ( 123 ) ;
6631+
6632+ _ ( "fred" ) . capitalize ( ) ; // $ExpectType "Fred"
6633+ _ ( "FRED" ) . capitalize ( ) ; // $ExpectType "Fred"
6634+ _ ( "fred" as string ) . capitalize ( ) ; // $ExpectType Capitalize<Lowercase<string>>
6635+ _ ( 123 ) . capitalize ( ) ; // $ExpectType never
6636+
6637+ _ . chain ( "fred" ) . capitalize ( ) ; // $ExpectType StringChain<"Fred">
6638+ _ . chain ( "FRED" ) . capitalize ( ) ; // $ExpectType StringChain<"Fred">
6639+ _ . chain ( "fred" as string ) . capitalize ( ) ; // $ExpectType StringChain<Capitalize<Lowercase<string>>>
6640+ _ . chain ( 123 ) . capitalize ( ) ; // $ExpectType StringChain<never>
6641+
6642+ fp . capitalize ( "fred" ) ; // $ExpectType "Fred"
6643+ fp . capitalize ( "FRED" ) ; // $ExpectType "Fred"
6644+ fp . capitalize ( "fred" as string ) ; // $ExpectType Capitalize<Lowercase<string>>
6645+ // @ts -expect-error cannot assign non string type
6646+ fp . capitalize ( 123 ) ;
66306647}
66316648
66326649// _.deburr
You can’t perform that action at this time.
0 commit comments