Set up TypeScript for lib

Add a TypeScript build suitable for incremental migration to TypeScript
to the lib package.
This commit is contained in:
Hornwitser committed 2023-08-03 15:01:34 +02:00
1 parent a1ee147c46
commit 90798205e0
16 files changed
+115 -151

No files matched your search

-13
View File
@@ -1,13 +0,0 @@
/**
* Configuration System
* @author Hornwitser
* @module lib/config
*/
"use strict";
const classes = require("./classes");
const definitions = require("./definitions");
module.exports = {
...classes,
...definitions,
};
+7
View File
@@ -0,0 +1,7 @@
/**
* Configuration System
* @author Hornwitser
* @module lib/config
*/
export * from "./classes";
export * from "./definitions";
+6 -3
View File
@@ -21,11 +21,14 @@ function jsonPrimitive(type) {
},
};
}
const JsonBoolean = jsonPrimitive("boolean");
const JsonNumber = jsonPrimitive("number");
const JsonString = jsonPrimitive("string");
module.exports = {
JsonBoolean: jsonPrimitive("boolean"),
JsonNumber: jsonPrimitive("number"),
JsonString: jsonPrimitive("string"),
JsonBoolean,
JsonNumber,
JsonString,
jsonArray,
jsonPrimitive,
-31
View File
@@ -1,31 +0,0 @@
/**
* Shared data types used in Clusterio
* @module lib/data
* @author Hornwitser
*/
"use strict";
const ExportManifest = require("./ExportManifest");
const ModInfo = require("./ModInfo");
const ModPack = require("./ModPack");
const composites = require("./composites");
const messagesCore = require("./messages_core");
const messagesController = require("./messages_controller");
const messagesHost = require("./messages_host");
const messagesInstance = require("./messages_instance");
const messagesMod = require("./messages_mod");
const messagesUser = require("./messages_user");
const version = require("./version");
module.exports = {
ExportManifest,
ModInfo,
ModPack,
...composites,
...messagesCore,
...messagesController,
...messagesHost,
...messagesInstance,
...messagesMod,
...messagesUser,
...version,
};
+16
View File
@@ -0,0 +1,16 @@
/**
* Shared data types used in Clusterio
* @module lib/data
* @author Hornwitser
*/
export { default as ExportManifest } from "./ExportManifest";
export { default as ModInfo } from "./ModInfo";
export { default as ModPack } from "./ModPack";
export * from "./composites";
export * from "./messages_core";
export * from "./messages_controller";
export * from "./messages_host";
export * from "./messages_instance";
export * from "./messages_mod";
export * from "./messages_user";
export * from "./version";
+2
View File
@@ -0,0 +1,2 @@
import type { ValidateFunction } from "ajv"
export default ValidateFunction
@@ -3,9 +3,4 @@
* @module lib/factorio
* @author Hornwitser
*/
"use strict";
const exchange_string = require("./exchange_string");
module.exports = {
...exchange_string,
};
export * from "./exchange_string";
-17
View File
@@ -1,17 +0,0 @@
/**
* Library for message based communication between nodes
* @module lib/link
* @author Hornwitser
*/
"use strict";
const link = require("./link");
const connectors = require("./connectors");
module.exports = {
...link,
...connectors,
// migrate: Allow info for plugins from before link refactor to load.
Event: class Event {},
Request: class Request {},
};
+11
View File
@@ -0,0 +1,11 @@
/**
* Library for message based communication between nodes
* @module lib/link
* @author Hornwitser
*/
export * from "./link"
export * from "./connectors"
// migrate: Allow info for plugins from before link refactor to load.
export class Event {}
export class Request {}
+2 -2
View File
@@ -416,7 +416,7 @@ function handleUnhandledErrors() {
/* eslint-enable node/no-process-exit */
}
const _formatServerOutput = formatServerOutput;
module.exports = {
TerminalFormat,
LinkTransport,
@@ -425,5 +425,5 @@ module.exports = {
queryLog,
// for testing only
_formatServerOutput: formatServerOutput,
_formatServerOutput,
};