Skip to content

Commit 847af92

Browse files
authored
chore(build): Modernize tsconfig.json (#1667)
1 parent 65a2098 commit 847af92

File tree

151 files changed

+709
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+709
-683
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"tsx": "^4.19.2",
6464
"tweakpane": "<4.0.0",
6565
"tweakpane-plugin-thumbnail-list": "^0.3.0",
66-
"typescript": "5.7.3",
66+
"typescript": "5.8.3",
6767
"vite": "^6.1.0",
6868
"watlas": "^1.0.0"
6969
},

packages/cli/src/cli.ts

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
import { URL } from 'url';
2-
import { promises as fs, readFileSync } from 'fs';
3-
import micromatch from 'micromatch';
4-
import { gzip } from 'node-gzip';
5-
import fetch from 'node-fetch'; // TODO(deps): Replace when v20 reaches end of maintenance.
6-
import mikktspace from 'mikktspace';
7-
import * as watlas from 'watlas';
8-
import { MeshoptEncoder, MeshoptSimplifier } from 'meshoptimizer';
9-
import { ready as resampleReady, resample as resampleWASM } from 'keyframe-resample';
10-
import { Logger, NodeIO, PropertyType, VertexLayout, vec2, Transform } from '@gltf-transform/core';
1+
import { Logger, NodeIO, PropertyType, type Transform, VertexLayout, type vec2 } from '@gltf-transform/core';
112
import {
12-
CenterOptions,
13-
InstanceOptions,
3+
type CenterOptions,
4+
DRACO_DEFAULTS,
5+
type DracoOptions,
6+
type FlattenOptions,
147
INSTANCE_DEFAULTS,
15-
PartitionOptions,
16-
PruneOptions,
8+
type InstanceOptions,
9+
JOIN_DEFAULTS,
10+
type JoinOptions,
11+
MESHOPT_DEFAULTS,
12+
PALETTE_DEFAULTS,
13+
PRUNE_DEFAULTS,
14+
type PaletteOptions,
15+
type PartitionOptions,
16+
type PruneOptions,
1717
QUANTIZE_DEFAULTS,
18-
ResampleOptions,
19-
SequenceOptions,
18+
type ResampleOptions,
19+
SIMPLIFY_DEFAULTS,
20+
type SequenceOptions,
21+
type SparseOptions,
22+
TEXTURE_COMPRESS_SUPPORTED_FORMATS,
2023
TextureResizeFilter,
21-
UnweldOptions,
22-
WeldOptions,
24+
UNWRAP_DEFAULTS,
25+
type UnweldOptions,
26+
type WeldOptions,
2327
center,
2428
dedup,
29+
dequantize,
30+
draco,
31+
flatten,
2532
instance,
33+
join,
34+
meshopt,
2635
metalRough,
36+
palette,
2737
partition,
2838
prune,
2939
quantize,
40+
reorder,
3041
resample,
3142
sequence,
32-
tangents,
33-
unweld,
34-
weld,
35-
reorder,
36-
dequantize,
37-
unlit,
38-
meshopt,
39-
DRACO_DEFAULTS,
40-
draco,
41-
DracoOptions,
4243
simplify,
43-
SIMPLIFY_DEFAULTS,
44-
textureCompress,
45-
FlattenOptions,
46-
flatten,
47-
JOIN_DEFAULTS,
48-
join,
49-
JoinOptions,
5044
sparse,
51-
SparseOptions,
52-
palette,
53-
PaletteOptions,
54-
PALETTE_DEFAULTS,
55-
MESHOPT_DEFAULTS,
56-
TEXTURE_COMPRESS_SUPPORTED_FORMATS,
57-
PRUNE_DEFAULTS,
45+
tangents,
46+
textureCompress,
47+
unlit,
48+
unweld,
5849
unwrap,
59-
UNWRAP_DEFAULTS,
50+
weld,
6051
} from '@gltf-transform/functions';
52+
import { promises as fs, readFileSync } from 'fs';
53+
import { ready as resampleReady, resample as resampleWASM } from 'keyframe-resample';
54+
import { MeshoptEncoder, MeshoptSimplifier } from 'meshoptimizer';
55+
import micromatch from 'micromatch';
56+
import mikktspace from 'mikktspace';
57+
import fetch from 'node-fetch'; // TODO(deps): Replace when v20 reaches end of maintenance.
58+
import { gzip } from 'node-gzip';
59+
import { URL } from 'url';
60+
import * as watlas from 'watlas';
61+
import { getConfig, loadConfig } from './config.js';
6162
import { inspect } from './inspect.js';
63+
import { Validator, program } from './program.js';
64+
import { Session } from './session.js';
6265
import {
6366
ETC1S_DEFAULTS,
6467
Filter,
6568
Mode,
6669
UASTC_DEFAULTS,
70+
type XMPOptions,
6771
ktxdecompress,
6872
ktxfix,
6973
merge,
7074
toktx,
71-
XMPOptions,
7275
xmp,
7376
} from './transforms/index.js';
74-
import { formatBytes, MICROMATCH_OPTIONS, underline, TableFormat, dim, regexFromArray } from './util.js';
75-
import { Session } from './session.js';
76-
import { ValidateOptions, validate } from './validate.js';
77-
import { getConfig, loadConfig } from './config.js';
78-
import { Validator, program } from './program.js';
77+
import { MICROMATCH_OPTIONS, TableFormat, dim, formatBytes, regexFromArray, underline } from './util.js';
78+
import { type ValidateOptions, validate } from './validate.js';
7979

8080
let io: NodeIO;
8181

82-
const programReady = new Promise<void>((resolve) => {
82+
const programReady: Promise<void> = new Promise<void>((resolve) => {
8383
// Manually detect and handle --config, before program actually runs.
8484
if (process.argv.includes('--config')) {
8585
loadConfig(process.argv[process.argv.indexOf('--config') + 1]);
@@ -1826,7 +1826,6 @@ program.option(
18261826
program.disableGlobalOption('--quiet');
18271827
program.disableGlobalOption('--no-color');
18281828

1829-
export { program, programReady };
1830-
export { Validator };
1831-
export * from './util.js';
18321829
export * from './transforms/index.js';
1830+
export * from './util.js';
1831+
export { Validator, program, programReady };

packages/cli/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function createDefaultConfig(): Promise<Config> {
4747
});
4848
}
4949

50-
export function loadConfig(path: string) {
50+
export function loadConfig(path: string): void {
5151
path = resolve(process.cwd(), path);
5252
path = `file:${path}`; // Required on Windows.
5353
customConfigPromise = import(path).then(validateConfig) as Promise<ConfigModule>;

packages/cli/src/inspect.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { Document, JSONDocument, ILogger, NodeIO, WebIO } from '@gltf-transform/core';
22
import {
3-
InspectAnimationReport,
4-
InspectMaterialReport,
5-
InspectMeshReport,
6-
InspectPropertyReport,
7-
InspectSceneReport,
8-
InspectTextureReport,
3+
type InspectAnimationReport,
4+
type InspectMaterialReport,
5+
type InspectMeshReport,
6+
type InspectPropertyReport,
7+
type InspectSceneReport,
8+
type InspectTextureReport,
99
inspect as inspectDoc,
1010
} from '@gltf-transform/functions';
1111
import { formatBytes, formatHeader, formatLong, formatParagraph, formatTable, formatXMP, TableFormat } from './util.js';

packages/cli/src/program.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
program as _program,
33
Command,
4-
ParsedOption,
5-
Validator as CaporalValidator,
6-
Logger as WinstonLogger,
4+
type ParsedOption,
5+
type Validator as CaporalValidator,
6+
type Logger as WinstonLogger,
77
} from '@donmccurdy/caporal';
8-
import { ILogger, Verbosity } from '@gltf-transform/core';
8+
import { type ILogger, Verbosity } from '@gltf-transform/core';
99

1010
const PAD_EMOJI = new Set(['🫖', '🖼', '⏯']);
1111

@@ -49,19 +49,19 @@ export interface IHelpOptions {
4949
}
5050

5151
class ProgramImpl implements IInternalProgram {
52-
version(version: string) {
52+
version(version: string): this {
5353
_program.version(version);
5454
return this;
5555
}
56-
description(desc: string) {
56+
description(desc: string): this {
5757
_program.description(desc);
5858
return this;
5959
}
60-
help(help: string, options?: IHelpOptions) {
60+
help(help: string, options?: IHelpOptions): this {
6161
_program.help(help, options);
6262
return this;
6363
}
64-
section(_name: string, _icon: string) {
64+
section(_name: string, _icon: string): this {
6565
const icon = _icon + (PAD_EMOJI.has(_icon) ? ' ' : '');
6666
const name = _name.toUpperCase();
6767
const line = ''.padEnd(50 - name.length - 1, '─');
@@ -71,20 +71,20 @@ class ProgramImpl implements IInternalProgram {
7171
command(name: string, desc: string): ICommand {
7272
return new CommandImpl(_program, name, desc);
7373
}
74-
option<T>(name: string, desc: string, options: IProgramOptions<T>) {
74+
option<T>(name: string, desc: string, options: IProgramOptions<T>): this {
7575
// biome-ignore lint/suspicious/noExplicitAny: TODO
7676
_program.option(name, desc, { global: true, ...options } as any);
7777
return this;
7878
}
79-
disableGlobalOption(name: string) {
79+
disableGlobalOption(name: string): this {
8080
_program.disableGlobalOption(name);
8181
return this;
8282
}
83-
run() {
83+
run(): this {
8484
_program.run();
8585
return this;
8686
}
87-
async exec(args: unknown[], options?: IExecOptions) {
87+
async exec(args: unknown[], options?: IExecOptions): Promise<void> {
8888
// biome-ignore lint/suspicious/noExplicitAny: TODO
8989
await _program.exec(args as any, options as any);
9090
}
@@ -141,7 +141,7 @@ class CommandImpl implements ICommand {
141141
}
142142
}
143143

144-
export const program = new ProgramImpl();
144+
export const program: ProgramImpl = new ProgramImpl();
145145

146146
/**********************************************************************************************
147147
* Validator.
@@ -179,10 +179,10 @@ export class Logger implements ILogger {
179179
this._verbosity = Verbosity.DEBUG;
180180
}
181181
}
182-
getVerbosity() {
182+
getVerbosity(): Verbosity {
183183
return this._verbosity;
184184
}
185-
setVerbosity(verbosity: Verbosity) {
185+
setVerbosity(verbosity: Verbosity): void {
186186
switch (verbosity) {
187187
case Verbosity.INFO:
188188
this._logger.level = 'info';
@@ -201,16 +201,16 @@ export class Logger implements ILogger {
201201
}
202202
this._verbosity = verbosity;
203203
}
204-
debug(msg: string) {
204+
debug(msg: string): void {
205205
this._logger.debug(msg);
206206
}
207-
info(msg: string) {
207+
info(msg: string): void {
208208
this._logger.info(msg);
209209
}
210-
warn(msg: string) {
210+
warn(msg: string): void {
211211
this._logger.warn(msg);
212212
}
213-
error(msg: string) {
213+
error(msg: string): void {
214214
this._logger.error(msg);
215215
}
216216
}

packages/cli/src/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Document, NodeIO, FileUtils, Transform, Format, Verbosity } from '@gltf-transform/core';
1+
import { Document, NodeIO, FileUtils, type Transform, Format, Verbosity } from '@gltf-transform/core';
22
import type { Packet, KHRXMP } from '@gltf-transform/extensions';
33
import { unpartition } from '@gltf-transform/functions';
4-
import { Listr, ListrTask } from 'listr2';
4+
import { Listr, type ListrTask } from 'listr2';
55
import { dim, formatBytes, formatLong, XMPContext } from './util.js';
66
import { performance } from 'perf_hooks'; // global in Node.js v16+
77
import { Logger } from './program.js';

packages/cli/src/transforms/ktxdecompress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os from 'os';
44
import tmp from 'tmp';
55
import pLimit from 'p-limit';
66

7-
import { uuid, Document, FileUtils, ImageUtils, Transform } from '@gltf-transform/core';
7+
import { uuid, Document, FileUtils, ImageUtils, type Transform } from '@gltf-transform/core';
88
import { KHRTextureBasisu } from '@gltf-transform/extensions';
99
import { createTransform } from '@gltf-transform/functions';
1010
import { spawn, formatBytes, waitExit } from '../util.js';

packages/cli/src/transforms/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
FileUtils,
55
ImageUtils,
66
NodeIO,
7-
Transform,
7+
type Transform,
88
Texture,
99
Buffer,
1010
PropertyType,

packages/cli/src/transforms/toktx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import type sharp from 'sharp';
99
import {
1010
Document,
1111
FileUtils,
12-
ILogger,
12+
type ILogger,
1313
ImageUtils,
1414
TextureChannel,
15-
Transform,
16-
vec2,
15+
type Transform,
16+
type vec2,
1717
uuid,
1818
Texture,
1919
BufferUtils,

packages/cli/src/transforms/xmp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Document, ILogger, Transform } from '@gltf-transform/core';
22
import { Packet, KHRXMP } from '@gltf-transform/extensions';
3-
import prompts, { PromptObject } from 'prompts';
3+
import prompts, { type PromptObject } from 'prompts';
44
import languageTags from 'language-tags';
55
import validateSPDX from 'spdx-correct';
66
import fs from 'fs/promises';

packages/cli/src/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export function regexFromArray(values: string[]): RegExp {
2828

2929
// Mocks for tests.
3030

31-
export let spawn = _spawn;
31+
export let spawn: typeof _spawn = _spawn;
3232
// See https://github.com/mathisonian/command-exists/issues/22
33-
export let commandExists = (cmd: string) => _commandExists(cmd).catch(() => false);
34-
export let waitExit = _waitExit;
33+
export let commandExists = (cmd: string): Promise<string | boolean> => _commandExists(cmd).catch(() => false);
34+
export let waitExit: typeof _waitExit = _waitExit;
3535

3636
export function mockSpawn(_spawn: unknown): void {
3737
spawn = _spawn as typeof spawn;

packages/cli/src/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function validate(input: string, options: ValidateOptions, logger:
2525
.validateBytes(new Uint8Array(buffer), {
2626
maxIssues: options.limit,
2727
ignoredIssues: options.ignore,
28-
externalResourceFunction: (uri: string) => {
28+
externalResourceFunction: async (uri: string) => {
2929
uri = path.resolve(path.dirname(input), decodeURIComponent(uri));
3030
return fs.readFile(uri).catch((err) => {
3131
logger.warn(`Unable to validate "${uri}": ${err.toString()}.`);

packages/core/src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ declare const PACKAGE_VERSION: string;
55
* Current version of the package.
66
* @hidden
77
*/
8-
export const VERSION = `v${PACKAGE_VERSION}`;
8+
export const VERSION: string = `v${PACKAGE_VERSION}`;
99

1010
/** @internal */
1111
export const NAME = '@gltf-transform/core';
@@ -152,7 +152,7 @@ export enum Format {
152152
GLB = 'GLB',
153153
}
154154

155-
export const ComponentTypeToTypedArray = {
155+
export const ComponentTypeToTypedArray: Record<string, TypedArrayConstructor> = {
156156
'5120': Int8Array,
157157
'5121': Uint8Array,
158158
'5122': Int16Array,

packages/core/src/document.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {
1212
Node,
1313
Primitive,
1414
PrimitiveTarget,
15-
Property,
15+
type Property,
1616
Root,
1717
Scene,
1818
Skin,
1919
Texture,
2020
} from './properties/index.js';
21-
import { ILogger, Logger } from './utils/index.js';
21+
import { type ILogger, Logger } from './utils/index.js';
2222

2323
export interface TransformContext {
2424
stack: string[];

0 commit comments

Comments
 (0)