Skip to content

Commit

Permalink
Merge pull request #18 from thisyahlen-deriv/thisyahlen/tsconfig-and-…
Browse files Browse the repository at this point in the history
…vite

chore: add tsconfig declarations
  • Loading branch information
thisyahlen-deriv authored Sep 11, 2024
2 parents fb05e00 + 9e19124 commit 5a6a58a
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 15 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"build": "tsc -b && vite build",
"lint": "eslint .",
"prepublish": "npm run build",
"preview": "vite preview"
"preview": "vite preview",
"watch": "vite build --watch"
},
"types": "./dist/auth-client.d.ts",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion src/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { OAuth2Provider } from './auth-context.tsx';
export { OAuth2Provider } from './auth-context';
export { useOAuth2 } from './use-oauth2';
2 changes: 1 addition & 1 deletion src/context/use-oauth2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { OAuth2Context } from '../context/auth-context.tsx';
import { OAuth2Context } from '../context/auth-context';

export const useOAuth2 = () => {
const context = useContext(OAuth2Context);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { OAuth2Provider, useOAuth2 } from './context/';
export * from './context/';
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import App from './App';
import './index.css';

createRoot(document.getElementById('root')!).render(
Expand Down
27 changes: 22 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
"compilerOptions": {
"target": "ES2021",
"declaration": true,
"declarationMap": true,
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"moduleResolution": "Node",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true
},
"include": ["src"],
"exclude": ["**/*.spec.ts"]
}
3 changes: 3 additions & 0 deletions types/App.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './App.css';
declare function App(): import("react/jsx-runtime").JSX.Element;
export default App;
1 change: 1 addition & 0 deletions types/constants/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './urls';
10 changes: 10 additions & 0 deletions types/constants/urls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export declare const DEFAULT_OAUTH_LOGOUT_URL = "https://oauth.deriv.com/oauth2/sessions/logout";
export declare const DEFAULT_OAUTH_ORIGIN_URL = "https://oauth.deriv.com";
export declare const getServerInfo: () => {
appId: string | null | undefined;
lang: string | null | undefined;
serverUrl: string | null | undefined;
};
export declare const getOauthUrl: () => string;
export declare const getOAuthLogoutUrl: () => string;
export declare const getOAuthOrigin: () => string;
12 changes: 12 additions & 0 deletions types/context/auth-context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
type OAuth2ContextValue = {
OAuth2Logout: () => void;
};
type OAuth2ProviderProps = {
children: React.ReactNode;
logout: () => Promise<void>;
oauthUrl: string;
};
export declare const OAuth2Context: React.Context<OAuth2ContextValue | undefined>;
export declare const OAuth2Provider: React.FC<OAuth2ProviderProps>;
export {};
2 changes: 2 additions & 0 deletions types/context/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { OAuth2Provider } from './auth-context';
export { useOAuth2 } from './use-oauth2';
3 changes: 3 additions & 0 deletions types/context/use-oauth2.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare const useOAuth2: () => {
OAuth2Logout: () => void;
};
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { OAuth2Provider, useOAuth2 } from './context/';
1 change: 1 addition & 0 deletions types/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './index.css';
16 changes: 11 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ import dts from 'vite-plugin-dts';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), dts({
include: ['src'],
exclude: ['src/**/*.spec.tsx'],
tsconfigPath: './tsconfig.app.json'
})],
plugins: [
react(),
dts({
include: ['src'],
exclude: ['src/**/*.spec.tsx'],
tsconfigPath: './tsconfig.app.json',
insertTypesEntry: true,
}),
],
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['es'],
name: '@deriv-com/auth-client',
fileName: 'auth-client',
},
copyPublicDir: false,
rollupOptions: {
Expand Down

0 comments on commit 5a6a58a

Please sign in to comment.