Skip to content

Commit 9c3f5ed

Browse files
authoredJan 27, 2023
Merge pull request #35 from syetalabs/global-types
feat: Typings for GSI client
2 parents 4d8d60e + 6a5bab5 commit 9c3f5ed

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed
 

‎package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/@types/globals.d.ts ‎src/@types/globals.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import { CodeClient } from "../interfaces/oauth2";
1+
import type {
2+
CodeClient,
3+
CodeClientConfig,
4+
OverridableTokenClientConfig,
5+
TokenClientConfig,
6+
TokenResponse,
7+
} from "../interfaces/oauth2";
28

3-
import {
9+
import type {
410
IdConfiguration,
511
MomentListener,
612
GsiButtonConfiguration,
713
RevocationCallback,
8-
} from "@/interfaces/accounts";
14+
} from "../interfaces/accounts";
915

1016
declare global {
1117
interface Window {
@@ -51,3 +57,5 @@ declare global {
5157
};
5258
}
5359
}
60+
61+
export default {};

‎src/composables/useCodeClient.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export default function useCodeClient(
129129
});
130130

131131
client = window.google?.accounts.oauth2.initCodeClient({
132-
client_id: clientId,
132+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
133+
client_id: clientId!,
133134
scope: computedScopes,
134135
callback: (response: CodeResponse) => {
135136
if (response.error) return onError?.(response);

‎src/composables/useTokenClient.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export default function useTokenClient(
111111
: scopeValue;
112112

113113
client = window.google?.accounts.oauth2.initTokenClient({
114-
client_id: clientId,
114+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
115+
client_id: clientId!,
115116
scope: `openid email profile ${scopes}`,
116117
callback: (response: TokenResponse) => {
117118
if (response.error) return onError?.(response);

‎src/plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ export type {
8282
AuthCodeFlowErrorResponse,
8383
AuthCodeFlowSuccessResponse,
8484
};
85+
export * from "./@types/globals";
8586

8687
export default plugin;

‎tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"DOM.Iterable",
1919
"ESNext"
2020
],
21+
"typeRoots": [
22+
"./src/@types"
23+
],
2124
"strict": true,
2225
"removeComments": false
2326
},

0 commit comments

Comments
 (0)
Please sign in to comment.