vue-authenticate icon indicating copy to clipboard operation
vue-authenticate copied to clipboard

Add typescript types

Open ilari-makimattila opened this issue 6 years ago • 7 comments

Add definition files for Typescript. Fixes #117.

HTTP request and response are typed to corresponding axios objects. Mainly because I don't have motivation to test other providers.

ilari-makimattila avatar Sep 04 '18 12:09 ilari-makimattila

Suggestion - in index.d.ts, add a constructor to the VueAuthenticate class declaration so it can be instantiated with new, as per the Vuex example in the README.

eg:

import {AxiosResponse, AxiosRequestConfig, AxiosInstance} from 'axios';

export declare class VueAuthenticate {
  public constructor($http: AxiosInstance, overrideOptions: AuthenticateOptions);
  
  // .. other method declarations 
}

pansapiens avatar Sep 18 '18 00:09 pansapiens

Also, withCredentials seems to be a valid flag for AuthenticateOptions and should be added.

export interface AuthenticateOptions {
  withCredentials?: boolean;
}

pansapiens avatar Sep 18 '18 00:09 pansapiens

Thanks. I added the missing definitions. In the meantime I stopped using this library because it's missing some features I needed and it turned out to be more effective to just write one myself. I'm happy to support with merging this though.

ilari-makimattila avatar Sep 18 '18 12:09 ilari-makimattila

Hi @ilari-makimattila , thanks for this PR. Can you please tell me which features are the key ones and the reason why you stopped using VueAuthenticate?

One thing bothers me here. You made typings for Axios only ($http: AxiosInstance), but this library can use any request library (previously, Vue-resource was default library). What happens when you pass Vue-resource library to handle network requests?

I see that you don't have motivation to test other libraries, but i can't merge half-finished work into master.

dgrubelic avatar Oct 20 '18 12:10 dgrubelic

We decided to go with a hosted solution instead of managing our own user database and it felt easiest to just write a vue plugin instead of looking for an existing solution.

These types would more or less force any typescript user to use axios. But to be honest I don't really know how to write the type declarations in a way that wouldn't force the you to do explicit casts for every return value.

ilari-makimattila avatar Oct 23 '18 13:10 ilari-makimattila

Hi, what is the status of this? I see there has been no activity in a while and the contributor who started it has stopped using this library. Is is worth picking up or are there no plans to integrate types?

Cheers

mewis avatar Dec 05 '19 18:12 mewis

Please see https://github.com/dgrubelic/vue-authenticate/pull/196

abeven avatar Feb 20 '20 21:02 abeven