Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 5bb1cfb

Browse files
jsx
1 parent 8ec3fe8 commit 5bb1cfb

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed

tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Feature } from "./base";
88
// while also preventing downstreams from needing to mutate existing files.
99
const features: Record<string, Feature<unknown>> = {};
1010

11-
const requireFeature = require.context("./", true, /.tsx$/);
11+
const requireFeature = require.context('./', true, /.tsx$/);
1212

1313
for (const key of requireFeature.keys()) {
1414
if (key === "index" || key === "base") {
Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@
44
* @license MIT
55
*/
66

7+
import { Store } from 'common/redux';
8+
import { Window } from './layouts';
79
import { selectBackend } from './backend';
810
import { selectDebug } from './debug/selectors';
9-
import { Window } from './layouts';
1011

1112
const requireInterface = require.context('./interfaces');
1213

13-
const routingError = (type, name) => () => {
14-
return (
15-
<Window>
16-
<Window.Content scrollable>
17-
{type === 'notFound' && (
18-
<div>Interface <b>{name}</b> was not found.</div>
19-
)}
20-
{type === 'missingExport' && (
21-
<div>Interface <b>{name}</b> is missing an export.</div>
22-
)}
23-
</Window.Content>
24-
</Window>
25-
);
26-
};
14+
const routingError =
15+
(type: 'notFound' | 'missingExport', name: string) => () => {
16+
return (
17+
<Window>
18+
<Window.Content scrollable>
19+
{type === 'notFound' && (
20+
<div>
21+
Interface <b>{name}</b> was not found.
22+
</div>
23+
)}
24+
{type === 'missingExport' && (
25+
<div>
26+
Interface <b>{name}</b> is missing an export.
27+
</div>
28+
)}
29+
</Window.Content>
30+
</Window>
31+
);
32+
};
2733

34+
// Displays an empty Window with scrollable content
2835
const SuspendedWindow = () => {
2936
return (
3037
<Window>
@@ -33,7 +40,8 @@ const SuspendedWindow = () => {
3340
);
3441
};
3542

36-
export const getRoutedComponent = store => {
43+
// Get the component for the current route
44+
export const getRoutedComponent = (store: Store) => {
3745
const state = store.getState();
3846
const { suspended, config } = selectBackend(state);
3947
if (suspended) {
@@ -48,19 +56,20 @@ export const getRoutedComponent = store => {
4856
}
4957
const name = config?.interface;
5058
const interfacePathBuilders = [
51-
name => `./${name}.tsx`,
52-
name => `./${name}.js`,
53-
name => `./${name}/index.tsx`,
54-
name => `./${name}/index.js`,
59+
(name: string) => `./${name}.tsx`,
60+
(name: string) => `./${name}.jsx`,
61+
(name: string) => `./${name}.js`,
62+
(name: string) => `./${name}/index.tsx`,
63+
(name: string) => `./${name}/index.jsx`,
64+
(name: string) => `./${name}/index.js`,
5565
];
5666
let esModule;
5767
while (!esModule && interfacePathBuilders.length > 0) {
58-
const interfacePathBuilder = interfacePathBuilders.shift();
68+
const interfacePathBuilder = interfacePathBuilders.shift()!;
5969
const interfacePath = interfacePathBuilder(name);
6070
try {
6171
esModule = requireInterface(interfacePath);
62-
}
63-
catch (err) {
72+
} catch (err) {
6473
if (err.code !== 'MODULE_NOT_FOUND') {
6574
throw err;
6675
}

tgui/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ module.exports = (env = {}, argv) => {
4949
chunkLoadTimeout: 15000,
5050
},
5151
resolve: {
52-
extensions: ['.tsx', '.ts', '.js'],
52+
extensions: ['.tsx', '.ts', '.js', '.jsx'],
5353
alias: {},
5454
},
5555
module: {
5656
rules: [
5757
{
58-
test: /\.(js|cjs|ts|tsx)$/,
58+
test: /\.(js|jsx|cjs|ts|tsx)$/,
5959
use: [
6060
{
6161
loader: require.resolve('babel-loader'),

0 commit comments

Comments
 (0)