Skip to content

Commit

Permalink
Fix typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JezerM committed Jul 14, 2024
1 parent d4f0fb2 commit cc664b2
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 110 deletions.
File renamed without changes.
14 changes: 14 additions & 0 deletions package-lock.json

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

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild -w node-gtk",
"build": "npm run build:vite && node make build",
"build:vite": "node vite.js && npm run build:themes",
"build": "npm run build:compile && node make build",
"build:compile": "node compile.js && npm run build:themes",
"build:theme:gruvbox": "tsc --build themes/themes/gruvbox",
"build:theme:dracula": "tsc --build themes/themes/dracula",
"build:themes": "npm run build:theme:gruvbox && npm run build:theme:dracula",
"type-check": "tsc --noEmit",
"type-check": "tsc -b",
"lint": "eslint \"ts/**\"",
"lint:fix": "eslint \"ts/**\" --fix",
"lint:theme:gruvbox": "eslint \"themes/themes/gruvbox/ts/**\"",
Expand All @@ -38,8 +38,10 @@
"license": "ISC",
"homepage": "https://github.com/JezerM/nody-greeter",
"devDependencies": {
"@electron/rebuild": "^3.6.0",
"@electron/asar": "^3.2.10",
"@electron/rebuild": "^3.6.0",
"@tsconfig/node18": "^18.0.0",
"@tsconfig/recommended": "^1.0.7",
"@types/js-yaml": "^4.0.2",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^7.16.0",
Expand Down
31 changes: 31 additions & 0 deletions src/common/ldm_interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,41 @@ interface LightDMBattery {
watt: number;
}

/**
* Metadata that is sent to each window to handle more interesting multi-monitor
* functionality / themes.
*/
interface WindowMetadata {
// TODO: Remove this eslint-disable comment
/* eslint-disable @typescript-eslint/naming-convention */
id: number;
is_primary: boolean;
position: {
x: number;
y: number;
};
size: {
width: number;
height: number;
};
/**
* The total real-estate across all screens,
* this can be used to assist in, for example,
* correctly positioning multi-monitor backgrounds.
*/
overallBoundary: {
minX: number;
maxX: number;
minY: number;
maxY: number;
};
}

export {
LightDMBattery,
LightDMLanguage,
LightDMLayout,
LightDMSession,
LightDMUser,
WindowMetadata,
};
2 changes: 1 addition & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Greeter, GreeterConfig, ThemeUtils } from "./bridge/bridge";
import { Greeter, GreeterConfig, ThemeUtils } from "./main/bridge/bridge";

declare global {
/* eslint-disable no-var */
Expand Down
2 changes: 1 addition & 1 deletion src/main/bridge/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
LightDMLayout,
LightDMSession,
LightDMUser,
} from "../ldm_interfaces";
} from "common/ldm_interfaces";
import { logger } from "../logger";
import { CONSTS } from "common/consts";

Expand Down
2 changes: 1 addition & 1 deletion src/main/bridge/bridge_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
LightDMLayout,
LightDMSession,
LightDMUser,
} from "../ldm_interfaces";
} from "common/ldm_interfaces";

import { LightDM } from "node-gtk";
import { BatteryController } from "../utils/battery";
Expand Down
2 changes: 1 addition & 1 deletion src/main/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as url from "url";
import { brightnessController } from "./utils/brightness";
import { logger } from "./logger";
import { setScreensaver, resetScreensaver } from "./utils/screensaver";
import { WindowMetadata } from "../preload/index";
import { WindowMetadata } from "common/ldm_interfaces";

interface NodyWindow {
isPrimary: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from "path";

import { ensureTheme, loadThemeConfig, globalNodyConfig } from "./config";

const res = yargs
const res = yargs(process.argv)
.scriptName("nody-greeter")
.usage("$0 [args]")
.option("mode", {
Expand Down
31 changes: 1 addition & 30 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,9 @@ import {
LightDMLayout,
LightDMSession,
LightDMUser,
WindowMetadata,
} from "common/ldm_interfaces";

/**
* Metadata that is sent to each window to handle more interesting multi-monitor
* functionality / themes.
*/
export interface WindowMetadata {
// TODO: Remove this eslint-disable comment
/* eslint-disable @typescript-eslint/naming-convention */
id: number;
is_primary: boolean;
position: {
x: number;
y: number;
};
size: {
width: number;
height: number;
};
/**
* The total real-estate across all screens,
* this can be used to assist in, for example,
* correctly positioning multi-monitor backgrounds.
*/
overallBoundary: {
minX: number;
maxX: number;
minY: number;
maxY: number;
};
}

/**
* An event that is fired and dispatched when one browser window of a theme
* sends a broadcast to all windows (which happens for multi-monitor setups)
Expand Down
83 changes: 12 additions & 71 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,74 +1,15 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.main.json"
},
{
"path": "./tsconfig.preload.json"
}
],
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./js", /* Redirect output structure to the directory. */
"rootDir": "./ts", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitUseStrict": true,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */

/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"./ts"
]
"noImplicitAny": false,
"allowJs": true,
}
}
24 changes: 24 additions & 0 deletions tsconfig.main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"include": [
"env.d.ts",
"src/global.d.ts",
"src/main/**/*",
"src/common/**/*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.main.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "bundler",
"types": [
"node"
],
"paths": {
"common/*": [
"./src/common/*"
]
}
}
}
27 changes: 27 additions & 0 deletions tsconfig.preload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"include": [
"src/preload/**/*",
"src/common/**/*",
],
"exclude": [
"src/**/__tests__/*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.preload.tsbuildinfo",
"module": "ES2020",
"moduleResolution": "bundler",
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"paths": {
"common/*": [
"./src/common/*"
]
}
}
}

0 comments on commit cc664b2

Please sign in to comment.