Skip to content

Commit

Permalink
Add typescript type generation to build
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyO1 committed Nov 10, 2023
1 parent 36572c1 commit 7fad3d1
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 11 deletions.
7 changes: 0 additions & 7 deletions index.d.ts

This file was deleted.

43 changes: 43 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const readFileRequest: "ReadFile-Request";
export const writeFileRequest: "WriteFile-Request";
export const readFileResponse: "ReadFile-Response";
export const writeFileResponse: "WriteFile-Response";
export const changeLanguageRequest: "ChangeLanguage-Request";
export function preloadBindings(ipcRenderer: any, process: any): {
send: (channel: any, data: any) => void;
onReceive: (channel: any, func: any) => void;
onLanguageChange: (func: any) => void;
clientOptions: {
environment: any;
platform: any;
resourcesPath: string;
};
};
export function mainBindings(ipcMain: any, browserWindow: any, fs: any): void;
export function clearMainBindings(ipcMain: any): void;
export default Backend;
declare class Backend {
constructor(services: any, backendOptions?: {}, i18nextOptions?: {});
readCallbacks: {};
writeCallbacks: {};
writeTimeout: any;
writeQueue: any[];
writeQueueOverflow: any[];
useOverflow: boolean;
init(services: any, backendOptions: any, i18nextOptions: any): void;
services: any;
backendOptions: any;
i18nextOptions: any;
mainLog: string;
rendererLog: string;
setupIpcBindings(): void;
write(writeQueue: any): void;
requestFileRead(filename: any, callback: any): void;
read(language: any, namespace: any, callback: any): void;
readMulti(_languages: any, _namespaces: any, _callback: any): void;
create(languages: any, namespace: any, key: any, fallbackValue: any, callback: any): void;
}
declare namespace Backend {
let type: string;
}
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lib/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export namespace UUID {
function generate(): string;
}
export function mergeNested(obj: any, path: any, split: any, val: any): any;
export function groupByArray(xs: any, key: any): any;
//# sourceMappingURL=utils.d.ts.map
1 change: 1 addition & 0 deletions lib/utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "An i18next backend plugin that allows you to use local translation files for your electron app, following electron's best-security practices.",
"main": "lib/index.js",
"scripts": {
"build": "npx babel ./src -d ./lib"
"build": "npx tsc && npx babel ./src -d ./lib"
},
"repository": {
"type": "git",
Expand All @@ -21,7 +21,8 @@
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"babel-preset-minify": "^0.5.2"
"babel-preset-minify": "^0.5.2",
"typescript": "^5.2.2"
},
"dependencies": {
"lodash.clonedeep": "^4.5.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
mergeNested,
groupByArray
} from "./utils";
import '../index';

// CONFIGS
const defaultOptions = {
Expand Down
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Change this to match your project
"include": ["src/**/*"],
"compilerOptions": {
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
// Types should go into this directory.
// Removing this would place the .d.ts files
// next to the .js files
"outDir": "lib",
// go to js file when using IDE functions like
// "Go to Definition" in VSCode
"declarationMap": true
}
}

0 comments on commit 7fad3d1

Please sign in to comment.