6666
6767/**
6868 * @public
69- * @param {Options } [defaults]
69+ * @param {Options } [defaults = {} ]
7070 * @returns {redaxios }
7171 */
7272function create ( defaults ) {
@@ -113,15 +113,17 @@ function create(defaults) {
113113
114114 /**
115115 * @private
116- * @param {Record<string,any> } opts
117- * @param {Record<string,any> } [overrides]
116+ * @template T, U
117+ * @param {T } opts
118+ * @param {U } [overrides]
118119 * @param {boolean } [lowerCase]
119- * @returns {Partial<opts> }
120+ * @returns {{} & (T | U) }
120121 */
121122 function deepMerge ( opts , overrides , lowerCase ) {
122- let out = { } ,
123+ let out = /** @type { any } */ ( { } ) ,
123124 i ;
124125 if ( Array . isArray ( opts ) ) {
126+ // @ts -ignore
125127 return opts . concat ( overrides ) ;
126128 }
127129 for ( i in opts ) {
@@ -140,18 +142,15 @@ function create(defaults) {
140142 * Issues a request.
141143 * @public
142144 * @template T
143- * @param {string | Options } url
144- * @param {Options } [config]
145+ * @param {string | Options } urlOrConfig
146+ * @param {Options } [config = {} ]
145147 * @param {any } [_method] (internal)
146148 * @param {any } [data] (internal)
147149 * @param {never } [_undefined] (internal)
148150 * @returns {Promise<Response<T>> }
149151 */
150- function redaxios ( url , config , _method , data , _undefined ) {
151- if ( typeof url !== 'string' ) {
152- config = url ;
153- url = config . url ;
154- }
152+ function redaxios ( urlOrConfig , config , _method , data , _undefined ) {
153+ let url = /** @type {string } */ ( typeof urlOrConfig != 'string' ? ( config = urlOrConfig ) . url : urlOrConfig ) ;
155154
156155 const response = /** @type {Response<any> } */ ( { config } ) ;
157156
@@ -177,7 +176,9 @@ function create(defaults) {
177176 }
178177
179178 try {
179+ // @ts -ignore providing the cookie name without header name is nonsensical anyway
180180 customHeaders [ options . xsrfHeaderName ] = decodeURIComponent (
181+ // @ts -ignore accessing match()[2] throws for no match, which is intentional
181182 document . cookie . match ( RegExp ( '(^|; )' + options . xsrfCookieName + '=([^;]*)' ) ) [ 2 ]
182183 ) ;
183184 } catch ( e ) { }
0 commit comments