Skip to content

Commit

Permalink
tgui: Updates typescript, other dependencies (tgstation#72279)
Browse files Browse the repository at this point in the history
## About The Pull Request
The largest change to this is that it updates typescript from 4.3.5 to
4.9.4.

It also does some QoL to update @ types, yarn version, and
typescript-eslint-parser (OPTIONAL)

I did this by:
1. Updating typescript `yarn add typescript`
2. Updating other types `yarn add @types/...`
3. Repackaging typescript (and other) workplace sdks `yarn dlx
@yarnpkg/sdks`
4. Updates yarn via corepack `yarn set version stable`
5. Fixes a couple places where typescript was mad

## Why It's Good For The Game
- I want to do things like make discriminating type unions
- Huge leap into typescript so I can better type out tgui core
- TS >>> JS

## Changelog
N/A Nothing player facing

Co-authored-by: Aleksej Komarov <[email protected]>
  • Loading branch information
jlsnow301 and stylemistake authored Dec 31, 2022
1 parent 261366b commit a32522d
Show file tree
Hide file tree
Showing 26 changed files with 1,220 additions and 899 deletions.
17 changes: 10 additions & 7 deletions tgui/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,16 @@ rules:
## Enforce or disallow capitalization of the first letter of a comment
# capitalized-comments: error
## Require or disallow trailing commas
comma-dangle: [error, {
arrays: always-multiline,
objects: always-multiline,
imports: always-multiline,
exports: always-multiline,
functions: only-multiline, ## Optional on functions
}]
comma-dangle: [
error,
{
arrays: always-multiline,
objects: always-multiline,
imports: always-multiline,
exports: always-multiline,
functions: only-multiline, ## Optional on functions
},
]
## Enforce consistent spacing before and after commas
comma-spacing: [error, { before: false, after: true }]
## Enforce consistent comma style
Expand Down
768 changes: 0 additions & 768 deletions tgui/.yarn/releases/yarn-3.1.1.cjs

This file was deleted.

823 changes: 823 additions & 0 deletions tgui/.yarn/releases/yarn-3.3.1.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/eslint/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/prettier/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/bin/tsc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/bin/tsserver
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/lib/tsc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

const moduleWrapper = tsserver => {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

const moduleWrapper = tsserver => {
if (!process.versions.pnp) {
Expand Down
4 changes: 2 additions & 2 deletions tgui/.yarn/sdks/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
Expand Down
2 changes: 1 addition & 1 deletion tgui/.yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.3.5-sdk",
"version": "4.9.4-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
2 changes: 1 addition & 1 deletion tgui/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ preferAggregateCacheInfo: true

preferInteractive: true

yarnPath: .yarn/releases/yarn-3.1.1.cjs
yarnPath: .yarn/releases/yarn-3.3.1.cjs
16 changes: 8 additions & 8 deletions tgui/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"name": "tgui-workspace",
"version": "4.3.0",
"packageManager": "yarn@3.1.1",
"version": "4.3.1",
"packageManager": "yarn@3.3.1",
"workspaces": [
"packages/*"
],
Expand All @@ -26,12 +26,12 @@
"@babel/plugin-transform-jscript": "^7.14.5",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^27.0.1",
"@types/jsdom": "^16.2.13",
"@types/node": "^14.17.9",
"@types/jest": "^29.2.4",
"@types/jsdom": "^20.0.1",
"@types/node": "14.x",
"@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.16.2",
"@typescript-eslint/parser": "^4.29.1",
"@types/webpack-env": "^1.18.0",
"@typescript-eslint/parser": "^5.47.1",
"babel-jest": "^27.0.6",
"babel-loader": "^8.2.2",
"babel-plugin-inferno": "^6.3.0",
Expand All @@ -54,7 +54,7 @@
"sass-loader": "^11.1.1",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.4",
"typescript": "^4.3.5",
"typescript": "^4.9.4",
"url-loader": "^4.1.1",
"webpack": "^5.50.0",
"webpack-bundle-analyzer": "^4.4.2",
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"private": true,
"name": "common",
"version": "4.3.0"
"version": "4.3.1"
}
2 changes: 1 addition & 1 deletion tgui/packages/tgui-bench/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tgui-bench",
"version": "4.3.0",
"version": "4.3.1",
"dependencies": {
"common": "workspace:*",
"fastify": "^3.29.4",
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui-dev-server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tgui-dev-server",
"version": "4.3.0",
"version": "4.3.1",
"type": "module",
"dependencies": {
"axios": "^0.21.1",
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui-panel/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tgui-panel",
"version": "4.3.0",
"version": "4.3.1",
"dependencies": {
"common": "workspace:*",
"dompurify": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui-polyfill/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tgui-polyfill",
"version": "4.3.0",
"version": "4.3.1",
"scripts": {
"tgui-polyfill:build": "terser 00-html5shiv.js 01-ie8.js 02-dom4.js 03-css-om.js 10-misc.js --ie8 -f ascii_only,comments=false -o ../../public/tgui-polyfill.min.js"
},
Expand Down
13 changes: 11 additions & 2 deletions tgui/packages/tgui-say/types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ export type State = {
};

type Timers = {
channelDebounce: ({ mode: boolean }) => void;
forceDebounce: ({ channel: number, entry: string }) => void;
channelDebounce: (ModeDebounce) => void;
forceDebounce: (ForceDebounce) => void;
typingThrottle: () => void;
};

type ModeDebounce = {
mode: boolean;
};

type ForceDebounce = {
channel: number;
entry: string;
};

export type DragzoneProps = {
theme: string;
top: boolean;
Expand Down
12 changes: 11 additions & 1 deletion tgui/packages/tgui/assets.js → tgui/packages/tgui/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ const loadedMappings = {};

export const resolveAsset = (name) => loadedMappings[name] || name;

export const assetMiddleware = (store) => (next) => (action) => {
type Action =
| {
type: 'asset/stylesheet';
payload: string;
}
| {
type: 'asset/mappings';
payload: Record<string, string>;
};

export const assetMiddleware = (store) => (next) => (action: Action) => {
const { type, payload } = action;
if (type === 'asset/stylesheet') {
Byond.loadCss(payload);
Expand Down
5 changes: 4 additions & 1 deletion tgui/packages/tgui/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ const DEFAULT_OPTIONS = {
],
};

const NULL_RECT = {
const NULL_RECT: DOMRect = {
width: 0,
height: 0,
top: 0,
right: 0,
bottom: 0,
left: 0,
x: 0,
y: 0,
toJSON: () => null,
};

export class Tooltip extends Component<TooltipProps, TooltipState> {
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tgui",
"version": "4.3.0",
"version": "4.3.1",
"dependencies": {
"@popperjs/core": "^2.9.3",
"@types/marked": "^4.0.3",
Expand Down
5 changes: 1 addition & 4 deletions tgui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@
"strictNullChecks": true,
"target": "ES3"
},
"include": [
"./*.d.ts",
"./packages"
]
"include": ["./*.d.ts", "./packages"]
}
Loading

0 comments on commit a32522d

Please sign in to comment.