@@ -98,23 +98,22 @@ export const pollForToken = async ({ api, ticket }) => {
98
98
try {
99
99
const accessToken = await api . getAccessToken ( ticket , { timeout : TOKEN_TIMEOUT } )
100
100
if ( ! accessToken ) {
101
- error ( 'Could not retrieve access token' )
101
+ return error ( 'Could not retrieve access token' )
102
102
}
103
- return accessToken
103
+ return accessToken as string
104
104
} catch ( error_ ) {
105
105
// @ts -expect-error TS(2571) FIXME: Object is of type 'unknown'.
106
106
if ( error_ . name === 'TimeoutError' ) {
107
- error (
107
+ return error (
108
108
`Timed out waiting for authorization. If you do not have a ${ chalk . bold . greenBright (
109
109
'Netlify' ,
110
110
) } account, please create one at ${ chalk . magenta (
111
111
'https://app.netlify.com/signup' ,
112
112
) } , then run ${ chalk . cyanBright ( 'netlify login' ) } again.`,
113
113
)
114
- } else {
115
- // @ts -expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
116
- error ( error_ )
117
114
}
115
+ // @ts -expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
116
+ return error ( error_ )
118
117
} finally {
119
118
clearSpinner ( { spinner } )
120
119
}
@@ -123,10 +122,10 @@ export const pollForToken = async ({ api, ticket }) => {
123
122
/**
124
123
* Get a netlify token
125
124
* @param {string } [tokenFromOptions] optional token from the provided --auth options
126
- * @returns {Promise<[null|string, 'flag' | 'env' |'config' |'not found']> }
127
125
*/
128
- // @ts -expect-error TS(7006) FIXME: Parameter 'tokenFromOptions' implicitly has an 'an... Remove this comment to see the full error message
129
- export const getToken = async ( tokenFromOptions ) => {
126
+ export const getToken = async (
127
+ tokenFromOptions : string ,
128
+ ) : Promise < [ null | string , 'flag' | 'env' | 'config' | 'not found' ] > => {
130
129
// 1. First honor command flag --auth
131
130
if ( tokenFromOptions ) {
132
131
return [ tokenFromOptions , 'flag' ]
@@ -186,7 +185,10 @@ export const warn = (message = '') => {
186
185
}
187
186
188
187
/** Throws an error or logs it */
189
- export const error = ( message : Error | string = '' , options : { exit ?: boolean } = { } ) => {
188
+ export function error ( message : Error | string , options : { exit : false } ) : void
189
+ export function error ( message : Error | string ) : never
190
+ export function error ( message : Error | string , options : { exit : true } ) : never
191
+ export function error ( message : Error | string = '' , options : { exit ?: boolean } = { } ) : never | void {
190
192
const err =
191
193
message instanceof Error
192
194
? message
0 commit comments