{ accessToken: string; source: string; }' is not assignable to parameter of type '(value: string) => PromiseLike<never>'. Type 'Promise<never> |

Hello everyone,

I am getting typescript error when going to build app by ionic package build app working fine on desktop error is:
/**------------------------------------------------- Error

Argument of type 
'(accessToken: string) => Promise<never> | { accessToken: string; source: string; }' 
is not assignable to parameter of type '(value: string) => PromiseLike<never>'. Type 'Promise<never> | { 
accessToken: string; source: string; }' 

is not assignable to type 'PromiseLike<never>'. Type '{ accessToken: string; source: string; }' is not assignable to type 'PromiseLike<never>'. Property 'then' is missing in type '{ accessToken: string; source: string; }'.    
                                                                                                                                                                                                                                                                                      
L14:  login(source: string): Promise<string> {                                                                                                                          
L15: return this.getOAuthService(source).login().then(accessToken => {                                                                                     
L16: if (!accessToken) {

and My function is:

login(source: string): Promise<string> {
		return this.getOAuthService(source).login().then(accessToken => {
			if (!accessToken) {
				return Promise.reject('No access token found');
			}
let oauthToken = {
				accessToken: accessToken,
				source: source
			};
			this.setOAuthToken(oauthToken);
			return oauthToken;
		});
	}

Please help me out what I wrote wrong?

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

Where do you get this error?
How are you building locally?
What is the exact command for Ionic Package?
Also: What is your ionic info output?

@ionic/cli-plugin-cordova       : 1.6.2                                                                                                                                
@ionic/cli-plugin-ionic-angular : 1.4.1                                                                                                                                 
@ionic/cli-utils                : 1.7.0                                                                                                                                 
ionic (Ionic CLI)               : 3.7.0                                                                                                                                                                                                                                                                                                     
global packages:                                                                                                                                                                                                                                                                                                                                    
Cordova CLI : 7.0.1                                                                                                                                                                                                                                                                                                                         
local packages:                                                                                                                                                                                                                                                                                                                                     
@ionic/app-scripts : 2.0.2                                                                                                                                              
Cordova Platforms  : android 6.2.3                                                                                                                                      
Ionic Framework    : ionic-angular 3.6.0                                                                                                                                                                                                                                                                                                    
System:                                                                                                                                                                                                                                                                                                                                             
        Node : v6.10.3                                                                                                                                                         
OS   : Windows 10                                                                                                                                                        
npm  : 3.10.10
1 Like

I am getting this error when I am trying to build my app using
ionic package build
and ionic cordova build

Your method is defined as returning a Promise, that resolves as a string later on. You can’t just return a string directly.

Something is wrong with your core library typings situation. Can you please post package.json and tsconfig.json?