Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript types #136

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ilari-makimattila
Copy link

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.

@pansapiens
Copy link

pansapiens commented Sep 18, 2018

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
Copy link

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

export interface AuthenticateOptions {
  withCredentials?: boolean;
}

@ilari-makimattila
Copy link
Author

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.

@dgrubelic
Copy link
Owner

dgrubelic commented Oct 20, 2018

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.

@ilari-makimattila
Copy link
Author

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.

}

export declare class VueAuthenticate {
public constructor($http: AxiosInstance, overrideOptions?: AuthenticateOptions);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May it be that line 3 has to be: import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';

@@ -0,0 +1,7 @@
import { VueAuthenticate } from 'vue-authenticate';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like import Vue from "vue"; is missing here.

@mewis
Copy link

mewis commented Dec 5, 2019

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

@abeven
Copy link

abeven commented Feb 20, 2020

Please see #196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any typescript definition for this?
7 participants