From f89adae9b53e42ab6e678a9ff1e1ee8420ffc70a Mon Sep 17 00:00:00 2001 From: Luke Abby Date: Sat, 21 Dec 2024 21:56:28 -0800 Subject: [PATCH] Move helperTypes and utils to fvtt-types/utils --- .eslintrc.cjs | 2 + CONTRIBUTING.md | 4 +- README.md | 18 +- package-lock.json | 14 +- package.json | 7 +- .../applications/api/application.d.mts | 8 +- .../client-esm/applications/api/dialog.d.mts | 2 +- .../applications/api/document-sheet.d.mts | 2 +- .../api/handlebars-application.d.mts | 2 +- .../apps/compendium-art-config.d.mts | 3 +- .../applications/apps/permission-config.d.mts | 3 +- .../applications/dice/roll-resolver.d.mts | 2 +- .../applications/forms/fields.d.mts | 2 +- .../applications/sheets/actor-sheet.d.mts | 2 +- .../sheets/ambient-light-config.d.mts | 3 +- .../sheets/ambient-sound-config.d.mts | 3 +- .../applications/sheets/item-sheet.d.mts | 2 +- .../sheets/region-behavior-config.d.mts | 2 +- .../applications/sheets/region-config.d.mts | 2 +- .../applications/sheets/user-config.d.mts | 3 +- .../applications/ui/region-legend.d.mts | 2 +- src/foundry/client-esm/audio/biquad.d.mts | 2 +- src/foundry/client-esm/audio/convolver.d.mts | 2 +- src/foundry/client-esm/audio/helper.d.mts | 2 +- src/foundry/client-esm/audio/sound.d.mts | 2 +- .../client-esm/canvas/edges/edge.d.mts | 2 +- src/foundry/client-esm/canvas/smaa/smaa.d.mts | 2 +- .../canvas/sources/base-effect-source.d.mts | 2 +- .../canvas/sources/base-light-source.d.mts | 2 +- .../canvas/sources/point-effect-source.d.mts | 2 +- .../sources/rendered-effect-source.d.mts | 2 +- src/foundry/client-esm/client.d.mts | 2 +- .../client-esm/data/client-backend.d.mts | 31 +- src/foundry/client-esm/dice/roll.d.mts | 17 +- src/foundry/client-esm/dice/terms/coin.d.mts | 2 +- src/foundry/client-esm/dice/terms/dice.d.mts | 4 +- src/foundry/client-esm/dice/terms/die.d.mts | 2 +- src/foundry/client-esm/dice/terms/fate.d.mts | 2 +- .../client-esm/dice/terms/function.d.mts | 7 +- .../client-esm/dice/terms/numeric.d.mts | 2 +- .../client-esm/dice/terms/operator.d.mts | 2 +- .../client-esm/dice/terms/parenthetical.d.mts | 2 +- src/foundry/client-esm/dice/terms/pool.d.mts | 21 +- .../client-esm/dice/terms/string.d.mts | 2 +- src/foundry/client-esm/dice/terms/term.d.mts | 13 +- src/foundry/client/apps/app.d.mts | 2 +- src/foundry/client/apps/av/av-config.d.mts | 2 +- src/foundry/client/apps/av/cameras.d.mts | 2 +- src/foundry/client/apps/form.d.mts | 2 +- src/foundry/client/apps/forms/actor.d.mts | 2 +- .../apps/forms/adventure-exporter.d.mts | 2 +- .../apps/forms/adventure-importer.d.mts | 2 +- .../client/apps/forms/base-sheet.d.mts | 2 +- .../client/apps/forms/card-config.d.mts | 2 +- .../client/apps/forms/cards-config.d.mts | 6 +- .../client/apps/forms/combat-config.d.mts | 2 +- .../client/apps/forms/effect-config.d.mts | 2 +- .../client/apps/forms/folder-config.d.mts | 2 +- src/foundry/client/apps/forms/fonts.d.mts | 2 +- .../client/apps/forms/grid-config.d.mts | 3 +- .../client/apps/forms/image-popout.d.mts | 2 +- src/foundry/client/apps/forms/item.d.mts | 2 +- .../apps/forms/journal-page-sheet.d.mts | 2 +- .../client/apps/forms/journal-sheet.d.mts | 2 +- .../client/apps/forms/macro-config.d.mts | 2 +- .../client/apps/forms/measure-template.d.mts | 18 +- src/foundry/client/apps/forms/ownership.d.mts | 2 +- .../client/apps/forms/playlist-config.d.mts | 2 +- .../apps/forms/playlist-sound-config.d.mts | 2 +- .../client/apps/forms/roll-table-config.d.mts | 2 +- .../client/apps/forms/scene-config.d.mts | 2 +- .../client/apps/forms/sheet-config.d.mts | 6 +- .../client/apps/forms/user-config.d.mts | 2 +- src/foundry/client/apps/hud/container.d.mts | 2 +- src/foundry/client/apps/hud/hotbar.d.mts | 2 +- src/foundry/client/apps/hud/hud.d.mts | 2 +- src/foundry/client/apps/hud/menu.d.mts | 2 +- src/foundry/client/apps/hud/navigation.d.mts | 2 +- src/foundry/client/apps/hud/pause.d.mts | 2 +- src/foundry/client/apps/hud/players.d.mts | 2 +- src/foundry/client/apps/i18n.d.mts | 2 +- .../apps/placeables/drawing-config.d.mts | 2 +- .../client/apps/placeables/drawing-hud.d.mts | 2 +- .../client/apps/placeables/light-config.d.mts | 3 +- .../client/apps/placeables/note-config.d.mts | 2 +- .../client/apps/placeables/sound-config.d.mts | 2 +- .../client/apps/placeables/tile-config.d.mts | 2 +- .../client/apps/placeables/tile-hud.d.mts | 2 +- .../client/apps/placeables/token-config.d.mts | 3 +- .../client/apps/placeables/token-hud.d.mts | 2 +- .../client/apps/placeables/wall-config.d.mts | 2 +- .../sidebar/apps/keybindings-config.d.mts | 2 +- .../apps/sidebar/apps/module-management.d.mts | 2 +- .../apps/sidebar/apps/support-details.d.mts | 2 +- .../apps/sidebar/apps/tours-management.d.mts | 2 +- .../apps/sidebar/apps/world-config.d.mts | 2 +- .../apps/sidebar/directory-tab-mixin.d.mts | 2 +- .../apps/sidebar/package-configuration.d.mts | 2 +- src/foundry/client/apps/sidebar/sidebar.d.mts | 2 +- src/foundry/client/av/client.d.mts | 2 +- .../client/av/clients/simplepeer.d.mts | 2 +- src/foundry/client/av/master.d.mts | 2 +- src/foundry/client/av/settings.d.mts | 3 +- src/foundry/client/config.d.mts | 5 +- src/foundry/client/core/hooks.d.mts | 2 +- src/foundry/client/core/image.d.mts | 2 +- src/foundry/client/core/index.d.mts | 2 +- src/foundry/client/core/keybindings.d.mts | 2 +- src/foundry/client/core/packages.d.mts | 2 +- src/foundry/client/core/settings.d.mts | 3 +- src/foundry/client/core/socket.d.mts | 2 +- src/foundry/client/core/sorting.d.mts | 2 +- src/foundry/client/core/tooltip.d.mts | 2 +- src/foundry/client/core/tour.d.mts | 2 +- src/foundry/client/core/utils.d.mts | 2 +- src/foundry/client/core/workers.d.mts | 2 +- .../data/abstract/canvas-document.d.mts | 2 +- .../data/abstract/client-document.d.mts | 4 +- .../abstract/directory-collection-mixin.d.mts | 2 +- .../data/abstract/document-collection.d.mts | 2 +- .../data/abstract/world-collection.d.mts | 2 +- .../client/data/collections/actors.d.mts | 2 +- .../collections/compendium-collection.d.mts | 2 +- .../client/data/collections/journal.d.mts | 2 +- .../client/data/collections/macros.d.mts | 2 +- .../client/data/collections/playlists.d.mts | 2 +- .../client/data/collections/scenes.d.mts | 2 +- .../client/data/collections/users.d.mts | 2 +- .../client/data/documents/active-effect.d.mts | 2 +- src/foundry/client/data/documents/actor.d.mts | 2 +- .../client/data/documents/adventure.d.mts | 3 +- src/foundry/client/data/documents/card.d.mts | 2 +- src/foundry/client/data/documents/cards.d.mts | 9 +- .../client/data/documents/chat-message.d.mts | 2 +- .../client/data/documents/combat.d.mts | 2 +- .../client/data/documents/combatant.d.mts | 2 +- .../data/documents/fog-exploration.d.mts | 2 +- .../client/data/documents/folder.d.mts | 7 +- .../data/documents/journal-entry-page.d.mts | 2 +- src/foundry/client/data/documents/macro.d.mts | 2 +- .../data/documents/playlist-sound.d.mts | 2 +- .../client/data/documents/playlist.d.mts | 2 +- src/foundry/client/data/documents/scene.d.mts | 2 +- src/foundry/client/data/documents/table.d.mts | 2 +- src/foundry/client/data/documents/token.d.mts | 2 +- src/foundry/client/data/documents/user.d.mts | 2 +- src/foundry/client/game.d.mts | 14 +- src/foundry/client/hooks.d.mts | 2 +- src/foundry/client/pixi/board.d.mts | 2 +- .../core/containers/base-canvas-group.d.mts | 2 +- .../core/containers/cached-container.d.mts | 2 +- .../containers/full-canvas-container.d.mts | 2 +- .../core/interaction/canvas-animation.d.mts | 3 +- .../pixi/core/interaction/control-icon.d.mts | 2 +- .../pixi/core/interaction/mouse-handler.d.mts | 2 +- .../pixi/core/interaction/render-flags.d.mts | 2 +- src/foundry/client/pixi/core/loader.d.mts | 2 +- .../pixi/core/shapes/polygon-mesher.d.mts | 2 +- .../pixi/core/shapes/source-polygon.d.mts | 10 +- .../client/pixi/extensions/circle.d.mts | 2 +- .../extensions/observable-transform.d.mts | 2 +- .../client/pixi/extensions/polygon.d.mts | 2 +- .../client/pixi/extensions/rectangle.d.mts | 3 +- src/foundry/client/pixi/groups/effects.d.mts | 2 +- .../client/pixi/groups/environment.d.mts | 2 +- .../client/pixi/groups/interface.d.mts | 2 +- .../pixi/layers/base/interaction-layer.d.mts | 2 +- .../pixi/layers/base/placeables-layer.d.mts | 5 +- .../client/pixi/layers/controls/layer.d.mts | 3 +- .../client/pixi/layers/controls/ruler.d.mts | 2 +- .../layers/effects/illumination-effects.d.mts | 2 +- .../pixi/layers/effects/visibility.d.mts | 2 +- .../pixi/layers/effects/weather-effects.d.mts | 2 +- .../client/pixi/layers/grid/layer.d.mts | 2 +- .../client/pixi/layers/grid/mesh.d.mts | 2 +- .../client/pixi/layers/placeables/notes.d.mts | 2 +- .../pixi/layers/placeables/sounds.d.mts | 3 +- .../pixi/layers/placeables/tokens.d.mts | 3 +- .../client/pixi/layers/placeables/walls.d.mts | 4 +- .../pixi/perception/detection-mode.d.mts | 2 +- .../client/pixi/perception/vision-mode.d.mts | 2 +- .../perception/weiler-atherton-clipping.d.mts | 3 +- src/foundry/client/pixi/placeable.d.mts | 3 +- .../client/pixi/placeables/drawing.d.mts | 2 +- .../primary-canvas-object.d.mts | 2 +- .../primary-graphics.d.mts | 2 +- .../primary-occludable-object.d.mts | 2 +- .../primary-sprite-mesh.d.mts | 2 +- .../client/pixi/placeables/template.d.mts | 2 +- .../client/pixi/placeables/token.d.mts | 2 +- .../webgl/extensions/batch-renderer.d.mts | 3 +- .../pixi/webgl/helpers/smooth-noise.d.mts | 2 +- .../webgl/helpers/texture-extractor.d.mts | 2 +- .../webgl/shaders/base-shader-mixin.d.mts | 2 +- .../pixi/webgl/shaders/base-shader.d.mts | 2 +- .../shaders/filters/effects-masking.d.mts | 2 +- .../webgl/shaders/filters/transition.d.mts | 2 +- .../webgl/shaders/filters/visibility.d.mts | 2 +- .../shaders/fragment-channel-mixin.d.mts | 2 +- .../client/pixi/webgl/shaders/grid/grid.d.mts | 2 +- .../webgl/shaders/samplers/base-sampler.d.mts | 2 +- .../webgl/shaders/weather/base-weather.d.mts | 3 +- .../pixi/webgl/shaders/weather/effect.d.mts | 2 +- .../pixi/webgl/shaders/weather/fog.d.mts | 2 +- .../pixi/webgl/shaders/weather/rain.d.mts | 2 +- .../pixi/webgl/shaders/weather/snow.d.mts | 2 +- src/foundry/client/ui/context.d.mts | 2 +- src/foundry/client/ui/dialog.d.mts | 2 +- src/foundry/client/ui/dragdrop.d.mts | 2 +- src/foundry/client/ui/editor.d.mts | 6 +- src/foundry/client/ui/filepicker.d.mts | 2 +- src/foundry/client/ui/filter.d.mts | 2 +- src/foundry/clipper/clipper.d.mts | 2 +- src/foundry/common/abstract/backend.d.mts | 59 +- src/foundry/common/abstract/data.d.mts | 2 +- src/foundry/common/abstract/document.d.mts | 87 +- .../abstract/embedded-collection-delta.d.mts | 2 +- .../common/abstract/embedded-collection.d.mts | 4 +- src/foundry/common/abstract/socket.d.mts | 2 +- src/foundry/common/abstract/type-data.d.mts | 4 +- src/foundry/common/config.d.mts | 2 +- src/foundry/common/constants.d.mts | 2 +- src/foundry/common/data/data.d.mts | 3 +- src/foundry/common/data/fields.d.mts | 4 +- .../common/documents/active-effect.d.mts | 3 +- .../common/documents/actor-delta.d.mts | 2 +- src/foundry/common/documents/actor.d.mts | 2 +- .../common/documents/ambient-light.d.mts | 2 +- .../common/documents/ambient-sound.d.mts | 2 +- src/foundry/common/documents/card.d.mts | 2 +- src/foundry/common/documents/cards.d.mts | 2 +- .../common/documents/chat-message.d.mts | 2 +- src/foundry/common/documents/drawing.d.mts | 2 +- src/foundry/common/documents/item.d.mts | 2 +- .../common/documents/journal-entry.d.mts | 2 +- src/foundry/common/documents/macro.d.mts | 2 +- .../common/documents/measured-template.d.mts | 2 +- src/foundry/common/documents/note.d.mts | 2 +- .../common/documents/playlist-sound.d.mts | 2 +- src/foundry/common/documents/playlist.d.mts | 2 +- src/foundry/common/documents/roll-table.d.mts | 2 +- src/foundry/common/documents/scene.d.mts | 2 +- .../common/documents/table-result.d.mts | 2 +- src/foundry/common/documents/tile.d.mts | 2 +- src/foundry/common/documents/token.d.mts | 2 +- src/foundry/common/documents/user.d.mts | 2 +- src/foundry/common/documents/wall.d.mts | 2 +- src/foundry/common/grid/base.d.mts | 2 +- src/foundry/common/grid/gridless.d.mts | 2 +- src/foundry/common/grid/hexagonal.d.mts | 2 +- src/foundry/common/grid/square.d.mts | 2 +- .../common/packages/base-package.d.mts | 3 +- src/foundry/common/packages/base-world.d.mts | 2 +- src/foundry/common/packages/sub-types.d.mts | 2 +- src/foundry/common/primitives/array.d.mts | 2 +- src/foundry/common/primitives/string.d.mts | 2 +- .../common/prosemirror/dirty-plugin.d.mts | 2 +- .../highlight-matches-plugin.d.mts | 2 +- .../common/prosemirror/image-plugin.d.mts | 2 +- .../prosemirror/paste-transformer.d.mts | 2 +- src/foundry/common/prosemirror/plugin.d.mts | 2 +- .../common/prosemirror/schema/index.d.mts | 2 +- src/foundry/common/types.d.mts | 2 +- src/foundry/common/utils/event-emitter.d.mts | 2 +- src/foundry/common/utils/helpers.d.mts | 2 +- src/foundry/common/utils/string-tree.d.mts | 2 +- src/foundry/common/utils/word-tree.d.mts | 2 +- src/types/augments/tinyMCE.d.mts | 2 +- src/types/config.d.mts | 3 +- src/types/documentConfiguration.d.mts | 3 +- src/types/helperTypes.d.mts | 629 +++--------- src/types/index.d.mts | 1 + src/types/utils.d.mts | 487 ++------- src/utils/index.d.mts | 968 ++++++++++++++++++ tests/foundry/client-esm/dice/roll.test-d.ts | 2 +- .../helpers/compendium-art.test-d.ts | 2 +- tests/foundry/client/apps/app.test-d.ts | 2 +- .../client/apps/hud/container.test-d.ts | 2 +- .../foundry/client/apps/hud/hotbar.test-d.ts | 2 +- tests/foundry/client/apps/hud/hud.test-d.ts | 2 +- .../apps/placeables/drawing-hud.test-d.ts | 2 +- .../client/apps/placeables/tile-hud.test-d.ts | 2 +- .../apps/placeables/token-hud.test-d.ts | 2 +- .../sidebar/tabs/combat-tracker.test-d.ts | 2 +- tests/foundry/client/config.test-d.ts | 2 +- tests/foundry/client/core/issues.test-d.ts | 7 +- tests/foundry/client/core/settings.test-d.ts | 2 +- tests/foundry/client/core/socket.test-d.ts | 5 +- tests/foundry/client/core/utils.test-d.ts | 2 +- .../data/abstract/canvas-document.test-d.ts | 3 +- .../client/data/collections/actors.test-d.ts | 2 +- .../client/data/collections/combats.test-d.ts | 2 +- .../compendium-collection.test-d.ts | 4 +- .../client/data/collections/fog.test-d.ts | 2 +- .../client/data/collections/folder.test-d.ts | 2 +- .../client/data/collections/items.test-d.ts | 2 +- .../client/data/collections/journal.test-d.ts | 2 +- .../client/data/collections/macros.test-d.ts | 2 +- .../data/collections/messages.test-d.ts | 2 +- .../data/collections/playlists.test-d.ts | 2 +- .../client/data/collections/scenes.test-d.ts | 2 +- .../data/collections/settings.test-d.ts | 2 +- .../client/data/collections/tables.test-d.ts | 2 +- .../client/data/collections/users.test-d.ts | 2 +- .../data/documents/active-effect.test-d.ts | 6 +- .../client/data/documents/adventure.test-d.ts | 5 +- .../client/data/documents/card.test-d.ts | 3 +- .../client/data/documents/cards.test-d.ts | 3 +- .../data/documents/chat-message.test-d.ts | 4 +- .../client/data/documents/combatant.test-d.ts | 2 +- .../client/data/documents/macro.test-d.ts | 2 +- .../client/data/documents/setting.test-d.ts | 4 +- tests/foundry/client/game.test-d.ts | 2 +- tests/foundry/client/pixi/board.test-d.ts | 3 +- .../core/interaction/mouse-handler.test-d.ts | 2 +- .../layers/base/placeables-layer.test-d.ts | 6 +- .../pixi/layers/controls/ruler.test-d.ts | 2 +- .../pixi/layers/effects/visibility.test-d.ts | 2 +- .../client/pixi/layers/grid/layer.test-d.ts | 2 +- .../pixi/perception/detection-mode.test-d.ts | 2 +- .../client/pixi/placeables/token.test-d.ts | 2 +- tests/foundry/client/ui/filepicker.test-d.ts | 2 +- .../common/abstract/document.mjs.test-d.ts | 16 +- .../common/abstract/type-data.mjs.test-d.ts | 9 +- tests/foundry/common/constants.test-d.ts | 2 +- .../common/documents/active-effect.test-d.ts | 2 +- .../common/documents/actor-delta.test-d.ts | 2 +- .../foundry/common/documents/actor.test-d.ts | 8 +- tests/foundry/common/documents/card.test-d.ts | 2 +- .../foundry/common/documents/cards.test-d.ts | 6 +- .../common/documents/chat-message.test-d.ts | 2 +- .../foundry/common/documents/combat.test-d.ts | 2 +- .../common/documents/combatant.test-d.ts | 2 +- .../common/documents/drawing.test-d.ts | 2 +- .../documents/fog-exploration.test-d.ts | 2 +- .../foundry/common/documents/folder.test-d.ts | 2 +- tests/foundry/common/documents/item.test-d.ts | 5 +- .../common/documents/journal-entry.test-d.ts | 2 +- .../foundry/common/documents/scene.test-d.ts | 4 +- .../common/documents/setting.test-d.ts | 2 +- tests/foundry/common/documents/user.test-d.ts | 2 +- .../common/packages/base-module.mjs.test-d.ts | 4 +- .../packages/base-package.mjs.test-d.ts | 2 +- .../common/packages/base-world.mjs.test-d.ts | 2 +- .../common/prosemirror/prosemirror.test-d.ts | 1 - .../common/utils/helpers.mjs.test-d.ts | 2 +- tests/tsconfig.json | 3 +- tests/types/utils.test-d.ts | 4 +- tsconfig.json | 3 +- 349 files changed, 1767 insertions(+), 1443 deletions(-) create mode 100644 src/utils/index.d.mts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3687074ed..f6dc45cb6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -37,6 +37,7 @@ module.exports = { }, ], "@typescript-eslint/prefer-namespace-keyword": "error", + "import/consistent-type-specifier-style": ["warn", "prefer-top-level"], "import/extensions": ["error", "always"], "import/first": "warn", @@ -55,6 +56,7 @@ module.exports = { "import/no-unused-modules": "warn", "import/no-useless-path-segments": "warn", "import/no-webpack-loader-syntax": "error", + "tsdoc/syntax": "warn", }, settings: { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 443edf5b2..c0e627d25 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,7 +149,7 @@ declare class ActorSheet`. This will also +If the type is not configurable by the user, it should most likely be `NameOfTheClass.AnyConstructor`. This will also allow deriving classes to be used as value. In rare occasions (i.e. when really only instances of this specific class may be assigned, no deriving classes), `typeof NameOfTheClass` can be used. @@ -168,7 +168,7 @@ Actor: { /** * @defaultValue `Actors` */ - collection: ConstructorOf; + collection: Actors.AnyConstructor; } ``` diff --git a/README.md b/README.md index d78479a26..a0690c634 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ At the moment, versions 0.7, 0.8, and 9 are fully supported with partial support ## V12 Installation -Currently v12 is still in beta. There are known bugs, issues in the ergonomics, and major unfinished work in the current implementation. To get a direct line of communication about the current status of development as well as to help us understand what areas need to be prioritizated first, join the [League of Extraordinary FoundryVTT Developers Discord](https://discord.gg/73HTMuK7dT) or file an issue. +Currently v12 is still in beta. There are known bugs, issues in the ergonomics, and major unfinished work in the current implementation. To get a direct line of communication about the current status of development as well as to help us understand what areas need to be prioritized first, join the [League of Extraordinary FoundryVTT Developers Discord](https://discord.gg/73HTMuK7dT) or file an issue. The recommended way to install for v12 is this command: @@ -31,6 +31,8 @@ Alternatively, if you're using yarn you'll need to use the command `yarn add --d This will add the current commit on `main` as a dependency. Both npm and yarn's lockfile will store the commit you initially installed this command and so updates to your dependency will not happen automatically or even after a fresh install. To update you will need to be rerun the prior command periodically to update as improvements are added frequently. +If you've been using the types for a few months now, the best branch would be `maintenance` instead. `main` will have a number of backwards incompatible breaking changes going forward. + ## Installation You can install historical versions of foundry-vtt-types from the [npm registry](https://npmjs.org/). @@ -84,22 +86,16 @@ Add foundry-vtt-types to your types section in your `tsconfig.json`: { "compilerOptions": { "types": ["@league-of-foundry-developers/foundry-vtt-types"], - "module": "node16", - "moduleResolution": "node16", - "esModuleInterop": true, - "strictNullChecks": true + "module": "esnext", + "moduleResolution": "bundler", + "strict": true } } ``` This will make the type definitions available globally in your project. -Make sure you are using at least `"module": "node16"` and `"moduleResolution": "node16"`, too. It is required for some -imports to be resolved correctly, such as `@league-of-foundry-developers/foundry-vtt-types/src/types/utils.mts`. - -Also make sure to set `"strictNullChecks": true` because otherwise, some conditional types used in the type definitions -resolve incorrectly, and you will see a lot of errors. Alternatively, you can just set `"strict": true`, which -implicitly sets `strictNullChecks`. This is actually what we **recommend**, but it's not required. +We recommend using `"strict": true` because it enables a whole host of useful options. However if you want to check that your config supports foundry-vtt-types, the most important settings under `strict` would be `strictNullChecks` and `strictFunctionTypes` are the most important. You can find some information about how to actually work with the type definitions in the [Wiki](https://github.com/League-of-Foundry-Developers/foundry-vtt-types/wiki). A good starting point is diff --git a/package-lock.json b/package-lock.json index a30974605..dafcb025a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@league-of-foundry-developers/foundry-vtt-types", - "version": "12.331.2-beta", + "version": "12.331.3-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@league-of-foundry-developers/foundry-vtt-types", - "version": "12.331.2-beta", + "version": "12.331.3-beta", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -37,7 +37,6 @@ "tinymce": "^6.8.3" }, "devDependencies": { - "@fvtt-types/fvtt-types": "file:.", "@typescript-eslint/eslint-plugin": "^8.12.2", "@typescript-eslint/parser": "^8.12.2", "eslint": "^8.57.1", @@ -45,6 +44,7 @@ "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", "eslint-plugin-tsdoc": "^0.4.0", + "fvtt-types": "file:.", "husky": "^9.1.4", "is-ci": "^4.1.0", "lint-staged": "^15.2.10", @@ -506,10 +506,6 @@ "node": "*" } }, - "node_modules/@fvtt-types/fvtt-types": { - "resolved": "", - "link": true - }, "node_modules/@humanwhocodes/config-array": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", @@ -3104,6 +3100,10 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fvtt-types": { + "resolved": "", + "link": true + }, "node_modules/get-east-asian-width": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.0.tgz", diff --git a/package.json b/package.json index dde1506ec..55e543898 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "types": "./index.d.mts", "scripts": { "lint": "./node_modules/typescript/bin/tsc; eslint .; prettier -c .", - "lint:fix": "eslint --fix .; prettier -w .", + "lint:fix": "eslint --fix .; prettier -l -w .", "lint:ci": "eslint .; prettier -c .", "eslint:report": "eslint --output-file eslint_report.json --format json .", "test": "vitest --typecheck", @@ -20,6 +20,9 @@ "url": "https://github.com/League-of-Foundry-Developers/foundry-vtt-types" }, "contributors": [ + { + "name": "LukeAbby" + }, { "name": "Kai Moschcau" }, @@ -81,7 +84,6 @@ "tinymce": "^6.8.3" }, "devDependencies": { - "@fvtt-types/fvtt-types": "file:.", "@typescript-eslint/eslint-plugin": "^8.12.2", "@typescript-eslint/parser": "^8.12.2", "eslint": "^8.57.1", @@ -89,6 +91,7 @@ "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", "eslint-plugin-tsdoc": "^0.4.0", + "fvtt-types": "file:.", "husky": "^9.1.4", "is-ci": "^4.1.0", "lint-staged": "^15.2.10", diff --git a/src/foundry/client-esm/applications/api/application.d.mts b/src/foundry/client-esm/applications/api/application.d.mts index 63e6206f9..a82571399 100644 --- a/src/foundry/client-esm/applications/api/application.d.mts +++ b/src/foundry/client-esm/applications/api/application.d.mts @@ -1,5 +1,4 @@ -import type { MustConform } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, DeepPartial, EmptyObject, InexactPartial, MaybePromise } from "../../../../types/utils.d.mts"; +import type { MustConform, AnyObject, DeepPartial, EmptyObject, InexactPartial, MaybePromise } from "../../../../utils/index.d.mts"; import type EventEmitterMixin from "../../../common/utils/event-emitter.d.mts"; // TODO: Investigate use of DeepPartial vs Partial vs InexactPartial @@ -15,6 +14,7 @@ type _InstanceMustBeAssignableToInternal = MustConform; + type AnyConstructor = typeof AnyApplicationV2; // Documented at https://gist.github.com/LukeAbby/c7420b053d881db4a4d4496b95995c98 namespace Internal { @@ -703,4 +703,8 @@ declare class ApplicationV2< bringToTop(): void; } +declare abstract class AnyApplicationV2 extends ApplicationV2 { + constructor(arg0: never, ...args: never[]); +} + export default ApplicationV2; diff --git a/src/foundry/client-esm/applications/api/dialog.d.mts b/src/foundry/client-esm/applications/api/dialog.d.mts index 3cf8b6daa..0791272aa 100644 --- a/src/foundry/client-esm/applications/api/dialog.d.mts +++ b/src/foundry/client-esm/applications/api/dialog.d.mts @@ -1,4 +1,4 @@ -import type { AnyFunction, DeepPartial, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyFunction, DeepPartial, EmptyObject } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "./application.d.mts"; /** diff --git a/src/foundry/client-esm/applications/api/document-sheet.d.mts b/src/foundry/client-esm/applications/api/document-sheet.d.mts index 62aee5688..72dca5fc3 100644 --- a/src/foundry/client-esm/applications/api/document-sheet.d.mts +++ b/src/foundry/client-esm/applications/api/document-sheet.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, DeepPartial, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, DeepPartial, EmptyObject } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "./application.d.mts"; declare namespace DocumentSheetV2 { diff --git a/src/foundry/client-esm/applications/api/handlebars-application.d.mts b/src/foundry/client-esm/applications/api/handlebars-application.d.mts index aaeda7145..be9e1f48e 100644 --- a/src/foundry/client-esm/applications/api/handlebars-application.d.mts +++ b/src/foundry/client-esm/applications/api/handlebars-application.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, Mixin } from "../../../../types/utils.d.mts"; +import type { DeepPartial, Mixin } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "./application.d.mts"; declare namespace HandlebarsApplication { diff --git a/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts b/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts index 0ffa62f74..ccc41cb31 100644 --- a/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts +++ b/src/foundry/client-esm/applications/apps/compendium-art-config.d.mts @@ -1,5 +1,4 @@ -import type { ConformRecord, InterfaceToObject, MustConform } from "../../../../types/helperTypes.d.mts"; -import type { DeepPartial } from "../../../../types/utils.d.mts"; +import type { ConformRecord, InterfaceToObject, MustConform, DeepPartial } from "../../../../utils/index.d.mts"; import type { CompendiumArtDescriptor } from "../../helpers/_types.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/apps/permission-config.d.mts b/src/foundry/client-esm/applications/apps/permission-config.d.mts index f9f594d47..253d6791e 100644 --- a/src/foundry/client-esm/applications/apps/permission-config.d.mts +++ b/src/foundry/client-esm/applications/apps/permission-config.d.mts @@ -1,5 +1,4 @@ -import type { ConformRecord, InterfaceToObject, MustConform } from "../../../../types/helperTypes.d.mts"; -import type { DeepPartial } from "../../../../types/utils.d.mts"; +import type { ConformRecord, InterfaceToObject, MustConform, DeepPartial } from "../../../../utils/index.d.mts"; import type { UserPermission } from "../../../common/constants.d.mts"; import type { CONST } from "../../client.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; diff --git a/src/foundry/client-esm/applications/dice/roll-resolver.d.mts b/src/foundry/client-esm/applications/dice/roll-resolver.d.mts index 2b8c02bf7..e1494db0d 100644 --- a/src/foundry/client-esm/applications/dice/roll-resolver.d.mts +++ b/src/foundry/client-esm/applications/dice/roll-resolver.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, DeepPartial, EmptyObject, InexactPartial } from "../../../../types/utils.d.mts"; +import type { AnyObject, DeepPartial, EmptyObject, InexactPartial } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/forms/fields.d.mts b/src/foundry/client-esm/applications/forms/fields.d.mts index c75124fc5..d42b0bb42 100644 --- a/src/foundry/client-esm/applications/forms/fields.d.mts +++ b/src/foundry/client-esm/applications/forms/fields.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps } from "../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../utils/index.d.mts"; export type CustomFormGroup = ( field: foundry.data.fields.DataField, diff --git a/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts b/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts index 90554488c..ce56034c8 100644 --- a/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts +++ b/src/foundry/client-esm/applications/sheets/actor-sheet.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; diff --git a/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts b/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts index 4207e43a4..daa8d54e0 100644 --- a/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts +++ b/src/foundry/client-esm/applications/sheets/ambient-light-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts b/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts index 174a58791..2adee486c 100644 --- a/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts +++ b/src/foundry/client-esm/applications/sheets/ambient-sound-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/sheets/item-sheet.d.mts b/src/foundry/client-esm/applications/sheets/item-sheet.d.mts index a6a368c2d..31994ae0f 100644 --- a/src/foundry/client-esm/applications/sheets/item-sheet.d.mts +++ b/src/foundry/client-esm/applications/sheets/item-sheet.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; /** diff --git a/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts b/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts index 4dc58f6b6..b90d5b3c3 100644 --- a/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts +++ b/src/foundry/client-esm/applications/sheets/region-behavior-config.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/sheets/region-config.d.mts b/src/foundry/client-esm/applications/sheets/region-config.d.mts index 5ab9e594a..23412185f 100644 --- a/src/foundry/client-esm/applications/sheets/region-config.d.mts +++ b/src/foundry/client-esm/applications/sheets/region-config.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/applications/sheets/user-config.d.mts b/src/foundry/client-esm/applications/sheets/user-config.d.mts index a74ac97e6..071594fed 100644 --- a/src/foundry/client-esm/applications/sheets/user-config.d.mts +++ b/src/foundry/client-esm/applications/sheets/user-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts"; import type DocumentSheetV2 from "../api/document-sheet.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; import type { CustomFormGroup } from "../forms/fields.d.mts"; diff --git a/src/foundry/client-esm/applications/ui/region-legend.d.mts b/src/foundry/client-esm/applications/ui/region-legend.d.mts index 1aa017c4c..6e81499e4 100644 --- a/src/foundry/client-esm/applications/ui/region-legend.d.mts +++ b/src/foundry/client-esm/applications/ui/region-legend.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts"; import type ApplicationV2 from "../api/application.d.mts"; import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts"; diff --git a/src/foundry/client-esm/audio/biquad.d.mts b/src/foundry/client-esm/audio/biquad.d.mts index e9e149526..596daedf0 100644 --- a/src/foundry/client-esm/audio/biquad.d.mts +++ b/src/foundry/client-esm/audio/biquad.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; /** * A sound effect which applies a biquad filter. diff --git a/src/foundry/client-esm/audio/convolver.d.mts b/src/foundry/client-esm/audio/convolver.d.mts index 3a5846a9d..a276ad54b 100644 --- a/src/foundry/client-esm/audio/convolver.d.mts +++ b/src/foundry/client-esm/audio/convolver.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare namespace ConvolverEffect {} diff --git a/src/foundry/client-esm/audio/helper.d.mts b/src/foundry/client-esm/audio/helper.d.mts index 49b9c623e..344327985 100644 --- a/src/foundry/client-esm/audio/helper.d.mts +++ b/src/foundry/client-esm/audio/helper.d.mts @@ -1,6 +1,6 @@ import type Sound from "./sound.d.mts"; import type AudioBufferCache from "./cache.d.mts"; -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; /** * A helper class to provide common functionality for working with the Web Audio API. diff --git a/src/foundry/client-esm/audio/sound.d.mts b/src/foundry/client-esm/audio/sound.d.mts index b879e0a91..74fc4dfb7 100644 --- a/src/foundry/client-esm/audio/sound.d.mts +++ b/src/foundry/client-esm/audio/sound.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial, ValueOf } from "../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial, ValueOf } from "../../../utils/index.d.mts"; import type EventEmitterMixin from "../../common/utils/event-emitter.d.mts"; declare namespace Sound { diff --git a/src/foundry/client-esm/canvas/edges/edge.d.mts b/src/foundry/client-esm/canvas/edges/edge.d.mts index ff3c776b1..f50e5d848 100644 --- a/src/foundry/client-esm/canvas/edges/edge.d.mts +++ b/src/foundry/client-esm/canvas/edges/edge.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { WallThresholdData } from "../../../common/documents/_types.d.mts"; /** diff --git a/src/foundry/client-esm/canvas/smaa/smaa.d.mts b/src/foundry/client-esm/canvas/smaa/smaa.d.mts index 8da03b118..2732f8c05 100644 --- a/src/foundry/client-esm/canvas/smaa/smaa.d.mts +++ b/src/foundry/client-esm/canvas/smaa/smaa.d.mts @@ -1,6 +1,6 @@ import type { CLEAR_MODES, FilterState, FilterSystem, RenderTexture } from "pixi.js"; -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; declare class SMAAFilter extends PIXI.Filter { /** diff --git a/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts index 4ea04f286..9328b0960 100644 --- a/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/base-effect-source.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; /** * TODO - Re-document after ESM refactor. diff --git a/src/foundry/client-esm/canvas/sources/base-light-source.d.mts b/src/foundry/client-esm/canvas/sources/base-light-source.d.mts index 2664b4940..53ca1d2ec 100644 --- a/src/foundry/client-esm/canvas/sources/base-light-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/base-light-source.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type RenderedEffectSource from "./rendered-effect-source.d.mts"; /** diff --git a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts index 8596ab9c5..a129fa195 100644 --- a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../utils/index.d.mts"; import type BaseEffectSource from "./base-effect-source.d.mts"; declare class PointEffectSource { diff --git a/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts index 0787aaea7..1afeb6468 100644 --- a/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts +++ b/src/foundry/client-esm/canvas/sources/rendered-effect-source.d.mts @@ -1,4 +1,4 @@ -import type { AnyFunction, InexactPartial } from "../../../../types/utils.d.mts"; +import type { AnyFunction, InexactPartial } from "../../../../utils/index.d.mts"; import type BaseEffectSource from "./base-effect-source.d.mts"; // TODO: Remove after shaders are done diff --git a/src/foundry/client-esm/client.d.mts b/src/foundry/client-esm/client.d.mts index 4409dad18..86d3d4d35 100644 --- a/src/foundry/client-esm/client.d.mts +++ b/src/foundry/client-esm/client.d.mts @@ -21,7 +21,7 @@ import * as _canvas from "./canvas/_module.mjs"; import * as _helpers from "./helpers/_module.mjs"; import * as _data from "./data/_module.mjs"; import * as _dice from "./dice/_module.mjs"; -import type { AnyObject } from "../../types/utils.d.mts"; +import type { AnyObject } from "../../utils/index.d.mts"; /** * Constant definitions used throughout the Foundry Virtual Tabletop framework. diff --git a/src/foundry/client-esm/data/client-backend.d.mts b/src/foundry/client-esm/data/client-backend.d.mts index 8c075a762..f6c93d6dc 100644 --- a/src/foundry/client-esm/data/client-backend.d.mts +++ b/src/foundry/client-esm/data/client-backend.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf } from "../../../types/utils.d.mts"; +import type { LoggingLevels } from "../../../utils/index.d.mts"; import type Document from "../../common/abstract/document.d.mts"; import type { DatabaseGetOperation, @@ -6,35 +6,34 @@ import type { DatabaseUpdateOperation, DatabaseDeleteOperation, } from "../../common/abstract/_types.d.mts"; -import type { LoggingLevels } from "../../../types/helperTypes.d.mts"; /** * The client-side database backend implementation which handles Document modification operations. */ declare class ClientDatabaseBackend extends foundry.abstract.DatabaseBackend { - protected override _getDocuments( - documentClass: ConstructorOf, + protected override _getDocuments( + documentClass: T, request: DatabaseGetOperation, user: User.ConfiguredInstance, - ): Promise; + ): Promise[]>; - protected override _createDocuments( - documentClass: ConstructorOf, - request: DatabaseCreateOperation, + protected override _createDocuments( + documentClass: T, + request: DatabaseCreateOperation>, user: User.ConfiguredInstance, - ): Promise; + ): Promise[]>; - protected override _updateDocuments( - documentClass: ConstructorOf, - request: DatabaseUpdateOperation, + protected override _updateDocuments( + documentClass: T, + request: DatabaseUpdateOperation>, user: User.ConfiguredInstance, - ): Promise; + ): Promise[]>; - protected override _deleteDocuments( - documentClass: ConstructorOf, + protected override _deleteDocuments( + documentClass: T, request: DatabaseDeleteOperation, user: User.ConfiguredInstance, - ): Promise; + ): Promise[]>; /** * Activate the Socket event listeners used to receive responses from events which modify database documents diff --git a/src/foundry/client-esm/dice/roll.d.mts b/src/foundry/client-esm/dice/roll.d.mts index 57560ce76..468d0e143 100644 --- a/src/foundry/client-esm/dice/roll.d.mts +++ b/src/foundry/client-esm/dice/roll.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, ConstructorOf, EmptyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject, InexactPartial } from "../../../utils/index.d.mts"; import type { RollParseNode } from "./_types.d.mts"; import type DiceTerm from "./terms/dice.d.mts"; @@ -551,7 +551,7 @@ declare class Roll { * @param data - Unpacked data representing the Roll * @returns A reconstructed Roll instance */ - static fromData>(this: ConstructorOf, data: Roll.Data): T; + static fromData(this: T, data: Roll.Data): InstanceType; /** * Recreate a Roll instance using a provided JSON string @@ -575,14 +575,17 @@ declare class Roll { * roll.formula; // 4d8 + 8 * ``` */ - static fromTerms>( - this: ConstructorOf, + static fromTerms( + this: T, terms: RollTerm[], options?: InexactPartial, - ): T; + ): InstanceType; } declare namespace Roll { + type Any = Roll; + type AnyConstructor = typeof AnyRoll; + interface Options extends RollTerm.EvaluationOptions { /** * If false, force the use of non-interactive rolls and do not prompt the user to make manual rolls. @@ -642,4 +645,8 @@ declare namespace Roll { type Evaluated = T & { _evaluated: true; _total: number; get total(): number }; } +declare abstract class AnyRoll extends Roll { + constructor(arg0: never, ...args: never[]); +} + export default Roll; diff --git a/src/foundry/client-esm/dice/terms/coin.d.mts b/src/foundry/client-esm/dice/terms/coin.d.mts index 8004ec6a7..ac25f6a30 100644 --- a/src/foundry/client-esm/dice/terms/coin.d.mts +++ b/src/foundry/client-esm/dice/terms/coin.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type DiceTerm from "./dice.d.mts"; /** diff --git a/src/foundry/client-esm/dice/terms/dice.d.mts b/src/foundry/client-esm/dice/terms/dice.d.mts index 410a4ec2f..16b8887ab 100644 --- a/src/foundry/client-esm/dice/terms/dice.d.mts +++ b/src/foundry/client-esm/dice/terms/dice.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { DiceRollParseNode } from "../_types.d.mts"; import type RollTerm from "./term.d.mts"; @@ -315,7 +315,7 @@ declare abstract class DiceTerm extends RollTerm { /* Serialization & Loading */ /* -------------------------------------------- */ - protected static _fromData(this: ConstructorOf, data: Record): T; + protected static _fromData(this: T, data: Record): InstanceType; override toJSON(): Record; } diff --git a/src/foundry/client-esm/dice/terms/die.d.mts b/src/foundry/client-esm/dice/terms/die.d.mts index d2a5cca56..5020e620d 100644 --- a/src/foundry/client-esm/dice/terms/die.d.mts +++ b/src/foundry/client-esm/dice/terms/die.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type DiceTerm from "./dice.d.mts"; diff --git a/src/foundry/client-esm/dice/terms/fate.d.mts b/src/foundry/client-esm/dice/terms/fate.d.mts index 8245d3ff5..b088b2895 100644 --- a/src/foundry/client-esm/dice/terms/fate.d.mts +++ b/src/foundry/client-esm/dice/terms/fate.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type DiceTerm from "./dice.d.mts"; import type Die from "./die.d.mts"; diff --git a/src/foundry/client-esm/dice/terms/function.d.mts b/src/foundry/client-esm/dice/terms/function.d.mts index 144742b10..54574ecb7 100644 --- a/src/foundry/client-esm/dice/terms/function.d.mts +++ b/src/foundry/client-esm/dice/terms/function.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { FunctionRollParseNode } from "../_types.d.mts"; import type RollTerm from "./term.d.mts"; @@ -70,7 +70,10 @@ declare class FunctionTerm extends RollTerm { /* -------------------------------------------- */ /* Saving and Loading */ /* -------------------------------------------- */ - protected static override _fromData(this: ConstructorOf, data: Record): T; + protected static override _fromData( + this: T, + data: Record, + ): InstanceType; /* -------------------------------------------- */ override toJSON(): Record; diff --git a/src/foundry/client-esm/dice/terms/numeric.d.mts b/src/foundry/client-esm/dice/terms/numeric.d.mts index 154ab7ad5..91375f774 100644 --- a/src/foundry/client-esm/dice/terms/numeric.d.mts +++ b/src/foundry/client-esm/dice/terms/numeric.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type RollTerm from "./term.d.mts"; /** diff --git a/src/foundry/client-esm/dice/terms/operator.d.mts b/src/foundry/client-esm/dice/terms/operator.d.mts index ba88c112d..b814f14b8 100644 --- a/src/foundry/client-esm/dice/terms/operator.d.mts +++ b/src/foundry/client-esm/dice/terms/operator.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type RollTerm from "./term.d.mts"; diff --git a/src/foundry/client-esm/dice/terms/parenthetical.d.mts b/src/foundry/client-esm/dice/terms/parenthetical.d.mts index 919e53d37..890b91fd9 100644 --- a/src/foundry/client-esm/dice/terms/parenthetical.d.mts +++ b/src/foundry/client-esm/dice/terms/parenthetical.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { ParentheticalRollParseNode } from "../_types.d.mts"; import type RollTerm from "./term.d.mts"; diff --git a/src/foundry/client-esm/dice/terms/pool.d.mts b/src/foundry/client-esm/dice/terms/pool.d.mts index e1f985f95..f927d9163 100644 --- a/src/foundry/client-esm/dice/terms/pool.d.mts +++ b/src/foundry/client-esm/dice/terms/pool.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { PoolRollParseNode } from "../_types.d.mts"; import type RollTerm from "./term.d.mts"; @@ -137,7 +137,10 @@ declare class PoolTerm extends RollTerm { /* Saving and Loading */ /* -------------------------------------------- */ - protected static override _fromData(this: ConstructorOf, data: Record): T; + protected static override _fromData( + this: T, + data: Record, + ): InstanceType; /* -------------------------------------------- */ @@ -151,18 +154,18 @@ declare class PoolTerm extends RollTerm { * @param options - Additional options applied to the PoolTerm * @returns The evaluated PoolTerm object or null if the formula is invalid */ - static fromExpression( - this: ConstructorOf, + static fromExpression( + this: T, formula: string, options?: RollTerm.Options, - ): T | null; + ): InstanceType | null; /** * Create a PoolTerm by providing an array of existing Roll objects * @param rolls - An array of Roll objects from which to create the pool * @returns The constructed PoolTerm comprised of the provided rolls */ - static fromRolls(this: ConstructorOf, rolls?: Roll[]): T; + static fromRolls(this: T, rolls?: Roll[]): InstanceType; /* -------------------------------------------- */ @@ -227,6 +230,8 @@ declare class PoolTerm extends RollTerm { } declare namespace PoolTerm { + type AnyConstructor = typeof AnyPoolTerm; + /** * @remarks This interface is not defined by foundry itself. It only exists * to allow module and system authors to use it for declaration merging, @@ -275,4 +280,8 @@ declare namespace PoolTerm { } } +declare abstract class AnyPoolTerm extends PoolTerm { + constructor(arg0: never, ...args: never[]); +} + export default PoolTerm; diff --git a/src/foundry/client-esm/dice/terms/string.d.mts b/src/foundry/client-esm/dice/terms/string.d.mts index c2198f5df..ba9f472a0 100644 --- a/src/foundry/client-esm/dice/terms/string.d.mts +++ b/src/foundry/client-esm/dice/terms/string.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type RollTerm from "./term.d.mts"; /** diff --git a/src/foundry/client-esm/dice/terms/term.d.mts b/src/foundry/client-esm/dice/terms/term.d.mts index 5dc5b3231..ecc3b22ab 100644 --- a/src/foundry/client-esm/dice/terms/term.d.mts +++ b/src/foundry/client-esm/dice/terms/term.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../../types/utils.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { RollParseNode } from "../_types.mts"; import type RollResolver from "../../applications/dice/roll-resolver.d.mts"; @@ -109,7 +109,10 @@ declare abstract class RollTerm { * @param data - The de-serialized term data * @returns The re-constructed RollTerm object */ - protected static _fromData(this: ConstructorOf, data: Record): T; + protected static _fromData( + this: T, + data: Record, + ): InstanceType; /** * Reconstruct a RollTerm instance from a provided JSON string @@ -126,6 +129,8 @@ declare abstract class RollTerm { } declare namespace RollTerm { + type AnyConstructor = typeof AnyRollTerm; + interface Options { flavor?: string | unknown; } @@ -157,4 +162,8 @@ declare namespace RollTerm { } } +declare abstract class AnyRollTerm { + constructor(arg0: never, ...args: never[]); +} + export default RollTerm; diff --git a/src/foundry/client/apps/app.d.mts b/src/foundry/client/apps/app.d.mts index 4cad29d2f..f00a86492 100644 --- a/src/foundry/client/apps/app.d.mts +++ b/src/foundry/client/apps/app.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise, ValueOf } from "../../../types/utils.d.mts"; +import type { MaybePromise, ValueOf } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/av/av-config.d.mts b/src/foundry/client/apps/av/av-config.d.mts index 0fca9a56d..6886cbcb5 100644 --- a/src/foundry/client/apps/av/av-config.d.mts +++ b/src/foundry/client/apps/av/av-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/av/cameras.d.mts b/src/foundry/client/apps/av/cameras.d.mts index 928206b0c..797a60d64 100644 --- a/src/foundry/client/apps/av/cameras.d.mts +++ b/src/foundry/client/apps/av/cameras.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/apps/form.d.mts b/src/foundry/client/apps/form.d.mts index 2621b7dd7..086da7054 100644 --- a/src/foundry/client/apps/form.d.mts +++ b/src/foundry/client/apps/form.d.mts @@ -1,6 +1,6 @@ import type { EditorView } from "prosemirror-view"; import type { Editor } from "tinymce"; -import type { AnyObject, GetDataReturnType, InexactPartial, MaybePromise } from "../../../types/utils.d.mts"; +import type { AnyObject, GetDataReturnType, InexactPartial, MaybePromise } from "../../../utils/index.d.mts"; import type { ProseMirrorKeyMaps, ProseMirrorMenu } from "../../common/prosemirror/_module.d.mts"; import type Document from "../../common/abstract/document.d.mts"; diff --git a/src/foundry/client/apps/forms/actor.d.mts b/src/foundry/client/apps/forms/actor.d.mts index 831531f9f..8ba188fa7 100644 --- a/src/foundry/client/apps/forms/actor.d.mts +++ b/src/foundry/client/apps/forms/actor.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; import type { DropData as ClientDocumentMixinDropData } from "../../data/abstract/client-document.d.mts"; declare global { diff --git a/src/foundry/client/apps/forms/adventure-exporter.d.mts b/src/foundry/client/apps/forms/adventure-exporter.d.mts index 23b723461..e89e5893e 100644 --- a/src/foundry/client/apps/forms/adventure-exporter.d.mts +++ b/src/foundry/client/apps/forms/adventure-exporter.d.mts @@ -1,6 +1,6 @@ import type { EditorView } from "prosemirror-view"; import type { Editor } from "tinymce"; -import type { GetDataReturnType } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/adventure-importer.d.mts b/src/foundry/client/apps/forms/adventure-importer.d.mts index c32ca8e65..2f15608b4 100644 --- a/src/foundry/client/apps/forms/adventure-importer.d.mts +++ b/src/foundry/client/apps/forms/adventure-importer.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/base-sheet.d.mts b/src/foundry/client/apps/forms/base-sheet.d.mts index 1d0f11374..d95719489 100644 --- a/src/foundry/client/apps/forms/base-sheet.d.mts +++ b/src/foundry/client/apps/forms/base-sheet.d.mts @@ -1,6 +1,6 @@ import type { EditorView } from "prosemirror-view"; import type { Editor } from "tinymce"; -import type { GetDataReturnType } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType } from "../../../../utils/index.d.mts"; declare global { class BaseSheet extends DocumentSheet< diff --git a/src/foundry/client/apps/forms/card-config.d.mts b/src/foundry/client/apps/forms/card-config.d.mts index f5cb56dc3..59b28adde 100644 --- a/src/foundry/client/apps/forms/card-config.d.mts +++ b/src/foundry/client/apps/forms/card-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/cards-config.d.mts b/src/foundry/client/apps/forms/cards-config.d.mts index 7f6fae71f..b1a1e91d3 100644 --- a/src/foundry/client/apps/forms/cards-config.d.mts +++ b/src/foundry/client/apps/forms/cards-config.d.mts @@ -1,5 +1,5 @@ -import type { ConfiguredDocumentClassForName } from "../../../../types/helperTypes.d.mts"; -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; +import type Document from "../../../common/abstract/document.d.mts"; declare global { /** @@ -11,7 +11,7 @@ declare global { Options, Cards.ConfiguredInstance > { - constructor(object: ConfiguredDocumentClassForName<"Cards">, options: Options); + constructor(object: Document.ConfiguredClassForName<"Cards">, options: Options); /** * The allowed sorting methods which can be used for this sheet diff --git a/src/foundry/client/apps/forms/combat-config.d.mts b/src/foundry/client/apps/forms/combat-config.d.mts index 98e80a6a9..09f91cbdd 100644 --- a/src/foundry/client/apps/forms/combat-config.d.mts +++ b/src/foundry/client/apps/forms/combat-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/effect-config.d.mts b/src/foundry/client/apps/forms/effect-config.d.mts index ba490af88..45c04249b 100644 --- a/src/foundry/client/apps/forms/effect-config.d.mts +++ b/src/foundry/client/apps/forms/effect-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise, SimpleMerge, ValueOf } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise, SimpleMerge, ValueOf } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/folder-config.d.mts b/src/foundry/client/apps/forms/folder-config.d.mts index a9a736335..f860e3831 100644 --- a/src/foundry/client/apps/forms/folder-config.d.mts +++ b/src/foundry/client/apps/forms/folder-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/fonts.d.mts b/src/foundry/client/apps/forms/fonts.d.mts index 13409a075..e88499ac5 100644 --- a/src/foundry/client/apps/forms/fonts.d.mts +++ b/src/foundry/client/apps/forms/fonts.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { class FontConfig extends FormApplication< diff --git a/src/foundry/client/apps/forms/grid-config.d.mts b/src/foundry/client/apps/forms/grid-config.d.mts index 1cb6ad0b8..ed2d84be7 100644 --- a/src/foundry/client/apps/forms/grid-config.d.mts +++ b/src/foundry/client/apps/forms/grid-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/image-popout.d.mts b/src/foundry/client/apps/forms/image-popout.d.mts index ec0637300..49a7b7aad 100644 --- a/src/foundry/client/apps/forms/image-popout.d.mts +++ b/src/foundry/client/apps/forms/image-popout.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { interface ImagePopoutOptions extends FormApplicationOptions { diff --git a/src/foundry/client/apps/forms/item.d.mts b/src/foundry/client/apps/forms/item.d.mts index e4b05571e..9bb482a5c 100644 --- a/src/foundry/client/apps/forms/item.d.mts +++ b/src/foundry/client/apps/forms/item.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/journal-page-sheet.d.mts b/src/foundry/client/apps/forms/journal-page-sheet.d.mts index b98b090d2..18595d862 100644 --- a/src/foundry/client/apps/forms/journal-page-sheet.d.mts +++ b/src/foundry/client/apps/forms/journal-page-sheet.d.mts @@ -1,6 +1,6 @@ import type { Editor } from "tinymce"; import type { EditorView } from "prosemirror-view"; -import type { GetDataReturnType, InexactPartial, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, InexactPartial, MaybePromise } from "../../../../utils/index.d.mts"; import type Showdown from "showdown"; declare global { diff --git a/src/foundry/client/apps/forms/journal-sheet.d.mts b/src/foundry/client/apps/forms/journal-sheet.d.mts index 2d490ea6a..580c9ccff 100644 --- a/src/foundry/client/apps/forms/journal-sheet.d.mts +++ b/src/foundry/client/apps/forms/journal-sheet.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise, InexactPartial } from "../../../../types/utils.d.mts"; +import type { MaybePromise, InexactPartial } from "../../../../utils/index.d.mts"; declare global { interface JournalSheetOptions extends DocumentSheetOptions { diff --git a/src/foundry/client/apps/forms/macro-config.d.mts b/src/foundry/client/apps/forms/macro-config.d.mts index 6e3d22400..08923c03b 100644 --- a/src/foundry/client/apps/forms/macro-config.d.mts +++ b/src/foundry/client/apps/forms/macro-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/measure-template.d.mts b/src/foundry/client/apps/forms/measure-template.d.mts index d0348487e..2aec9ed47 100644 --- a/src/foundry/client/apps/forms/measure-template.d.mts +++ b/src/foundry/client/apps/forms/measure-template.d.mts @@ -1,5 +1,4 @@ -import type { ConfiguredDocumentClassForName } from "../../../../types/helperTypes.d.mts"; -import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../utils/index.d.mts"; declare global { /** @@ -7,8 +6,9 @@ declare global { * @typeParam Options - the type of the options object */ class MeasuredTemplateConfig< - Options extends DocumentSheetOptions = DocumentSheetOptions, - > extends DocumentSheet>> { + Options extends + DocumentSheetOptions = DocumentSheetOptions, + > extends DocumentSheet { /** * @defaultValue * ```typescript @@ -21,7 +21,7 @@ declare global { * }) * ``` */ - static override get defaultOptions(): DocumentSheetOptions; + static override get defaultOptions(): DocumentSheetOptions; override getData(): MaybePromise>; @@ -46,11 +46,9 @@ declare global { } interface MeasuredTemplateConfigData< - Options extends DocumentSheetOptions = DocumentSheetOptions, - > extends DocumentSheet.DocumentSheetData< - Options, - InstanceType> - > { + Options extends + DocumentSheetOptions = DocumentSheetOptions, + > extends DocumentSheet.DocumentSheetData { templateTypes: Record; gridUnits: string; submitText: string; diff --git a/src/foundry/client/apps/forms/ownership.d.mts b/src/foundry/client/apps/forms/ownership.d.mts index a8ffd32c1..c41e9e317 100644 --- a/src/foundry/client/apps/forms/ownership.d.mts +++ b/src/foundry/client/apps/forms/ownership.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/playlist-config.d.mts b/src/foundry/client/apps/forms/playlist-config.d.mts index f4e8995b2..8e3e1e660 100644 --- a/src/foundry/client/apps/forms/playlist-config.d.mts +++ b/src/foundry/client/apps/forms/playlist-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise, ValueOf } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/playlist-sound-config.d.mts b/src/foundry/client/apps/forms/playlist-sound-config.d.mts index 11ba8c992..381fd8845 100644 --- a/src/foundry/client/apps/forms/playlist-sound-config.d.mts +++ b/src/foundry/client/apps/forms/playlist-sound-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/roll-table-config.d.mts b/src/foundry/client/apps/forms/roll-table-config.d.mts index 18679dfa1..50140a8fa 100644 --- a/src/foundry/client/apps/forms/roll-table-config.d.mts +++ b/src/foundry/client/apps/forms/roll-table-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/forms/scene-config.d.mts b/src/foundry/client/apps/forms/scene-config.d.mts index a5071f21e..27d56badd 100644 --- a/src/foundry/client/apps/forms/scene-config.d.mts +++ b/src/foundry/client/apps/forms/scene-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/apps/forms/sheet-config.d.mts b/src/foundry/client/apps/forms/sheet-config.d.mts index e389c8bb6..faf698860 100644 --- a/src/foundry/client/apps/forms/sheet-config.d.mts +++ b/src/foundry/client/apps/forms/sheet-config.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; import type DocumentSheetV2 from "../../../client-esm/applications/api/document-sheet.d.mts"; import type { Document } from "../../../common/abstract/module.d.mts"; @@ -92,7 +92,7 @@ declare global { static unregisterSheet( documentClass: Document.AnyConstructor, scope: string, - sheetClass: ConstructorOf>, + sheetClass: typeof FormApplication, { types }?: { types?: string[] }, ): void; @@ -131,7 +131,7 @@ declare global { label: string; /** The sheet class definition being registered */ - sheetClass: ConstructorOf; + sheetClass: Application.AnyConstructor; /** An array of types for which this sheet is added */ types: string[]; diff --git a/src/foundry/client/apps/forms/user-config.d.mts b/src/foundry/client/apps/forms/user-config.d.mts index b6a2f0805..0926bfb20 100644 --- a/src/foundry/client/apps/forms/user-config.d.mts +++ b/src/foundry/client/apps/forms/user-config.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/apps/hud/container.d.mts b/src/foundry/client/apps/hud/container.d.mts index ddd4545c5..f13829e95 100644 --- a/src/foundry/client/apps/hud/container.d.mts +++ b/src/foundry/client/apps/hud/container.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/hotbar.d.mts b/src/foundry/client/apps/hud/hotbar.d.mts index 393dd0546..1137786df 100644 --- a/src/foundry/client/apps/hud/hotbar.d.mts +++ b/src/foundry/client/apps/hud/hotbar.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/hud.d.mts b/src/foundry/client/apps/hud/hud.d.mts index bc773165e..49dde5bf4 100644 --- a/src/foundry/client/apps/hud/hud.d.mts +++ b/src/foundry/client/apps/hud/hud.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/menu.d.mts b/src/foundry/client/apps/hud/menu.d.mts index eb7c0119f..2259a28a9 100644 --- a/src/foundry/client/apps/hud/menu.d.mts +++ b/src/foundry/client/apps/hud/menu.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/navigation.d.mts b/src/foundry/client/apps/hud/navigation.d.mts index 25cf4eb1f..402b27bbb 100644 --- a/src/foundry/client/apps/hud/navigation.d.mts +++ b/src/foundry/client/apps/hud/navigation.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/pause.d.mts b/src/foundry/client/apps/hud/pause.d.mts index 6c736aefe..c1d2dd436 100644 --- a/src/foundry/client/apps/hud/pause.d.mts +++ b/src/foundry/client/apps/hud/pause.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/hud/players.d.mts b/src/foundry/client/apps/hud/players.d.mts index 424f5d32c..2c4110b99 100644 --- a/src/foundry/client/apps/hud/players.d.mts +++ b/src/foundry/client/apps/hud/players.d.mts @@ -1,4 +1,4 @@ -import type { GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts"; +import type { GetDataReturnType, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/i18n.d.mts b/src/foundry/client/apps/i18n.d.mts index a00edd96d..031099a51 100644 --- a/src/foundry/client/apps/i18n.d.mts +++ b/src/foundry/client/apps/i18n.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/drawing-config.d.mts b/src/foundry/client/apps/placeables/drawing-config.d.mts index fa16b6d85..72bc9ac10 100644 --- a/src/foundry/client/apps/placeables/drawing-config.d.mts +++ b/src/foundry/client/apps/placeables/drawing-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { interface DrawingConfigOptions extends FormApplicationOptions { diff --git a/src/foundry/client/apps/placeables/drawing-hud.d.mts b/src/foundry/client/apps/placeables/drawing-hud.d.mts index 52ae90481..624a5b1c3 100644 --- a/src/foundry/client/apps/placeables/drawing-hud.d.mts +++ b/src/foundry/client/apps/placeables/drawing-hud.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/light-config.d.mts b/src/foundry/client/apps/placeables/light-config.d.mts index 7d16f9f5a..44f39e998 100644 --- a/src/foundry/client/apps/placeables/light-config.d.mts +++ b/src/foundry/client/apps/placeables/light-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject, DeepPartial, MaybePromise } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, DeepPartial, MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/note-config.d.mts b/src/foundry/client/apps/placeables/note-config.d.mts index 2198daf2c..3fceca049 100644 --- a/src/foundry/client/apps/placeables/note-config.d.mts +++ b/src/foundry/client/apps/placeables/note-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/sound-config.d.mts b/src/foundry/client/apps/placeables/sound-config.d.mts index d99b2a54a..40d254e20 100644 --- a/src/foundry/client/apps/placeables/sound-config.d.mts +++ b/src/foundry/client/apps/placeables/sound-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/tile-config.d.mts b/src/foundry/client/apps/placeables/tile-config.d.mts index da21943a6..ecaaf2ff9 100644 --- a/src/foundry/client/apps/placeables/tile-config.d.mts +++ b/src/foundry/client/apps/placeables/tile-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/tile-hud.d.mts b/src/foundry/client/apps/placeables/tile-hud.d.mts index 0ff235684..0df5ef678 100644 --- a/src/foundry/client/apps/placeables/tile-hud.d.mts +++ b/src/foundry/client/apps/placeables/tile-hud.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/token-config.d.mts b/src/foundry/client/apps/placeables/token-config.d.mts index 90b30a454..d350d181d 100644 --- a/src/foundry/client/apps/placeables/token-config.d.mts +++ b/src/foundry/client/apps/placeables/token-config.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts"; -import type { AnyObject } from "../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject } from "../../../../utils/index.d.mts"; import type StringTerm from "../../../client-esm/dice/terms/string.d.mts"; declare global { diff --git a/src/foundry/client/apps/placeables/token-hud.d.mts b/src/foundry/client/apps/placeables/token-hud.d.mts index ca4244552..9f2fb1214 100644 --- a/src/foundry/client/apps/placeables/token-hud.d.mts +++ b/src/foundry/client/apps/placeables/token-hud.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/placeables/wall-config.d.mts b/src/foundry/client/apps/placeables/wall-config.d.mts index 02e54bff5..f943c71a9 100644 --- a/src/foundry/client/apps/placeables/wall-config.d.mts +++ b/src/foundry/client/apps/placeables/wall-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts b/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts index 90d6a470c..f589ad325 100644 --- a/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts +++ b/src/foundry/client/apps/sidebar/apps/keybindings-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/sidebar/apps/module-management.d.mts b/src/foundry/client/apps/sidebar/apps/module-management.d.mts index a203faf18..0656ac777 100644 --- a/src/foundry/client/apps/sidebar/apps/module-management.d.mts +++ b/src/foundry/client/apps/sidebar/apps/module-management.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/sidebar/apps/support-details.d.mts b/src/foundry/client/apps/sidebar/apps/support-details.d.mts index 99d925b25..0ac046dfd 100644 --- a/src/foundry/client/apps/sidebar/apps/support-details.d.mts +++ b/src/foundry/client/apps/sidebar/apps/support-details.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/apps/sidebar/apps/tours-management.d.mts b/src/foundry/client/apps/sidebar/apps/tours-management.d.mts index d78b43810..a0dd07ac3 100644 --- a/src/foundry/client/apps/sidebar/apps/tours-management.d.mts +++ b/src/foundry/client/apps/sidebar/apps/tours-management.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../../utils/index.d.mts"; declare global { /** A management app for configuring which Tours are available or have been completed. */ diff --git a/src/foundry/client/apps/sidebar/apps/world-config.d.mts b/src/foundry/client/apps/sidebar/apps/world-config.d.mts index ff2c08466..8c6ef28c6 100644 --- a/src/foundry/client/apps/sidebar/apps/world-config.d.mts +++ b/src/foundry/client/apps/sidebar/apps/world-config.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../../utils/index.d.mts"; declare global { interface WorldConfigOptions extends FormApplicationOptions { diff --git a/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts b/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts index 219c436bb..8f0a625cf 100644 --- a/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts +++ b/src/foundry/client/apps/sidebar/directory-tab-mixin.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../utils/index.d.mts"; declare class DirectoryApplication { /** @privateRemarks All mixin classses should accept anything for its constructor. */ diff --git a/src/foundry/client/apps/sidebar/package-configuration.d.mts b/src/foundry/client/apps/sidebar/package-configuration.d.mts index 6cb4e67b8..7e9b09c67 100644 --- a/src/foundry/client/apps/sidebar/package-configuration.d.mts +++ b/src/foundry/client/apps/sidebar/package-configuration.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** An application for configuring data across all installed and active packages. */ diff --git a/src/foundry/client/apps/sidebar/sidebar.d.mts b/src/foundry/client/apps/sidebar/sidebar.d.mts index 30d6e6894..f08d40464 100644 --- a/src/foundry/client/apps/sidebar/sidebar.d.mts +++ b/src/foundry/client/apps/sidebar/sidebar.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/av/client.d.mts b/src/foundry/client/av/client.d.mts index 2eeea7978..70356911f 100644 --- a/src/foundry/client/av/client.d.mts +++ b/src/foundry/client/av/client.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial } from "../../../types/utils.d.mts"; +import type { DeepPartial } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/av/clients/simplepeer.d.mts b/src/foundry/client/av/clients/simplepeer.d.mts index aba018ed7..bb4ac644c 100644 --- a/src/foundry/client/av/clients/simplepeer.d.mts +++ b/src/foundry/client/av/clients/simplepeer.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/av/master.d.mts b/src/foundry/client/av/master.d.mts index f9fa1619a..b8b0b67f1 100644 --- a/src/foundry/client/av/master.d.mts +++ b/src/foundry/client/av/master.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial } from "../../../types/utils.d.mts"; +import type { DeepPartial } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/av/settings.d.mts b/src/foundry/client/av/settings.d.mts index 3e0e22202..7cc74037d 100644 --- a/src/foundry/client/av/settings.d.mts +++ b/src/foundry/client/av/settings.d.mts @@ -1,5 +1,4 @@ -import type { GetKey } from "../../../types/helperTypes.d.mts"; -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { GetKey, ValueOf } from "../../../utils/index.d.mts"; declare global { interface AVSettingsData { diff --git a/src/foundry/client/config.d.mts b/src/foundry/client/config.d.mts index f8d2b5b45..d3060d76c 100644 --- a/src/foundry/client/config.d.mts +++ b/src/foundry/client/config.d.mts @@ -1,8 +1,7 @@ -import type { GetKey } from "../../types/helperTypes.d.mts"; import type * as CONST from "../common/constants.d.mts"; import type { DataModel, Document } from "../common/abstract/module.d.mts"; import type PointLightSource from "../client-esm/canvas/sources/point-light-source.d.mts"; -import type { AnyObject, HandleEmptyObject, MaybePromise } from "../../types/utils.d.mts"; +import type { GetKey, AnyObject, HandleEmptyObject, MaybePromise } from "../../utils/index.d.mts"; declare global { namespace CONFIG { @@ -2971,7 +2970,7 @@ declare global { zIndexScrollingText?: number; } - interface LayerDefinition { + interface LayerDefinition { layerClass: LayerClass; group: keyof CONFIG["Canvas"]["groups"]; } diff --git a/src/foundry/client/core/hooks.d.mts b/src/foundry/client/core/hooks.d.mts index facda816c..0e1c11bd3 100644 --- a/src/foundry/client/core/hooks.d.mts +++ b/src/foundry/client/core/hooks.d.mts @@ -1,4 +1,4 @@ -import type { AnyFunction } from "../../../types/utils.d.mts"; +import type { AnyFunction } from "../../../utils/index.d.mts"; export {}; diff --git a/src/foundry/client/core/image.d.mts b/src/foundry/client/core/image.d.mts index 209d326b0..ffe255756 100644 --- a/src/foundry/client/core/image.d.mts +++ b/src/foundry/client/core/image.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, NullishProps } from "../../../types/utils.d.mts"; +import type { InexactPartial, NullishProps } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/core/index.d.mts b/src/foundry/client/core/index.d.mts index 4b58acf3d..d6c214247 100644 --- a/src/foundry/client/core/index.d.mts +++ b/src/foundry/client/core/index.d.mts @@ -16,6 +16,6 @@ import "./time.d.mts"; import "./tooltip.d.mts"; import "./tour.d.mts"; import "./tours.d.mts"; -import "./utils.d.mts"; +import "../../../utils/index.d.mts"; import "./video.d.mts"; import "./workers.d.mts"; diff --git a/src/foundry/client/core/keybindings.d.mts b/src/foundry/client/core/keybindings.d.mts index 222f4edcd..6b15518a6 100644 --- a/src/foundry/client/core/keybindings.d.mts +++ b/src/foundry/client/core/keybindings.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { ValueOf } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/core/packages.d.mts b/src/foundry/client/core/packages.d.mts index f57a130f0..815f00d11 100644 --- a/src/foundry/client/core/packages.d.mts +++ b/src/foundry/client/core/packages.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, Mixin } from "../../../types/utils.d.mts"; +import type { InexactPartial, Mixin } from "../../../utils/index.d.mts"; import type { CONST } from "../../client-esm/client.d.mts"; import type BasePackage from "../../common/packages/base-package.d.mts"; diff --git a/src/foundry/client/core/settings.d.mts b/src/foundry/client/core/settings.d.mts index f4b819a71..15036ba2c 100644 --- a/src/foundry/client/core/settings.d.mts +++ b/src/foundry/client/core/settings.d.mts @@ -1,5 +1,4 @@ -import type { ConformRecord } from "../../../types/helperTypes.d.mts"; -import type { AnyArray, AnyObject, DeepPartial, InexactPartial } from "../../../types/utils.d.mts"; +import type { ConformRecord, AnyArray, AnyObject, DeepPartial, InexactPartial } from "../../../utils/index.d.mts"; import type ApplicationV2 from "../../client-esm/applications/api/application.d.mts"; import type { CustomFormInput } from "../../client-esm/applications/forms/fields.d.mts"; import type DataModel from "../../common/abstract/data.d.mts"; diff --git a/src/foundry/client/core/socket.d.mts b/src/foundry/client/core/socket.d.mts index 42eebb55b..da4b2abc1 100644 --- a/src/foundry/client/core/socket.d.mts +++ b/src/foundry/client/core/socket.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.d.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type { DatabaseOperationMap, DocumentSocketRequest } from "../../common/abstract/_types.d.mts"; declare global { diff --git a/src/foundry/client/core/sorting.d.mts b/src/foundry/client/core/sorting.d.mts index 989e12c23..82c49f5d4 100644 --- a/src/foundry/client/core/sorting.d.mts +++ b/src/foundry/client/core/sorting.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/core/tooltip.d.mts b/src/foundry/client/core/tooltip.d.mts index 67cb84409..cb2e26847 100644 --- a/src/foundry/client/core/tooltip.d.mts +++ b/src/foundry/client/core/tooltip.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { ValueOf } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/core/tour.d.mts b/src/foundry/client/core/tour.d.mts index 6b5603d3b..6b5fce168 100644 --- a/src/foundry/client/core/tour.d.mts +++ b/src/foundry/client/core/tour.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { ValueOf } from "../../../utils/index.d.mts"; export { Tour }; diff --git a/src/foundry/client/core/utils.d.mts b/src/foundry/client/core/utils.d.mts index beb09aa7c..d61c8389d 100644 --- a/src/foundry/client/core/utils.d.mts +++ b/src/foundry/client/core/utils.d.mts @@ -1,4 +1,4 @@ -import type { GetKey } from "../../../types/helperTypes.d.mts"; +import type { GetKey } from "../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/core/workers.d.mts b/src/foundry/client/core/workers.d.mts index eaed27ed8..2a9a98d9a 100644 --- a/src/foundry/client/core/workers.d.mts +++ b/src/foundry/client/core/workers.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { ValueOf } from "../../../utils/index.d.mts"; // TODO: smarter types for named functions declare global { diff --git a/src/foundry/client/data/abstract/canvas-document.d.mts b/src/foundry/client/data/abstract/canvas-document.d.mts index 0593b1864..958401c99 100644 --- a/src/foundry/client/data/abstract/canvas-document.d.mts +++ b/src/foundry/client/data/abstract/canvas-document.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { ClientDocument } from "./client-document.d.mts"; diff --git a/src/foundry/client/data/abstract/client-document.d.mts b/src/foundry/client/data/abstract/client-document.d.mts index ca034c530..e1da94775 100644 --- a/src/foundry/client/data/abstract/client-document.d.mts +++ b/src/foundry/client/data/abstract/client-document.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, DeepPartial, InexactPartial, Mixin, ValueOf } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial, Mixin, ValueOf } from "../../../../utils/index.d.mts"; import type { DatabaseCreateOperation } from "../../../common/abstract/_types.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; @@ -88,7 +88,7 @@ declare class ClientDocument | null; + protected _getSheetClass(): FormApplication.AnyConstructor | foundry.applications.api.ApplicationV2.AnyConstructor | null; /** * Safely prepare data for a Document, catching any errors. diff --git a/src/foundry/client/data/abstract/directory-collection-mixin.d.mts b/src/foundry/client/data/abstract/directory-collection-mixin.d.mts index a59d4163f..30d08fd67 100644 --- a/src/foundry/client/data/abstract/directory-collection-mixin.d.mts +++ b/src/foundry/client/data/abstract/directory-collection-mixin.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; type DirectoryCollectionMixin_DocumentCollection_Static = DirectoryCollection & diff --git a/src/foundry/client/data/abstract/document-collection.d.mts b/src/foundry/client/data/abstract/document-collection.d.mts index 290568308..66946a69f 100644 --- a/src/foundry/client/data/abstract/document-collection.d.mts +++ b/src/foundry/client/data/abstract/document-collection.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { AnyObject, DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type { DatabaseAction, DatabaseOperationMap } from "../../../common/abstract/_types.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; diff --git a/src/foundry/client/data/abstract/world-collection.d.mts b/src/foundry/client/data/abstract/world-collection.d.mts index 1e6e59c64..c51df9e44 100644 --- a/src/foundry/client/data/abstract/world-collection.d.mts +++ b/src/foundry/client/data/abstract/world-collection.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DirectoryCollectionMixin_DocumentCollection_Interface } from "./directory-collection-mixin.d.mts"; diff --git a/src/foundry/client/data/collections/actors.d.mts b/src/foundry/client/data/collections/actors.d.mts index c90883dfb..6f7eddba0 100644 --- a/src/foundry/client/data/collections/actors.d.mts +++ b/src/foundry/client/data/collections/actors.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/data/collections/compendium-collection.d.mts b/src/foundry/client/data/collections/compendium-collection.d.mts index 4ed6e7379..c62f3f545 100644 --- a/src/foundry/client/data/collections/compendium-collection.d.mts +++ b/src/foundry/client/data/collections/compendium-collection.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, EmptyObject, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, EmptyObject, InexactPartial } from "../../../../utils/index.d.mts"; import type { DatabaseCreateOperation, DatabaseDeleteOperation, diff --git a/src/foundry/client/data/collections/journal.d.mts b/src/foundry/client/data/collections/journal.d.mts index ed1589d9e..c47ea4021 100644 --- a/src/foundry/client/data/collections/journal.d.mts +++ b/src/foundry/client/data/collections/journal.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/data/collections/macros.d.mts b/src/foundry/client/data/collections/macros.d.mts index f2072cbd9..9812d4a92 100644 --- a/src/foundry/client/data/collections/macros.d.mts +++ b/src/foundry/client/data/collections/macros.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/data/collections/playlists.d.mts b/src/foundry/client/data/collections/playlists.d.mts index 0b10eadfb..37755fd0f 100644 --- a/src/foundry/client/data/collections/playlists.d.mts +++ b/src/foundry/client/data/collections/playlists.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/data/collections/scenes.d.mts b/src/foundry/client/data/collections/scenes.d.mts index c58cb20fc..5e8b1f62d 100644 --- a/src/foundry/client/data/collections/scenes.d.mts +++ b/src/foundry/client/data/collections/scenes.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/data/collections/users.d.mts b/src/foundry/client/data/collections/users.d.mts index 1f94cc5a6..74278d3f2 100644 --- a/src/foundry/client/data/collections/users.d.mts +++ b/src/foundry/client/data/collections/users.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/data/documents/active-effect.d.mts b/src/foundry/client/data/documents/active-effect.d.mts index 73d752eff..88362f3da 100644 --- a/src/foundry/client/data/documents/active-effect.d.mts +++ b/src/foundry/client/data/documents/active-effect.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject } from "../../../../utils/index.d.mts"; import type { DataModel } from "../../../common/abstract/data.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; diff --git a/src/foundry/client/data/documents/actor.d.mts b/src/foundry/client/data/documents/actor.d.mts index 6ced68b37..0876993df 100644 --- a/src/foundry/client/data/documents/actor.d.mts +++ b/src/foundry/client/data/documents/actor.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseActor from "../../../common/documents/actor.d.mts"; diff --git a/src/foundry/client/data/documents/adventure.d.mts b/src/foundry/client/data/documents/adventure.d.mts index 736285fae..5ec16a688 100644 --- a/src/foundry/client/data/documents/adventure.d.mts +++ b/src/foundry/client/data/documents/adventure.d.mts @@ -1,5 +1,4 @@ -import type { FolderDocumentTypes } from "../../../../types/helperTypes.d.mts"; -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { FolderDocumentTypes, InexactPartial } from "../../../../utils/index.d.mts"; // eslint-disable-next-line import/no-named-as-default import type DataModel from "../../../common/abstract/data.d.mts"; import type { fields } from "../../../common/data/module.d.mts"; diff --git a/src/foundry/client/data/documents/card.d.mts b/src/foundry/client/data/documents/card.d.mts index 763cc1688..85baae9dc 100644 --- a/src/foundry/client/data/documents/card.d.mts +++ b/src/foundry/client/data/documents/card.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type { CardFaceData } from "../../../common/documents/_types.d.mts"; diff --git a/src/foundry/client/data/documents/cards.d.mts b/src/foundry/client/data/documents/cards.d.mts index 51c68e518..f3c9fb1c8 100644 --- a/src/foundry/client/data/documents/cards.d.mts +++ b/src/foundry/client/data/documents/cards.d.mts @@ -1,5 +1,4 @@ -import type { DatabaseOperationsFor } from "../../../../types/helperTypes.d.mts"; -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type { fields } from "../../../common/data/module.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; @@ -183,7 +182,9 @@ declare global { data: Array< fields.SchemaField.AssignmentType>["schema"]["fields"]> & Record >, - operation?: InexactPartial["metadata"]["name"], "create">, "data">> & { + operation?: InexactPartial< + Omit["metadata"]["name"], "create">, "data"> + > & { temporary?: Temporary; }, ): Promise[] | undefined>; @@ -344,7 +345,7 @@ declare global { static override createDialog( this: T, data?: DeepPartial> & Record>, - context?: Pick, "parent" | "pack"> & + context?: Pick, "parent" | "pack"> & InexactPartial< DialogOptions & { /** A restriction the selectable sub-types of the Dialog. */ diff --git a/src/foundry/client/data/documents/chat-message.d.mts b/src/foundry/client/data/documents/chat-message.d.mts index ab38ed584..c9db9a5aa 100644 --- a/src/foundry/client/data/documents/chat-message.d.mts +++ b/src/foundry/client/data/documents/chat-message.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseChatMessage from "../../../common/documents/chat-message.d.mts"; diff --git a/src/foundry/client/data/documents/combat.d.mts b/src/foundry/client/data/documents/combat.d.mts index 819b9c2e6..0344eac65 100644 --- a/src/foundry/client/data/documents/combat.d.mts +++ b/src/foundry/client/data/documents/combat.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseCombat from "../../../common/documents/combat.d.mts"; diff --git a/src/foundry/client/data/documents/combatant.d.mts b/src/foundry/client/data/documents/combatant.d.mts index a4ab27415..a984b8e38 100644 --- a/src/foundry/client/data/documents/combatant.d.mts +++ b/src/foundry/client/data/documents/combatant.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../../types/utils.d.mts"; +import type { ValueOf } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseCombatant from "../../../common/documents/combatant.d.mts"; diff --git a/src/foundry/client/data/documents/fog-exploration.d.mts b/src/foundry/client/data/documents/fog-exploration.d.mts index a6a26e7fa..719fc6743 100644 --- a/src/foundry/client/data/documents/fog-exploration.d.mts +++ b/src/foundry/client/data/documents/fog-exploration.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { DatabaseGetOperation } from "../../../common/abstract/_types.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; diff --git a/src/foundry/client/data/documents/folder.d.mts b/src/foundry/client/data/documents/folder.d.mts index 9227245a0..5bdbbfb44 100644 --- a/src/foundry/client/data/documents/folder.d.mts +++ b/src/foundry/client/data/documents/folder.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseFolder from "../../../common/documents/folder.d.mts"; @@ -20,6 +20,11 @@ declare global { type Schema = BaseFolder.Schema; type Source = BaseFolder.Source; + /** + * Actual document types that go in folders + */ + type DocumentType = Exclude; + interface ExportToCompendiumOptions { /** Update existing entries in the Compendium pack, matching by name */ updateByName?: boolean | undefined; diff --git a/src/foundry/client/data/documents/journal-entry-page.d.mts b/src/foundry/client/data/documents/journal-entry-page.d.mts index 6024dbfcc..73ebd0a44 100644 --- a/src/foundry/client/data/documents/journal-entry-page.d.mts +++ b/src/foundry/client/data/documents/journal-entry-page.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseJournalEntryPage from "../../../common/documents/journal-entry-page.d.mts"; diff --git a/src/foundry/client/data/documents/macro.d.mts b/src/foundry/client/data/documents/macro.d.mts index 5bb2532e4..eff5ad46e 100644 --- a/src/foundry/client/data/documents/macro.d.mts +++ b/src/foundry/client/data/documents/macro.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseMacro from "../../../common/documents/macro.d.mts"; diff --git a/src/foundry/client/data/documents/playlist-sound.d.mts b/src/foundry/client/data/documents/playlist-sound.d.mts index 929d8a275..177f338d6 100644 --- a/src/foundry/client/data/documents/playlist-sound.d.mts +++ b/src/foundry/client/data/documents/playlist-sound.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Sound from "../../../client-esm/audio/sound.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; diff --git a/src/foundry/client/data/documents/playlist.d.mts b/src/foundry/client/data/documents/playlist.d.mts index 2d4dae8ff..f33b8d860 100644 --- a/src/foundry/client/data/documents/playlist.d.mts +++ b/src/foundry/client/data/documents/playlist.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type { Document } from "../../../common/abstract/module.d.mts"; import type BasePlaylist from "../../../common/documents/playlist.d.mts"; diff --git a/src/foundry/client/data/documents/scene.d.mts b/src/foundry/client/data/documents/scene.d.mts index 0ee5a3f41..3fe6b6d1d 100644 --- a/src/foundry/client/data/documents/scene.d.mts +++ b/src/foundry/client/data/documents/scene.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseScene from "../../../common/documents/scene.d.mts"; diff --git a/src/foundry/client/data/documents/table.d.mts b/src/foundry/client/data/documents/table.d.mts index 0b5b6d2a9..daba62f4d 100644 --- a/src/foundry/client/data/documents/table.d.mts +++ b/src/foundry/client/data/documents/table.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseRollTable from "../../../common/documents/roll-table.d.mts"; diff --git a/src/foundry/client/data/documents/token.d.mts b/src/foundry/client/data/documents/token.d.mts index a12c97d0f..15a647a56 100644 --- a/src/foundry/client/data/documents/token.d.mts +++ b/src/foundry/client/data/documents/token.d.mts @@ -1,4 +1,4 @@ -import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts"; +import type { DeepPartial, InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type { SchemaField } from "../../../common/data/fields.d.mts"; diff --git a/src/foundry/client/data/documents/user.d.mts b/src/foundry/client/data/documents/user.d.mts index b3cdf226e..a9113182b 100644 --- a/src/foundry/client/data/documents/user.d.mts +++ b/src/foundry/client/data/documents/user.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; import type Document from "../../../common/abstract/document.d.mts"; import type { DocumentDatabaseOperations } from "../../../common/abstract/document.d.mts"; import type BaseUser from "../../../common/documents/user.d.mts"; diff --git a/src/foundry/client/game.d.mts b/src/foundry/client/game.d.mts index 1a6b1e1d2..7cdcd7891 100644 --- a/src/foundry/client/game.d.mts +++ b/src/foundry/client/game.d.mts @@ -1,11 +1,5 @@ import type { Socket } from "socket.io-client"; -import type { - ConfiguredDocumentClassForName, - ConfiguredModule, - GetKey, - ModuleRequiredOrOptional, -} from "../../types/helperTypes.d.mts"; -import type { EmptyObject, ValueOf } from "../../types/utils.d.mts"; +import type { ConfiguredModule, GetKey, EmptyObject, ValueOf } from "../../utils/index.d.mts"; import type BasePackage from "../common/packages/base-package.d.mts"; import type { Document } from "../common/abstract/module.d.mts"; @@ -654,7 +648,7 @@ declare global { * @see {@link RequiredModules} to remove `undefined` from the return type for a given module * @param id - The module ID to look up */ - get(id: T): (Module & ConfiguredModule) | Exclude, undefined>; + get(id: T): Module & ConfiguredModule; } namespace Model { @@ -753,8 +747,8 @@ declare global { } & { [DocumentType in | foundry.CONST.DOCUMENT_TYPES - | "Setting" as ConfiguredDocumentClassForName["metadata"]["collection"]]?: InstanceType< - ConfiguredDocumentClassForName + | "Setting" as Document.ConfiguredClassForName["metadata"]["collection"]]?: InstanceType< + Document.ConfiguredClassForName >["_source"][]; }; diff --git a/src/foundry/client/hooks.d.mts b/src/foundry/client/hooks.d.mts index e08edfedd..4bf9e87f4 100644 --- a/src/foundry/client/hooks.d.mts +++ b/src/foundry/client/hooks.d.mts @@ -1,5 +1,5 @@ import type { EditorState, Plugin } from "prosemirror-state"; -import type { DeepPartial, EmptyObject, ValueOf } from "../../types/utils.d.mts"; +import type { DeepPartial, EmptyObject, ValueOf } from "../../utils/index.d.mts"; import type Document from "../common/abstract/document.d.mts"; import type { EffectChangeData } from "../common/documents/_types.d.mts"; import type { ProseMirrorDropDown } from "../common/prosemirror/menu.d.mts"; diff --git a/src/foundry/client/pixi/board.d.mts b/src/foundry/client/pixi/board.d.mts index 94099bce6..9fe51fce6 100644 --- a/src/foundry/client/pixi/board.d.mts +++ b/src/foundry/client/pixi/board.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, NullishProps } from "../../../types/utils.d.mts"; +import type { InexactPartial, NullishProps } from "../../../utils/index.d.mts"; import type Document from "../../common/abstract/document.d.mts"; import type { CANVAS_PERFORMANCE_MODES } from "../../common/constants.d.mts"; diff --git a/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts b/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts index 57829933b..e0aa7bf92 100644 --- a/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts +++ b/src/foundry/client/pixi/core/containers/base-canvas-group.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, Mixin } from "../../../../../types/utils.d.mts"; +import type { AnyObject, Mixin } from "../../../../../utils/index.d.mts"; declare class CanvasGroup { /** @privateRemarks All mixin classses should accept anything for its constructor. */ diff --git a/src/foundry/client/pixi/core/containers/cached-container.d.mts b/src/foundry/client/pixi/core/containers/cached-container.d.mts index b7e5d0a37..5c6a87b84 100644 --- a/src/foundry/client/pixi/core/containers/cached-container.d.mts +++ b/src/foundry/client/pixi/core/containers/cached-container.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps } from "../../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../../utils/index.d.mts"; export {}; diff --git a/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts b/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts index d0fd197cc..6c3f29b59 100644 --- a/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts +++ b/src/foundry/client/pixi/core/containers/full-canvas-container.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../../utils/index.d.mts"; declare class FullCanvasObject { /** @privateRemarks All mixin classses should accept anything for its constructor. */ diff --git a/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts b/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts index e0e045c5f..51915bd22 100644 --- a/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts +++ b/src/foundry/client/pixi/core/interaction/canvas-animation.d.mts @@ -1,5 +1,4 @@ -import type { ValueOf } from "../../../../../types/utils.d.mts"; -import type { PropertiesOfType } from "../../../../../types/helperTypes.d.mts"; +import type { ValueOf, PropertiesOfType } from "../../../../../utils/index.d.mts"; declare global { namespace CanvasAnimation { diff --git a/src/foundry/client/pixi/core/interaction/control-icon.d.mts b/src/foundry/client/pixi/core/interaction/control-icon.d.mts index 4e48be343..78ad1c9f0 100644 --- a/src/foundry/client/pixi/core/interaction/control-icon.d.mts +++ b/src/foundry/client/pixi/core/interaction/control-icon.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts b/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts index 90df1c48b..93c66d32b 100644 --- a/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts +++ b/src/foundry/client/pixi/core/interaction/mouse-handler.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../../../types/utils.d.mts"; +import type { ValueOf } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/core/interaction/render-flags.d.mts b/src/foundry/client/pixi/core/interaction/render-flags.d.mts index ea23ebb09..660b22f91 100644 --- a/src/foundry/client/pixi/core/interaction/render-flags.d.mts +++ b/src/foundry/client/pixi/core/interaction/render-flags.d.mts @@ -1,4 +1,4 @@ -import type { AnyConstructor, InexactPartial, Mixin } from "../../../../../types/utils.d.mts"; +import type { AnyConstructor, InexactPartial, Mixin } from "../../../../../utils/index.d.mts"; import type { LogCompatibilityWarningOptions } from "../../../../common/utils/logging.d.mts"; declare class RenderFlagObject { diff --git a/src/foundry/client/pixi/core/loader.d.mts b/src/foundry/client/pixi/core/loader.d.mts index c91608ef2..d586e4bb8 100644 --- a/src/foundry/client/pixi/core/loader.d.mts +++ b/src/foundry/client/pixi/core/loader.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts b/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts index e3cb560fb..4dd0c9f6b 100644 --- a/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts +++ b/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/core/shapes/source-polygon.d.mts b/src/foundry/client/pixi/core/shapes/source-polygon.d.mts index 50ae1b442..76850976b 100644 --- a/src/foundry/client/pixi/core/shapes/source-polygon.d.mts +++ b/src/foundry/client/pixi/core/shapes/source-polygon.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; import type PointEffectSourceMixin from "../../../../client-esm/canvas/sources/point-effect-source.d.mts"; declare global { @@ -57,7 +57,7 @@ declare global { * (default: `{}`) * @returns The computed polygon instance */ - static create>( + static create( this: T, origin: Canvas.Point, config?: Parameters>["initialize"]>[1], @@ -180,6 +180,8 @@ declare global { } namespace PointSourcePolygon { + type AnyConstructor = typeof AnyPointSourcePolygon; + /** @internal */ type _Config = InexactPartial<{ /** The angle of emission, if limited */ @@ -247,3 +249,7 @@ declare global { type TestCollision = CollisionTypes[Mode]; } } + +declare abstract class AnyPointSourcePolygon extends PointSourcePolygon { + constructor(arg0: never, ...args: never[]); +} diff --git a/src/foundry/client/pixi/extensions/circle.d.mts b/src/foundry/client/pixi/extensions/circle.d.mts index 9851fe1dc..bff0945a3 100644 --- a/src/foundry/client/pixi/extensions/circle.d.mts +++ b/src/foundry/client/pixi/extensions/circle.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps } from "../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../utils/index.d.mts"; import type { LineCircleIntersection } from "../../../common/utils/geometry.d.mts"; declare module "pixi.js" { diff --git a/src/foundry/client/pixi/extensions/observable-transform.d.mts b/src/foundry/client/pixi/extensions/observable-transform.d.mts index c4a54f310..7beeab017 100644 --- a/src/foundry/client/pixi/extensions/observable-transform.d.mts +++ b/src/foundry/client/pixi/extensions/observable-transform.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../../types/utils.d.mts"; +import type { AnyObject } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/extensions/polygon.d.mts b/src/foundry/client/pixi/extensions/polygon.d.mts index e56551c30..cec73175a 100644 --- a/src/foundry/client/pixi/extensions/polygon.d.mts +++ b/src/foundry/client/pixi/extensions/polygon.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, NullishProps } from "../../../../types/utils.d.mts"; +import type { InexactPartial, NullishProps } from "../../../../utils/index.d.mts"; declare module "pixi.js" { interface Polygon { diff --git a/src/foundry/client/pixi/extensions/rectangle.d.mts b/src/foundry/client/pixi/extensions/rectangle.d.mts index 8a1ba8e0d..454897f55 100644 --- a/src/foundry/client/pixi/extensions/rectangle.d.mts +++ b/src/foundry/client/pixi/extensions/rectangle.d.mts @@ -1,5 +1,4 @@ -import type { UnionToIntersection, Brand } from "../../../../types/helperTypes.d.mts"; -import type { InexactPartial, NullishProps } from "../../../../types/utils.d.mts"; +import type { UnionToIntersection, Brand, InexactPartial, NullishProps } from "../../../../utils/index.d.mts"; /** * Typically in a mapped type TypeScript associates your type to the original. diff --git a/src/foundry/client/pixi/groups/effects.d.mts b/src/foundry/client/pixi/groups/effects.d.mts index c62952378..a199e5972 100644 --- a/src/foundry/client/pixi/groups/effects.d.mts +++ b/src/foundry/client/pixi/groups/effects.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../../types/utils.d.mts"; +import type { ValueOf } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/groups/environment.d.mts b/src/foundry/client/pixi/groups/environment.d.mts index bf019b6a2..db41ce66d 100644 --- a/src/foundry/client/pixi/groups/environment.d.mts +++ b/src/foundry/client/pixi/groups/environment.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; // TODO: Remove when this is typed as part of #2674 type SceneEnvironmentData = unknown; diff --git a/src/foundry/client/pixi/groups/interface.d.mts b/src/foundry/client/pixi/groups/interface.d.mts index e168dd2cb..e1582fb85 100644 --- a/src/foundry/client/pixi/groups/interface.d.mts +++ b/src/foundry/client/pixi/groups/interface.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/base/interaction-layer.d.mts b/src/foundry/client/pixi/layers/base/interaction-layer.d.mts index fab1fe33b..1bb12e774 100644 --- a/src/foundry/client/pixi/layers/base/interaction-layer.d.mts +++ b/src/foundry/client/pixi/layers/base/interaction-layer.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps } from "../../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/base/placeables-layer.d.mts b/src/foundry/client/pixi/layers/base/placeables-layer.d.mts index 957439fce..22420079e 100644 --- a/src/foundry/client/pixi/layers/base/placeables-layer.d.mts +++ b/src/foundry/client/pixi/layers/base/placeables-layer.d.mts @@ -1,5 +1,4 @@ -import type { ArrayOverlaps } from "../../../../../types/helperTypes.d.mts"; -import type { ConstructorOf, InexactPartial, NullishProps, ValueOf } from "../../../../../types/utils.d.mts"; +import type { ArrayOverlaps, InexactPartial, NullishProps, ValueOf } from "../../../../../utils/index.d.mts"; import type Document from "../../../../common/abstract/document.d.mts"; import type EmbeddedCollection from "../../../../common/abstract/embedded-collection.d.mts"; @@ -98,7 +97,7 @@ declare global { /** * Define a Container implementation used to render placeable objects contained in this layer */ - static get placeableClass(): ConstructorOf; + static get placeableClass(): PlaceableObject.AnyConstructor; /** * If objects on this PlaceablesLayer have a HUD UI, provide a reference to its instance diff --git a/src/foundry/client/pixi/layers/controls/layer.d.mts b/src/foundry/client/pixi/layers/controls/layer.d.mts index 05712f359..235a0a95d 100644 --- a/src/foundry/client/pixi/layers/controls/layer.d.mts +++ b/src/foundry/client/pixi/layers/controls/layer.d.mts @@ -1,5 +1,4 @@ -import type { IntentionalPartial } from "../../../../../types/helperTypes.d.mts"; -import type { InexactPartial, NullishProps, RemoveIndexSignatures } from "../../../../../types/utils.d.mts"; +import type { IntentionalPartial, InexactPartial, NullishProps, RemoveIndexSignatures } from "../../../../../utils/index.d.mts"; import type { LineIntersection } from "../../../../common/utils/geometry.d.mts"; declare global { diff --git a/src/foundry/client/pixi/layers/controls/ruler.d.mts b/src/foundry/client/pixi/layers/controls/ruler.d.mts index 5080f4476..bb1a33dee 100644 --- a/src/foundry/client/pixi/layers/controls/ruler.d.mts +++ b/src/foundry/client/pixi/layers/controls/ruler.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps, ValueOf } from "../../../../../types/utils.d.mts"; +import type { NullishProps, ValueOf } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts b/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts index b035bd63b..37665b8ad 100644 --- a/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts +++ b/src/foundry/client/pixi/layers/effects/illumination-effects.d.mts @@ -1,4 +1,4 @@ -import type { NullishProps } from "../../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/effects/visibility.d.mts b/src/foundry/client/pixi/layers/effects/visibility.d.mts index ee8102891..be8fe4987 100644 --- a/src/foundry/client/pixi/layers/effects/visibility.d.mts +++ b/src/foundry/client/pixi/layers/effects/visibility.d.mts @@ -1,4 +1,4 @@ -import type { EmptyObject, InexactPartial, ValueOf } from "../../../../../types/utils.d.mts"; +import type { EmptyObject, InexactPartial, ValueOf } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/effects/weather-effects.d.mts b/src/foundry/client/pixi/layers/effects/weather-effects.d.mts index 60d107a6f..92ea6c0bd 100644 --- a/src/foundry/client/pixi/layers/effects/weather-effects.d.mts +++ b/src/foundry/client/pixi/layers/effects/weather-effects.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/grid/layer.d.mts b/src/foundry/client/pixi/layers/grid/layer.d.mts index 378e4a74c..47d7eb78f 100644 --- a/src/foundry/client/pixi/layers/grid/layer.d.mts +++ b/src/foundry/client/pixi/layers/grid/layer.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, NullishProps } from "../../../../../types/utils.d.mts"; +import type { InexactPartial, NullishProps } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/grid/mesh.d.mts b/src/foundry/client/pixi/layers/grid/mesh.d.mts index 5b1296f9d..17e265c7d 100644 --- a/src/foundry/client/pixi/layers/grid/mesh.d.mts +++ b/src/foundry/client/pixi/layers/grid/mesh.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/placeables/notes.d.mts b/src/foundry/client/pixi/layers/placeables/notes.d.mts index c1055b94e..e7e6dc027 100644 --- a/src/foundry/client/pixi/layers/placeables/notes.d.mts +++ b/src/foundry/client/pixi/layers/placeables/notes.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/layers/placeables/sounds.d.mts b/src/foundry/client/pixi/layers/placeables/sounds.d.mts index 1d9204aeb..a02bd099d 100644 --- a/src/foundry/client/pixi/layers/placeables/sounds.d.mts +++ b/src/foundry/client/pixi/layers/placeables/sounds.d.mts @@ -1,5 +1,4 @@ -import type { IntentionalPartial } from "../../../../../types/helperTypes.d.mts"; -import type { InexactPartial, NullishProps } from "../../../../../types/utils.d.mts"; +import type { IntentionalPartial, InexactPartial, NullishProps } from "../../../../../utils/index.d.mts"; import type { AmbientSoundEffect } from "../../../../common/documents/_types.d.mts"; declare global { diff --git a/src/foundry/client/pixi/layers/placeables/tokens.d.mts b/src/foundry/client/pixi/layers/placeables/tokens.d.mts index aeb4193e2..fc86ec8ae 100644 --- a/src/foundry/client/pixi/layers/placeables/tokens.d.mts +++ b/src/foundry/client/pixi/layers/placeables/tokens.d.mts @@ -1,5 +1,4 @@ -import type { ArrayOverlaps } from "../../../../../types/helperTypes.d.mts"; -import type { NullishProps } from "../../../../../types/utils.d.mts"; +import type { ArrayOverlaps, NullishProps } from "../../../../../utils/index.d.mts"; import type Document from "../../../../common/abstract/document.d.mts"; declare global { diff --git a/src/foundry/client/pixi/layers/placeables/walls.d.mts b/src/foundry/client/pixi/layers/placeables/walls.d.mts index 6f8a58bcc..db25cac96 100644 --- a/src/foundry/client/pixi/layers/placeables/walls.d.mts +++ b/src/foundry/client/pixi/layers/placeables/walls.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, NullishProps } from "../../../../../types/utils.d.mts"; +import type { NullishProps } from "../../../../../utils/index.d.mts"; import type Document from "../../../../common/abstract/document.d.mts"; declare global { @@ -197,7 +197,7 @@ declare global { controllableObjects: true; objectClass: typeof Wall; quadtree: true; - sheetClass: ConstructorOf; + sheetClass: FormApplication.AnyConstructor; sortActiveTop: boolean; zIndex: number; } diff --git a/src/foundry/client/pixi/perception/detection-mode.d.mts b/src/foundry/client/pixi/perception/detection-mode.d.mts index 310f8daca..869b220c2 100644 --- a/src/foundry/client/pixi/perception/detection-mode.d.mts +++ b/src/foundry/client/pixi/perception/detection-mode.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, ValueOf } from "../../../../types/utils.d.mts"; +import type { InexactPartial, ValueOf } from "../../../../utils/index.d.mts"; import type { fields } from "../../../common/data/module.d.mts"; import type { TokenDetectionMode } from "../../../common/documents/_types.d.mts"; diff --git a/src/foundry/client/pixi/perception/vision-mode.d.mts b/src/foundry/client/pixi/perception/vision-mode.d.mts index 6f4d9a743..daf0fa514 100644 --- a/src/foundry/client/pixi/perception/vision-mode.d.mts +++ b/src/foundry/client/pixi/perception/vision-mode.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial, SimpleMerge, ValueOf } from "../../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial, SimpleMerge, ValueOf } from "../../../../utils/index.d.mts"; import type { fields } from "../../../common/data/module.d.mts"; declare global { diff --git a/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts b/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts index ae9377673..6be42e371 100644 --- a/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts +++ b/src/foundry/client/pixi/perception/weiler-atherton-clipping.d.mts @@ -1,5 +1,4 @@ -import type { Brand } from "../../../../types/helperTypes.d.mts"; -import type { NullishProps } from "../../../../types/utils.d.mts"; +import type { Brand, NullishProps } from "../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/placeable.d.mts b/src/foundry/client/pixi/placeable.d.mts index c8a1ee555..29b1f805d 100644 --- a/src/foundry/client/pixi/placeable.d.mts +++ b/src/foundry/client/pixi/placeable.d.mts @@ -1,5 +1,4 @@ -import type { MakeConform } from "../../../types/helperTypes.d.mts"; -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { MakeConform, ValueOf } from "../../../utils/index.d.mts"; import type ApplicationV2 from "../../client-esm/applications/api/application.d.mts"; import type { Document } from "../../common/abstract/module.d.mts"; diff --git a/src/foundry/client/pixi/placeables/drawing.d.mts b/src/foundry/client/pixi/placeables/drawing.d.mts index af41dad3a..e49af7996 100644 --- a/src/foundry/client/pixi/placeables/drawing.d.mts +++ b/src/foundry/client/pixi/placeables/drawing.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../../types/utils.d.mts"; +import type { ValueOf } from "../../../../utils/index.d.mts"; import type { ConfiguredObjectClassOrDefault } from "../../config.d.mts"; declare global { diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts index 9cf4dccb6..8edb9c949 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../../utils/index.d.mts"; import type Document from "../../../../common/abstract/document.d.mts"; declare class PrimaryCanvasObject { diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts index 4acf641c4..e6361b3b3 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-graphics.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { /** diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts index f83fce31f..0401966d8 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-occludable-object.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, Mixin } from "../../../../../types/utils.d.mts"; +import type { InexactPartial, Mixin } from "../../../../../utils/index.d.mts"; declare class PrimaryOccludableObject { /** @privateRemarks All mixin classses should accept anything for its constructor. */ diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts index 2319d52e2..e91d2accd 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-sprite-mesh.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; // TODO: Remove when #2570 is completed declare const PrimaryBaseSamplerShader: BaseSamplerShader; diff --git a/src/foundry/client/pixi/placeables/template.d.mts b/src/foundry/client/pixi/placeables/template.d.mts index d4afffe9c..f356002d0 100644 --- a/src/foundry/client/pixi/placeables/template.d.mts +++ b/src/foundry/client/pixi/placeables/template.d.mts @@ -1,4 +1,4 @@ -import type { RequiredProps } from "../../../../types/utils.d.mts"; +import type { RequiredProps } from "../../../../utils/index.d.mts"; import type { ConfiguredObjectClassOrDefault } from "../../config.d.mts"; declare global { diff --git a/src/foundry/client/pixi/placeables/token.d.mts b/src/foundry/client/pixi/placeables/token.d.mts index ce41fba92..6caf3e380 100644 --- a/src/foundry/client/pixi/placeables/token.d.mts +++ b/src/foundry/client/pixi/placeables/token.d.mts @@ -1,4 +1,4 @@ -import type { RequiredProps } from "../../../../types/utils.d.mts"; +import type { RequiredProps } from "../../../../utils/index.d.mts"; import type { ConfiguredObjectClassOrDefault } from "../../config.d.mts"; declare global { diff --git a/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts b/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts index 08f3c7ed6..492376784 100644 --- a/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts +++ b/src/foundry/client/pixi/webgl/extensions/batch-renderer.d.mts @@ -1,5 +1,4 @@ -import type { ToMethod } from "../../../../../types/helperTypes.d.mts"; -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { ToMethod, InexactPartial } from "../../../../../utils/index.d.mts"; declare abstract class AnyBatchRenderer extends BatchRenderer { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts b/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts index 062290f3b..89a36de35 100644 --- a/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts +++ b/src/foundry/client/pixi/webgl/helpers/smooth-noise.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare global { namespace SmoothNoise { diff --git a/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts b/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts index 5ac356921..6eceb5b9c 100644 --- a/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts +++ b/src/foundry/client/pixi/webgl/helpers/texture-extractor.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../utils/index.d.mts"; declare abstract class AnyTextureExtractor extends TextureExtractor { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts b/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts index 0a713a792..f49179f9c 100644 --- a/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/base-shader-mixin.d.mts @@ -1,4 +1,4 @@ -import type { Mixin } from "../../../../../types/utils.d.mts"; +import type { Mixin } from "../../../../../utils/index.d.mts"; declare abstract class AnyBaseShader extends BaseShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts b/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts index a3ee3166c..7f16ed2b1 100644 --- a/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/base-shader.d.mts @@ -1,4 +1,4 @@ -import type { ToMethod } from "../../../../../types/helperTypes.d.mts"; +import type { ToMethod } from "../../../../../utils/index.d.mts"; declare abstract class AnyAbstractBaseShader extends AbstractBaseShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts b/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts index b5aa1a7fe..eeb22c712 100644 --- a/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/filters/effects-masking.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, ShapeWithIndexSignature } from "../../../../../../types/utils.d.mts"; +import type { AnyObject, ShapeWithIndexSignature } from "../../../../../../utils/index.d.mts"; declare abstract class AnyVisualEffectsMaskingFilter extends VisualEffectsMaskingFilter { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts b/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts index 0145dadfb..1a4827d5e 100644 --- a/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/filters/transition.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, ValueOf } from "../../../../../../types/utils.d.mts"; +import type { InexactPartial, ValueOf } from "../../../../../../utils/index.d.mts"; declare abstract class AnyTextureTransitionFilter extends TextureTransitionFilter { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts b/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts index d36d149d6..81ab0a291 100644 --- a/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/filters/visibility.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../../utils/index.d.mts"; declare abstract class AnyVisibilityFilter extends VisibilityFilter { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts b/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts index 64e609518..941807c25 100644 --- a/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/fragment-channel-mixin.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, Mixin, ShapeWithIndexSignature } from "../../../../../types/utils.d.mts"; +import type { AnyObject, Mixin, ShapeWithIndexSignature } from "../../../../../utils/index.d.mts"; declare abstract class AnyAdaptiveFragmentChannel extends AdaptiveFragmentChannel { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts b/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts index d63295231..99fc1372b 100644 --- a/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/grid/grid.d.mts @@ -1,4 +1,4 @@ -import type { IntentionalPartial } from "../../../../../../types/helperTypes.d.mts"; +import type { IntentionalPartial } from "../../../../../../utils/index.d.mts"; declare abstract class AnyGridShader extends GridShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts b/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts index 7aad78c65..27a86e62f 100644 --- a/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/samplers/base-sampler.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, Mixin } from "../../../../../../types/utils.d.mts"; +import type { InexactPartial, Mixin } from "../../../../../../utils/index.d.mts"; declare abstract class AnyBaseSamplerShader extends BaseSamplerShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts b/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts index 1ddeefc71..d71183da8 100644 --- a/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/weather/base-weather.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../../../../types/helperTypes.d.mts"; -import type { AnyObject, RemoveIndexSignatures } from "../../../../../../types/utils.d.mts"; +import type { InterfaceToObject, AnyObject, RemoveIndexSignatures } from "../../../../../../utils/index.d.mts"; declare abstract class AnyAbstractWeatherShader extends AbstractWeatherShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts b/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts index c84d9a6cd..ef630990d 100644 --- a/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/weather/effect.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../../../../utils/index.d.mts"; declare abstract class AnyWeatherShaderEffect extends WeatherShaderEffect { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts b/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts index da20ef9b1..5b6cd4f97 100644 --- a/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/weather/fog.d.mts @@ -1,4 +1,4 @@ -import type { InterfaceToObject } from "../../../../../../types/helperTypes.d.mts"; +import type { InterfaceToObject } from "../../../../../../utils/index.d.mts"; declare abstract class AnyFogShader extends FogShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts b/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts index 4ff724ecc..a10a9c574 100644 --- a/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/weather/rain.d.mts @@ -1,4 +1,4 @@ -import type { InterfaceToObject } from "../../../../../../types/helperTypes.d.mts"; +import type { InterfaceToObject } from "../../../../../../utils/index.d.mts"; declare abstract class AnyRainShader extends RainShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts b/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts index e42e6c531..3d3106573 100644 --- a/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts +++ b/src/foundry/client/pixi/webgl/shaders/weather/snow.d.mts @@ -1,4 +1,4 @@ -import type { InterfaceToObject } from "../../../../../../types/helperTypes.d.mts"; +import type { InterfaceToObject } from "../../../../../../utils/index.d.mts"; declare abstract class AnySnowShader extends SnowShader { constructor(arg0: never, ...args: never[]); diff --git a/src/foundry/client/ui/context.d.mts b/src/foundry/client/ui/context.d.mts index dfdb9c57d..177436535 100644 --- a/src/foundry/client/ui/context.d.mts +++ b/src/foundry/client/ui/context.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type ApplicationV2 from "../../client-esm/applications/api/application.d.mts"; export {}; diff --git a/src/foundry/client/ui/dialog.d.mts b/src/foundry/client/ui/dialog.d.mts index 4c6ae10f5..028f2c2a3 100644 --- a/src/foundry/client/ui/dialog.d.mts +++ b/src/foundry/client/ui/dialog.d.mts @@ -1,4 +1,4 @@ -import type { MaybePromise } from "../../../types/utils.d.mts"; +import type { MaybePromise } from "../../../utils/index.d.mts"; declare global { interface DialogOptions extends ApplicationOptions { diff --git a/src/foundry/client/ui/dragdrop.d.mts b/src/foundry/client/ui/dragdrop.d.mts index 04ddf3a13..cbb789da0 100644 --- a/src/foundry/client/ui/dragdrop.d.mts +++ b/src/foundry/client/ui/dragdrop.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; export {}; diff --git a/src/foundry/client/ui/editor.d.mts b/src/foundry/client/ui/editor.d.mts index 0365000cc..293c804e1 100644 --- a/src/foundry/client/ui/editor.d.mts +++ b/src/foundry/client/ui/editor.d.mts @@ -1,6 +1,6 @@ import type { EditorView } from "prosemirror-view"; -import type { AnyObject, InexactPartial, MaybePromise } from "../../../types/utils.d.mts"; -import type { ConfiguredDocumentClassForName } from "../../../types/helperTypes.d.mts"; +import type { AnyObject, InexactPartial, MaybePromise } from "../../../utils/index.d.mts"; +import type Document from "../../common/abstract/document.d.mts"; declare global { /** @@ -290,7 +290,7 @@ declare global { */ static getDragEventData( event: DragEvent, - ): PlaceableObject | number | Promise>; + ): PlaceableObject | number | Promise>; /** * Given a Drop event, returns a Content link if possible such as `@Actor[ABC123]`, else null diff --git a/src/foundry/client/ui/filepicker.d.mts b/src/foundry/client/ui/filepicker.d.mts index ce0368773..bc97941fb 100644 --- a/src/foundry/client/ui/filepicker.d.mts +++ b/src/foundry/client/ui/filepicker.d.mts @@ -1,4 +1,4 @@ -import type { EmptyObject, MaybePromise, ValueOf } from "../../../types/utils.d.mts"; +import type { EmptyObject, MaybePromise, ValueOf } from "../../../utils/index.d.mts"; declare global { interface FilePickerOptions extends ApplicationOptions { diff --git a/src/foundry/client/ui/filter.d.mts b/src/foundry/client/ui/filter.d.mts index fcd06e966..b22eb043b 100644 --- a/src/foundry/client/ui/filter.d.mts +++ b/src/foundry/client/ui/filter.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../../types/utils.d.mts"; +import type { ValueOf } from "../../../utils/index.d.mts"; declare global { /** Options which customize the behavior of the filter */ diff --git a/src/foundry/clipper/clipper.d.mts b/src/foundry/clipper/clipper.d.mts index 03c429c0c..19aec3d1b 100644 --- a/src/foundry/clipper/clipper.d.mts +++ b/src/foundry/clipper/clipper.d.mts @@ -1,4 +1,4 @@ -import type { Brand } from "../../types/helperTypes.d.mts"; +import type { Brand } from "../../utils/index.d.mts"; declare global { namespace ClipperLib { diff --git a/src/foundry/common/abstract/backend.d.mts b/src/foundry/common/abstract/backend.d.mts index 5714c0a8d..6bb9f5158 100644 --- a/src/foundry/common/abstract/backend.d.mts +++ b/src/foundry/common/abstract/backend.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial, LoggingLevels } from "../../../utils/index.d.mts"; import type BaseUser from "../documents/user.d.mts"; import type Document from "./document.d.mts"; import type { @@ -8,7 +8,6 @@ import type { DatabaseOperation, DatabaseUpdateOperation, } from "./_types.d.mts"; -import type { LoggingLevels } from "../../../types/helperTypes.d.mts"; /** * An abstract base class extended on both the client and server which defines how Documents are retrieved, created, @@ -22,11 +21,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of retrieved Document instances or index objects */ - get( - documentClass: ConstructorOf, + get( + documentClass: T, operation: DatabaseGetOperation, user?: BaseUser, - ): Promise[]; + ): Promise>[]; /** * Retrieve Document instances using the specified operation parameters. @@ -35,11 +34,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of retrieved Document instances or index objects */ - protected abstract _getDocuments( - documentClass: ConstructorOf, + protected abstract _getDocuments( + documentClass: T, operation: DatabaseGetOperation, user?: BaseUser, - ): Promise; + ): Promise[]>; /** * Create new Documents using provided data and context. @@ -50,11 +49,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of created Document instances */ - create( - documentClass: ConstructorOf, - operation: DatabaseCreateOperation, + create( + documentClass: T, + operation: DatabaseCreateOperation>, user?: BaseUser, - ): Promise; + ): Promise[]>; /** * Create Document instances using provided data and operation parameters. @@ -63,11 +62,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of created Document instances */ - protected abstract _createDocuments( - documentClass: ConstructorOf, - operation: DatabaseCreateOperation, + protected abstract _createDocuments( + documentClass: T, + operation: DatabaseCreateOperation>, user?: BaseUser, - ): Promise; + ): Promise[]>; /** * Update Documents using provided data and context. @@ -78,11 +77,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of updated Document instances */ - update( - documentClass: ConstructorOf, - operation: DatabaseUpdateOperation, + update( + documentClass: T, + operation: DatabaseUpdateOperation>, user?: BaseUser, - ): Promise; + ): Promise[]>; /** * Update Document instances using provided data and operation parameters. @@ -91,11 +90,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns An array of updated Document instances */ - protected abstract _updateDocuments( - documentClass: ConstructorOf, - operation: DatabaseUpdateOperation, + protected abstract _updateDocuments( + documentClass: T, + operation: DatabaseUpdateOperation>, user: BaseUser, - ): Promise; + ): Promise[]>; /** * Delete Documents using provided ids and context. @@ -106,11 +105,11 @@ declare abstract class DatabaseBackend { * @param user - The requesting User * @returns The deleted Document instances */ - delete( - documentClass: ConstructorOf, + delete( + documentClass: T, operation: DatabaseDeleteOperation, user?: BaseUser, - ): Promise; + ): Promise[]>; /** * Delete Document instances using provided ids and operation parameters. @@ -118,11 +117,11 @@ declare abstract class DatabaseBackend { * @param operation - Parameters of the delete operation * @param user - The requesting User */ - protected abstract _deleteDocuments( - documentClass: ConstructorOf, + protected abstract _deleteDocuments( + documentClass: T, operation: DatabaseDeleteOperation, user: BaseUser, - ): Promise; + ): Promise[]>; /** * Get the parent Document (if any) associated with a request context. diff --git a/src/foundry/common/abstract/data.d.mts b/src/foundry/common/abstract/data.d.mts index fba76e421..91303aaa1 100644 --- a/src/foundry/common/abstract/data.d.mts +++ b/src/foundry/common/abstract/data.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, EmptyObject } from "../../../types/utils.d.mts"; +import type { AnyObject, EmptyObject } from "../../../utils/index.d.mts"; import type { DataField, SchemaField } from "../data/fields.d.mts"; import type { fields } from "../data/module.d.mts"; import type { DataModelValidationFailure } from "../data/validation-failure.d.mts"; diff --git a/src/foundry/common/abstract/document.d.mts b/src/foundry/common/abstract/document.d.mts index 6a427bdbb..b0148917d 100644 --- a/src/foundry/common/abstract/document.d.mts +++ b/src/foundry/common/abstract/document.d.mts @@ -5,32 +5,31 @@ import type { ConstructorData, } from "../../../types/documentConfiguration.d.mts"; import type { - DatabaseOperationsFor, GetKey, InterfaceToObject, MakeConform, MustConform, ToMethod, -} from "../../../types/helperTypes.mts"; -import type { AnyObject, DeepPartial, EmptyObject, InexactPartial, RemoveIndexSignatures, -} from "../../../types/utils.mts"; -import type { documents } from "../../client-esm/client.d.mts"; +} from "../../../utils/index.d.mts"; import type * as CONST from "../constants.mts"; import type { DataField, EmbeddedCollectionField, EmbeddedDocumentField } from "../data/fields.d.mts"; import type { fields } from "../data/module.mts"; import type { LogCompatibilityWarningOptions } from "../utils/logging.mts"; import type { + DatabaseAction, DatabaseCreateOperation, DatabaseDeleteOperation, DatabaseGetOperation, DatabaseUpdateOperation, + DocumentSocketRequest, } from "./_types.d.mts"; import type DataModel from "./data.mts"; +import type DocumentSocketResponse from "./socket.d.mts"; export default Document; @@ -321,8 +320,10 @@ declare abstract class Document< */ static createDocuments( this: T, - data: Array>, - operation?: InexactPartial, "data">> & { + data: Array>>, + operation?: InexactPartial< + Omit["metadata"]["name"], "create">, "data"> + > & { temporary?: Temporary; }, ): Promise[] | undefined>; @@ -364,8 +365,10 @@ declare abstract class Document< */ static updateDocuments( this: T, - updates?: Array>>, - operation?: InexactPartial["documentName"], "update">, "updates">>, + updates?: Array>>>, + operation?: InexactPartial< + Omit>["documentName"], "update">, "updates"> + >, ): Promise[]>; /** @@ -408,7 +411,9 @@ declare abstract class Document< static deleteDocuments( this: T, ids?: string[], - operation?: InexactPartial["documentName"], "delete">, "ids">>, + operation?: InexactPartial< + Omit>["documentName"], "delete">, "ids"> + >, ): Promise[]>; /** @@ -442,8 +447,10 @@ declare abstract class Document< */ static create( this: T, - data: Document.ConstructorDataFor | Document.ConstructorDataFor[], - operation?: InexactPartial, "data">> & { + data: Document.ConstructorDataFor> | Document.ConstructorDataFor>[], + operation?: InexactPartial< + Omit["metadata"]["name"], "create">, "data"> + > & { temporary?: Temporary; }, ): Promise | undefined>; @@ -462,7 +469,7 @@ declare abstract class Document< update( // TODO: Determine if this is Partial, DeepPartial, or InexactPartial. data?: Partial>, - operation?: InexactPartial, "updates">>, + operation?: InexactPartial, "updates">>, ): Promise; /** @@ -475,7 +482,7 @@ declare abstract class Document< * @remarks If no document has actually been deleted, the returned {@link Promise} resolves to `undefined`. */ delete( - operation?: InexactPartial, "ids">>, + operation?: InexactPartial, "ids">>, ): Promise; /** @@ -561,7 +568,7 @@ declare abstract class Document< >( embeddedName: EmbeddedName, data?: Array>>, - operation?: InexactPartial, "create">> & { + operation?: InexactPartial, "create">> & { temporary?: Temporary; }, ): Promise>> | undefined>; @@ -598,7 +605,7 @@ declare abstract class Document< >( embeddedName: EmbeddedName, ids: Array, - operation?: DatabaseOperationsFor, + operation?: Document.DatabaseOperationsFor, ): Promise>>>; /** @@ -697,8 +704,8 @@ declare abstract class Document< */ protected static _preCreateOperation( this: T, - documents: Document.ToConfiguredInstance[], - operation: DatabaseOperationsFor, + documents: Document.ToConfiguredInstance>[], + operation: Document.DatabaseOperationsFor["metadata"]["name"], "create">, user: foundry.documents.BaseUser, ): Promise; @@ -714,8 +721,8 @@ declare abstract class Document< */ protected static _onCreateOperation( this: T, - documents: InstanceType>[], - operation: DatabaseOperationsFor, + documents: InstanceType>>[], + operation: Document.DatabaseOperationsFor["metadata"]["name"], "create">, user: foundry.documents.BaseUser, ): Promise; @@ -763,8 +770,8 @@ declare abstract class Document< */ protected static _preUpdateOperation( this: T, - documents: InstanceType>[], - operation: DatabaseOperationsFor["documentName"], "update">, + documents: InstanceType>>[], + operation: Document.DatabaseOperationsFor>["documentName"], "update">, user: foundry.documents.BaseUser, ): Promise; @@ -780,8 +787,8 @@ declare abstract class Document< */ protected static _onUpdateOperation( this: T, - documents: InstanceType>[], - operation: DatabaseOperationsFor["documentName"], "update">, + documents: InstanceType>>[], + operation: Document.DatabaseOperationsFor>["documentName"], "update">, user: foundry.documents.BaseUser, ): Promise; @@ -823,8 +830,8 @@ declare abstract class Document< */ protected static _preDeleteOperation( this: T, - documents: Array>, - operation: DatabaseOperationsFor["documentName"], "delete">, + documents: Array>>, + operation: Document.DatabaseOperationsFor>["documentName"], "delete">, user: foundry.documents.BaseUser, ): Promise; @@ -840,8 +847,8 @@ declare abstract class Document< */ protected static _onDeleteOperation( this: T, - documents: Array>, - operation: DatabaseOperationsFor["documentName"], "delete">, + documents: Array>>, + operation: Document.DatabaseOperationsFor>["documentName"], "delete">, user: foundry.documents.BaseUser, ): Promise; @@ -894,7 +901,7 @@ declare abstract class Document< */ protected static _onCreateDocuments( this: T, - documents: Array>, + documents: Array>>, context: Document.ModificationContext, ): Promise; @@ -904,7 +911,7 @@ declare abstract class Document< */ protected static _onUpdateDocuments( this: T, - documents: Array>, + documents: Array>>, context: Document.ModificationContext, ): Promise; @@ -914,7 +921,7 @@ declare abstract class Document< */ protected static _onDeleteDocuments( this: T, - documents: Array>, + documents: Array>>, context: Document.ModificationContext, ): Promise; } @@ -1002,6 +1009,9 @@ declare namespace Document { ChildDocument extends Document.Internal.Instance.Any, > = ParentDocument extends Internal.ParentFor ? true : false; + type SocketRequest = DocumentSocketRequest; + type SocketResponse = DocumentSocketResponse; + // Documented at https://gist.github.com/LukeAbby/c7420b053d881db4a4d4496b95995c98 namespace Internal { type SimpleMetadata = ConfiguredMetadata[Name]; @@ -1371,6 +1381,21 @@ declare namespace Document { pack: null; } } + + /** + * This is a helper type that gets the right DatabaseOperation (including the + * proper options) for a particular Document type. + */ + type DatabaseOperationsFor< + Name extends Document.Type, + ConcreteOperation extends Operation, + > = DatabaseOperationMap[Name][ConcreteOperation]; + + type ConfiguredSheetClassFor = GetKey, "sheetClass">; + + type ConfiguredObjectClassFor = GetKey, "objectClass">; + + type ConfiguredLayerClassFor = GetKey, "layerClass">; } export type Operation = "create" | "update" | "delete"; diff --git a/src/foundry/common/abstract/embedded-collection-delta.d.mts b/src/foundry/common/abstract/embedded-collection-delta.d.mts index 51e543860..51e5308d0 100644 --- a/src/foundry/common/abstract/embedded-collection-delta.d.mts +++ b/src/foundry/common/abstract/embedded-collection-delta.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type Document from "./document.d.mts"; import type EmbeddedCollection from "./embedded-collection.d.mts"; diff --git a/src/foundry/common/abstract/embedded-collection.d.mts b/src/foundry/common/abstract/embedded-collection.d.mts index 42357f768..27d07c056 100644 --- a/src/foundry/common/abstract/embedded-collection.d.mts +++ b/src/foundry/common/abstract/embedded-collection.d.mts @@ -1,4 +1,4 @@ -import type { ConstructorOf, InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type _Collection from "../utils/collection.d.mts"; import type { DatabaseAction, DatabaseOperation } from "./_types.d.mts"; import type Document from "./document.d.mts"; @@ -37,7 +37,7 @@ declare class EmbeddedCollection< /** * The Document implementation used to construct instances within this collection */ - readonly documentClass: ConstructorOf; + readonly documentClass: abstract new (arg0: never, ...args: never) => ContainedDocument; /** * The name of this collection in the parent Document. diff --git a/src/foundry/common/abstract/socket.d.mts b/src/foundry/common/abstract/socket.d.mts index 0b08a105b..bcdefc0c5 100644 --- a/src/foundry/common/abstract/socket.d.mts +++ b/src/foundry/common/abstract/socket.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.d.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type { DatabaseAction, DatabaseOperation, DocumentSocketRequest } from "./_types.d.mts"; /** diff --git a/src/foundry/common/abstract/type-data.d.mts b/src/foundry/common/abstract/type-data.d.mts index 8f3f19a28..bace199f9 100644 --- a/src/foundry/common/abstract/type-data.d.mts +++ b/src/foundry/common/abstract/type-data.d.mts @@ -1,5 +1,5 @@ -import type { MustConform } from "../../../types/helperTypes.d.mts"; import type { + MustConform, AnyObject, EmptyObject, DeepPartial, @@ -7,7 +7,7 @@ import type { Merge, RemoveIndexSignatures, SimpleMerge, -} from "../../../types/utils.d.mts"; +} from "../../../utils/index.d.mts"; import type { SchemaField } from "../data/fields.d.mts"; import type BaseUser from "../documents/user.d.mts"; import type { DataModel } from "./data.d.mts"; diff --git a/src/foundry/common/config.d.mts b/src/foundry/common/config.d.mts index 1b736d43c..168e6a743 100644 --- a/src/foundry/common/config.d.mts +++ b/src/foundry/common/config.d.mts @@ -1,7 +1,7 @@ import type { DataModel } from "./abstract/data.d.mts"; import type * as fields from "./data/fields.d.mts"; import type { SOFTWARE_UPDATE_CHANNELS } from "./constants.d.mts"; -import type { AnyObject } from "../../types/utils.d.mts"; +import type { AnyObject } from "../../utils/index.d.mts"; declare namespace ApplicationConfiguration { interface Schema extends DataSchema { diff --git a/src/foundry/common/constants.d.mts b/src/foundry/common/constants.d.mts index 7be699b09..aa10b1719 100644 --- a/src/foundry/common/constants.d.mts +++ b/src/foundry/common/constants.d.mts @@ -1,4 +1,4 @@ -import type { ValueOf } from "../../types/utils.d.mts"; +import type { ValueOf } from "../../utils/index.d.mts"; /** * The shortened software name diff --git a/src/foundry/common/data/data.d.mts b/src/foundry/common/data/data.d.mts index 02ad6d43e..f4c0e7bfd 100644 --- a/src/foundry/common/data/data.d.mts +++ b/src/foundry/common/data/data.d.mts @@ -2,8 +2,7 @@ import type { DatabaseBackend } from "../abstract/module.d.mts"; import type { DataModel } from "../abstract/data.d.mts"; import type { fields } from "./module.d.mts"; import type * as documents from "../documents/_module.d.mts"; -import type { AnyObject, EmptyObject, ValueOf } from "../../../types/utils.d.mts"; -import type { ToMethod } from "../../../types/helperTypes.d.mts"; +import type { AnyObject, EmptyObject, ToMethod, ValueOf } from "../../../utils/index.d.mts" // TODO: Implement all of the necessary options diff --git a/src/foundry/common/data/fields.d.mts b/src/foundry/common/data/fields.d.mts index a05b9493e..f0e26b006 100644 --- a/src/foundry/common/data/fields.d.mts +++ b/src/foundry/common/data/fields.d.mts @@ -7,7 +7,8 @@ import type { NullishProps, InexactPartial, AnyConstructor, -} from "../../../types/utils.d.mts"; + ToMethod, +} from "../../../utils/index.d.mts"; import type { DataModel } from "../abstract/data.mts"; import type Document from "../abstract/document.mts"; import type { EmbeddedCollection, EmbeddedCollectionDelta, TypeDataModel } from "../abstract/module.d.mts"; @@ -23,7 +24,6 @@ import type { SelectInputConfig, TextAreaInputConfig, } from "../../client-esm/applications/forms/fields.d.mts"; -import type { ToMethod } from "../../../types/helperTypes.d.mts"; declare global { /** diff --git a/src/foundry/common/documents/active-effect.d.mts b/src/foundry/common/documents/active-effect.d.mts index 27a084e40..90210b435 100644 --- a/src/foundry/common/documents/active-effect.d.mts +++ b/src/foundry/common/documents/active-effect.d.mts @@ -1,5 +1,4 @@ -import type { InterfaceToObject } from "../../../types/helperTypes.d.mts"; -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { InterfaceToObject, AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/actor-delta.d.mts b/src/foundry/common/documents/actor-delta.d.mts index 1b6830cd3..06a374381 100644 --- a/src/foundry/common/documents/actor-delta.d.mts +++ b/src/foundry/common/documents/actor-delta.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type { fields } from "../data/module.d.mts"; import type { CONST, documents } from "../../client-esm/client.d.mts"; diff --git a/src/foundry/common/documents/actor.d.mts b/src/foundry/common/documents/actor.d.mts index 11f4e17e6..e434bbd3b 100644 --- a/src/foundry/common/documents/actor.d.mts +++ b/src/foundry/common/documents/actor.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type { PrototypeToken } from "../data/data.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/ambient-light.d.mts b/src/foundry/common/documents/ambient-light.d.mts index 12792b907..fe978a0be 100644 --- a/src/foundry/common/documents/ambient-light.d.mts +++ b/src/foundry/common/documents/ambient-light.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type { LightData } from "../data/data.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/ambient-sound.d.mts b/src/foundry/common/documents/ambient-sound.d.mts index c27b76ff3..7158a119d 100644 --- a/src/foundry/common/documents/ambient-sound.d.mts +++ b/src/foundry/common/documents/ambient-sound.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/card.d.mts b/src/foundry/common/documents/card.d.mts index fbfeec9dd..f10ea0161 100644 --- a/src/foundry/common/documents/card.d.mts +++ b/src/foundry/common/documents/card.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/cards.d.mts b/src/foundry/common/documents/cards.d.mts index 8a7a03ea7..cd42cd71a 100644 --- a/src/foundry/common/documents/cards.d.mts +++ b/src/foundry/common/documents/cards.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/chat-message.d.mts b/src/foundry/common/documents/chat-message.d.mts index 7418a7169..7afab1550 100644 --- a/src/foundry/common/documents/chat-message.d.mts +++ b/src/foundry/common/documents/chat-message.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/drawing.d.mts b/src/foundry/common/documents/drawing.d.mts index 1381bd9c3..7e73b295b 100644 --- a/src/foundry/common/documents/drawing.d.mts +++ b/src/foundry/common/documents/drawing.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/item.d.mts b/src/foundry/common/documents/item.d.mts index 7a0c42761..9f281a6b2 100644 --- a/src/foundry/common/documents/item.d.mts +++ b/src/foundry/common/documents/item.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/journal-entry.d.mts b/src/foundry/common/documents/journal-entry.d.mts index bf9bada10..407926e51 100644 --- a/src/foundry/common/documents/journal-entry.d.mts +++ b/src/foundry/common/documents/journal-entry.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/macro.d.mts b/src/foundry/common/documents/macro.d.mts index 63945a7ce..0f6d1eef8 100644 --- a/src/foundry/common/documents/macro.d.mts +++ b/src/foundry/common/documents/macro.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.d.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/measured-template.d.mts b/src/foundry/common/documents/measured-template.d.mts index c9d6015b0..be339358e 100644 --- a/src/foundry/common/documents/measured-template.d.mts +++ b/src/foundry/common/documents/measured-template.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/note.d.mts b/src/foundry/common/documents/note.d.mts index 584088c8c..7758588aa 100644 --- a/src/foundry/common/documents/note.d.mts +++ b/src/foundry/common/documents/note.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type { TextureData } from "../data/data.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/playlist-sound.d.mts b/src/foundry/common/documents/playlist-sound.d.mts index c24b23c78..674e54c51 100644 --- a/src/foundry/common/documents/playlist-sound.d.mts +++ b/src/foundry/common/documents/playlist-sound.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/playlist.d.mts b/src/foundry/common/documents/playlist.d.mts index cb4775c9d..0056acbb9 100644 --- a/src/foundry/common/documents/playlist.d.mts +++ b/src/foundry/common/documents/playlist.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/roll-table.d.mts b/src/foundry/common/documents/roll-table.d.mts index 26fe0ebc7..9f0160cb1 100644 --- a/src/foundry/common/documents/roll-table.d.mts +++ b/src/foundry/common/documents/roll-table.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as fields from "../data/fields.d.mts"; import type * as documents from "./_module.mts"; diff --git a/src/foundry/common/documents/scene.d.mts b/src/foundry/common/documents/scene.d.mts index d4b0bf707..c16dc0ef7 100644 --- a/src/foundry/common/documents/scene.d.mts +++ b/src/foundry/common/documents/scene.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type { TextureData } from "../data/data.mts"; diff --git a/src/foundry/common/documents/table-result.d.mts b/src/foundry/common/documents/table-result.d.mts index fee53cc24..5197d9118 100644 --- a/src/foundry/common/documents/table-result.d.mts +++ b/src/foundry/common/documents/table-result.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/tile.d.mts b/src/foundry/common/documents/tile.d.mts index 0219278e7..601e09dd4 100644 --- a/src/foundry/common/documents/tile.d.mts +++ b/src/foundry/common/documents/tile.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type { TextureData } from "../data/data.mts"; diff --git a/src/foundry/common/documents/token.d.mts b/src/foundry/common/documents/token.d.mts index 527448f38..9253773ba 100644 --- a/src/foundry/common/documents/token.d.mts +++ b/src/foundry/common/documents/token.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type { DataModel } from "../abstract/data.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; diff --git a/src/foundry/common/documents/user.d.mts b/src/foundry/common/documents/user.d.mts index 1165bec7a..0ead5a458 100644 --- a/src/foundry/common/documents/user.d.mts +++ b/src/foundry/common/documents/user.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/documents/wall.d.mts b/src/foundry/common/documents/wall.d.mts index 83c2ccaeb..e73fb8d6b 100644 --- a/src/foundry/common/documents/wall.d.mts +++ b/src/foundry/common/documents/wall.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../types/utils.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.mts"; import type * as CONST from "../constants.mts"; import type * as fields from "../data/fields.d.mts"; diff --git a/src/foundry/common/grid/base.d.mts b/src/foundry/common/grid/base.d.mts index 8d8878990..78ea2322d 100644 --- a/src/foundry/common/grid/base.d.mts +++ b/src/foundry/common/grid/base.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; /** * The base grid class. diff --git a/src/foundry/common/grid/gridless.d.mts b/src/foundry/common/grid/gridless.d.mts index 982344622..86929686c 100644 --- a/src/foundry/common/grid/gridless.d.mts +++ b/src/foundry/common/grid/gridless.d.mts @@ -1,6 +1,6 @@ import type BaseGrid from "./base.d.mts"; -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare class Gridless extends BaseGrid { override type: number; diff --git a/src/foundry/common/grid/hexagonal.d.mts b/src/foundry/common/grid/hexagonal.d.mts index 409359018..bb98219b8 100644 --- a/src/foundry/common/grid/hexagonal.d.mts +++ b/src/foundry/common/grid/hexagonal.d.mts @@ -1,6 +1,6 @@ import type BaseGrid from "./base.d.mts"; -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare class HexagonalGrid extends BaseGrid { /** diff --git a/src/foundry/common/grid/square.d.mts b/src/foundry/common/grid/square.d.mts index 0cb6cd6e8..a1c1a055d 100644 --- a/src/foundry/common/grid/square.d.mts +++ b/src/foundry/common/grid/square.d.mts @@ -1,6 +1,6 @@ import type BaseGrid from "./base.d.mts"; -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; declare class SquareGrid extends BaseGrid { /** diff --git a/src/foundry/common/packages/base-package.d.mts b/src/foundry/common/packages/base-package.d.mts index 09430f3e4..623a69d62 100644 --- a/src/foundry/common/packages/base-package.d.mts +++ b/src/foundry/common/packages/base-package.d.mts @@ -1,5 +1,4 @@ -import type { GetKey } from "../../../types/helperTypes.d.mts"; -import type { AnyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { GetKey, AnyObject, InexactPartial } from "../../../utils/index.d.mts"; // eslint-disable-next-line import/no-named-as-default import type DataModel from "../abstract/data.d.mts"; import type { ReleaseData } from "../config.d.mts"; diff --git a/src/foundry/common/packages/base-world.d.mts b/src/foundry/common/packages/base-world.d.mts index a93520c64..f92d4c391 100644 --- a/src/foundry/common/packages/base-world.d.mts +++ b/src/foundry/common/packages/base-world.d.mts @@ -1,6 +1,6 @@ import type BasePackage from "./base-package.d.mts"; import type * as fields from "../data/fields.d.mts"; -import type { AnyObject, InexactPartial, Merge } from "../../../types/utils.d.mts"; +import type { AnyObject, InexactPartial, Merge } from "../../../utils/index.d.mts"; import type { ReleaseData } from "../config.d.mts"; type BaseWorldSchema = Merge< diff --git a/src/foundry/common/packages/sub-types.d.mts b/src/foundry/common/packages/sub-types.d.mts index 71f3b9200..1b9523921 100644 --- a/src/foundry/common/packages/sub-types.d.mts +++ b/src/foundry/common/packages/sub-types.d.mts @@ -1,4 +1,4 @@ -import type { AnyObject, Merge } from "../../../types/utils.d.mts"; +import type { AnyObject, Merge } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.d.mts"; import type { DataField, ObjectField } from "../data/fields.d.mts"; diff --git a/src/foundry/common/primitives/array.d.mts b/src/foundry/common/primitives/array.d.mts index cfdc3469b..fc2d9ddbb 100644 --- a/src/foundry/common/primitives/array.d.mts +++ b/src/foundry/common/primitives/array.d.mts @@ -1,4 +1,4 @@ -import type { OverlapsWith } from "../../../types/helperTypes.d.mts"; +import type { OverlapsWith } from "../../../utils/index.d.mts"; declare global { namespace Array { diff --git a/src/foundry/common/primitives/string.d.mts b/src/foundry/common/primitives/string.d.mts index bee75bd3d..3ae8d5a0b 100644 --- a/src/foundry/common/primitives/string.d.mts +++ b/src/foundry/common/primitives/string.d.mts @@ -1,4 +1,4 @@ -import type { Titlecase } from "../../../types/utils.d.mts"; +import type { Titlecase } from "../../../utils/index.d.mts"; declare global { interface String { diff --git a/src/foundry/common/prosemirror/dirty-plugin.d.mts b/src/foundry/common/prosemirror/dirty-plugin.d.mts index 79dd26328..ae2236e12 100644 --- a/src/foundry/common/prosemirror/dirty-plugin.d.mts +++ b/src/foundry/common/prosemirror/dirty-plugin.d.mts @@ -1,7 +1,7 @@ import type { Schema } from "prosemirror-model"; import type { Plugin } from "prosemirror-state"; import type ProseMirrorPlugin from "./plugin.d.mts"; -import type { EmptyObject } from "../../../types/utils.d.mts"; +import type { EmptyObject } from "../../../utils/index.d.mts"; export default ProseMirrorDirtyPlugin; diff --git a/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts b/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts index b76f59d4c..29a4e1ae9 100644 --- a/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts +++ b/src/foundry/common/prosemirror/highlight-matches-plugin.d.mts @@ -3,7 +3,7 @@ import type ProseMirrorPlugin from "./plugin.d.mts"; import type { ProseMirrorMenu } from "./menu.d.mts"; import { EditorState, Plugin } from "prosemirror-state"; import { EditorView } from "prosemirror-view"; -import type { EmptyObject, InexactPartial } from "../../../types/utils.d.mts"; +import type { EmptyObject, InexactPartial } from "../../../utils/index.d.mts"; declare namespace ProseMirrorHighlightMatchesPlugin { /** diff --git a/src/foundry/common/prosemirror/image-plugin.d.mts b/src/foundry/common/prosemirror/image-plugin.d.mts index 8dd462247..b3ec2af12 100644 --- a/src/foundry/common/prosemirror/image-plugin.d.mts +++ b/src/foundry/common/prosemirror/image-plugin.d.mts @@ -2,7 +2,7 @@ import type { Schema, Slice } from "prosemirror-model"; import type { Plugin } from "prosemirror-state"; import type { EditorView } from "prosemirror-view"; import type ProseMirrorPlugin from "./plugin.d.mts"; -import type { EmptyObject } from "../../../types/utils.d.mts"; +import type { EmptyObject } from "../../../utils/index.d.mts"; export default ProseMirrorImagePlugin; /** diff --git a/src/foundry/common/prosemirror/paste-transformer.d.mts b/src/foundry/common/prosemirror/paste-transformer.d.mts index 3d4de1d26..e63f32a4e 100644 --- a/src/foundry/common/prosemirror/paste-transformer.d.mts +++ b/src/foundry/common/prosemirror/paste-transformer.d.mts @@ -2,7 +2,7 @@ import type { Schema, Slice } from "prosemirror-model"; import type ProseMirrorPlugin from "./plugin.d.mts"; import type { Plugin } from "prosemirror-state"; import type { EditorView } from "prosemirror-view"; -import type { EmptyObject } from "../../../types/utils.d.mts"; +import type { EmptyObject } from "../../../utils/index.d.mts"; export default ProseMirrorPasteTransformer; diff --git a/src/foundry/common/prosemirror/plugin.d.mts b/src/foundry/common/prosemirror/plugin.d.mts index 4e67135c6..a0d7a7b9b 100644 --- a/src/foundry/common/prosemirror/plugin.d.mts +++ b/src/foundry/common/prosemirror/plugin.d.mts @@ -1,6 +1,6 @@ import type { Schema } from "prosemirror-model"; import type { Plugin } from "prosemirror-state"; -import type { AnyObject } from "../../../types/utils.d.mts"; +import type { AnyObject } from "../../../utils/index.d.mts"; export default ProseMirrorPlugin; declare abstract class ProseMirrorPlugin { diff --git a/src/foundry/common/prosemirror/schema/index.d.mts b/src/foundry/common/prosemirror/schema/index.d.mts index 6537dda25..89a2b2c9c 100644 --- a/src/foundry/common/prosemirror/schema/index.d.mts +++ b/src/foundry/common/prosemirror/schema/index.d.mts @@ -9,4 +9,4 @@ import "./other.d.mts"; import "./schema-definition.d.mts"; import "./secret-node.d.mts"; import "./tables.d.mts"; -import "./utils.d.mts"; +import "../../../../utils/index.d.mts"; diff --git a/src/foundry/common/types.d.mts b/src/foundry/common/types.d.mts index 62cce53d1..cbd62d5ed 100644 --- a/src/foundry/common/types.d.mts +++ b/src/foundry/common/types.d.mts @@ -1,4 +1,4 @@ -import type { AnyConcreteConstructor, AnyConstructor, AnyFunction } from "../../types/utils.d.mts"; +import type { AnyConcreteConstructor, AnyConstructor, AnyFunction } from "../../utils/index.d.mts"; import type { Document } from "./abstract/module.d.mts"; // After seeing that none of these types add anything or are even exported a diff --git a/src/foundry/common/utils/event-emitter.d.mts b/src/foundry/common/utils/event-emitter.d.mts index de60a1e18..7435aa285 100644 --- a/src/foundry/common/utils/event-emitter.d.mts +++ b/src/foundry/common/utils/event-emitter.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial, Mixin } from "../../../types/utils.d.mts"; +import type { InexactPartial, Mixin } from "../../../utils/index.d.mts"; /** * A mixin class which implements the behavior of EventTarget. diff --git a/src/foundry/common/utils/helpers.d.mts b/src/foundry/common/utils/helpers.d.mts index 8f96d01bf..67f5d7b15 100644 --- a/src/foundry/common/utils/helpers.d.mts +++ b/src/foundry/common/utils/helpers.d.mts @@ -1,4 +1,4 @@ -import type { AnyConstructor, AnyFunction, DeepPartial, InexactPartial } from "../../../types/utils.d.mts"; +import type { AnyConstructor, AnyFunction, DeepPartial, InexactPartial } from "../../../utils/index.d.mts"; import type Document from "../abstract/document.d.mts"; /** diff --git a/src/foundry/common/utils/string-tree.d.mts b/src/foundry/common/utils/string-tree.d.mts index f113ec0ee..6d23baf1e 100644 --- a/src/foundry/common/utils/string-tree.d.mts +++ b/src/foundry/common/utils/string-tree.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; /** * A data structure representing a tree of string nodes with arbitrary object leaves. diff --git a/src/foundry/common/utils/word-tree.d.mts b/src/foundry/common/utils/word-tree.d.mts index 011dcf0d3..02f2959b0 100644 --- a/src/foundry/common/utils/word-tree.d.mts +++ b/src/foundry/common/utils/word-tree.d.mts @@ -1,4 +1,4 @@ -import type { InexactPartial } from "../../../types/utils.d.mts"; +import type { InexactPartial } from "../../../utils/index.d.mts"; import type StringTree from "./string-tree.d.mts"; /** diff --git a/src/types/augments/tinyMCE.d.mts b/src/types/augments/tinyMCE.d.mts index 8c3ec16bd..772735160 100644 --- a/src/types/augments/tinyMCE.d.mts +++ b/src/types/augments/tinyMCE.d.mts @@ -1,6 +1,6 @@ import _tinymce from "tinymce"; import type * as _tinymceTypes from "tinymce"; -import type { AnyObject } from "../utils.d.mts"; +import type { AnyObject } from "../../utils/index.d.mts"; declare global { let tinyMCE: typeof _tinymce; diff --git a/src/types/config.d.mts b/src/types/config.d.mts index 069974ab9..6363aa920 100644 --- a/src/types/config.d.mts +++ b/src/types/config.d.mts @@ -1,7 +1,6 @@ import type Document from "../foundry/common/abstract/document.d.mts"; import type { fields } from "../foundry/common/data/module.d.mts"; -import type { InterfaceToObject, MaybeEmpty, MustConform } from "./helperTypes.d.mts"; -import type { DeepPartial } from "./utils.d.mts"; +import type { InterfaceToObject, MaybeEmpty, MustConform, DeepPartial } from "../utils/index.d.mts"; declare global { /** diff --git a/src/types/documentConfiguration.d.mts b/src/types/documentConfiguration.d.mts index 65a9628c1..578901d10 100644 --- a/src/types/documentConfiguration.d.mts +++ b/src/types/documentConfiguration.d.mts @@ -12,8 +12,7 @@ import type BaseTableResult from "../foundry/common/documents/table-result.d.mts import type BaseToken from "../foundry/common/documents/token.d.mts"; import type BaseUser from "../foundry/common/documents/user.d.mts"; import type BaseWall from "../foundry/common/documents/wall.d.mts"; -import type { ConformRecord, InterfaceToObject, MakeConform, MustConform } from "./helperTypes.d.mts"; -import type { Merge } from "./utils.d.mts"; +import type { ConformRecord, InterfaceToObject, MakeConform, MustConform, Merge } from "../utils/index.d.mts"; type DocumentConform = MakeConform; diff --git a/src/types/helperTypes.d.mts b/src/types/helperTypes.d.mts index 96e9763c0..4e5737452 100644 --- a/src/types/helperTypes.d.mts +++ b/src/types/helperTypes.d.mts @@ -1,268 +1,137 @@ -import type { DatabaseOperationMap, Operation } from "../foundry/common/abstract/document.d.mts"; +import type { Operation } from "../foundry/common/abstract/document.d.mts"; import type Document from "../foundry/common/abstract/document.d.mts"; -import type { ConfiguredDocuments } from "./documentConfiguration.d.mts"; -import type { AnyFunction, AnyObject, EmptyObject } from "./utils.d.mts"; +import type * as utils from "../utils/index.d.mts"; +/** + * @deprecated No replacement. + */ export type ModuleRequiredOrOptional = Name extends keyof RequiredModules ? never : undefined; -export type ConfiguredModuleData = Name extends keyof ModuleConfig - ? ModuleConfig[Name] - : EmptyObject; - -export type ConfiguredModule = - ModuleRequiredOrOptional extends never - ? ConfiguredModuleData - : - | ({ active: true } & ConfiguredModuleData) - // flawed, can't use `key in module` this way, but omitting the Partial Record type kills nullish - // collocating, which is probably the better DX. - | ({ active: false } & Record, undefined>); - -/** Keys of functions of console.log / globalThis.logger */ -export type LoggingLevels = "debug" | "log" | "info" | "warn" | "error"; - -/** - * `GetKey` accesses a property while intentionally ignoring index signatures. This means `GetKey, "foo">` will return `never`. - */ -// Note(LukeAbby): There are two tricky cases: -// - `T = {}` would regularly always return `unknown`. The fix here adding a single dummy property `{ _?: any } & T`. -// - `T = never` would regularly always return `unknown`. The fix here is adding `_GetKey` which makes the type distributive and therefore `never` as an input becomes `never` in the output. -export type GetKey = _GetKey<{ _?: any } & T, K, D>; - -type _GetKey = T extends { readonly [_ in K]?: infer V } ? V : D; - -/** - * `Partial` is usually the wrong type. - * In order to make it easier to audit unintentional uses of `Partial` this type is provided. - * - * ### Picking the right helper type - * - Favor `NullishProps` whenever it is valid. Allowing both `null` and - * `undefined` is convenient for the end user and it is very common that - * wherever `undefined` is valid so is `null`. For some examples it is valid - * for `options.prop ??= "default"`, `options.prop ||= "default"`, - * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. - * - Use `IntentionalPartial` when an explicit `undefined` is problematic but - * leaving off the property entirely is fine. This primarily occurs when - * patterns like `options = { ...defaultOptions, ...options }`, - * `Object.assign({}, defaultOptions, options)`, - * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. - * - * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} - * also expands the object. So once `ExpandsTo` exists you should also use - * that helper type. - * - * What these patterns have in common is that if `options` looks like - * `{ prop: undefined }` that will override whatever is in `defaultOptions` - * and may cause issues. Note that even if you see one of these patterns you - * also need to ensure that `undefined` would cause issues down the road - * before using `IntentionalPartial` as it could be an intended way of - * resetting a property. - * - Use `InexactPartial` when `null` is problematic but `undefined` is not. - * The most common time this shows up is with the pattern - * `exampleFunction({ prop = "foo" } = {}) { ... }`. - */ -export type IntentionalPartial = Partial; - -/** - * This type is used to make a constraint where `T` must be statically known to overlap with `U`. - * - * @example - * ```ts - * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.` - * function takesNumber(input: OverlapsWith): void { - * // This function body is an example of a method this might be useful for. - * // If the input isn't an number it simply returns in this case. - * if (typeof input !== "number") { - * return; - * } - * - * // Assumes, unchecked, that `element` is a number. - * // This means an input like `number[] | string[]` would be unsound as it could be a string. - * element + 1; - * } - * - * takesNumber(1); // Ok! - * takesNumber("foo"); // Error, statically known to never an number and so presumed to be a mistake. - * takesNumber(Math.random() > 0.5 ? 1 : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful. - * ``` - */ -export type OverlapsWith = [Extract, any] extends [U, Extract] ? T : U extends T ? T : U; - -/** - * Used to build a constraint where `T` to overlap with `Item[]` but disallows unrelated arrays. - * This is safer than what `OverlapsWith` provides as it ensures that if the type is an array it is an array of `Item`. - * Assumes readonly arrays are permitted. - * - * Note that `never[]` and `any[]` are still accepted due to the unsoundness of those types. - * - * @example - * ```ts - * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.` - * function takesNumericArray(input: ArrayOverlaps): void { - * // This function body is an example of a method this might be useful for. - * // If the input isn't an array it simply returns in this case. - * if (!Array.isArray(input)) { - * return; - * } - * - * for (const element of input) { - * // Assumes, unchecked, that `element` is a number. - * // This means an input like `number[] | string[]` would be unsound as it could be a string. - * element + 1; - * } - * } - * - * takesNumericArray([1, 2, 3]); // Ok! - * takesNumericArray("foo"); // Error, statically known to never an array and so presumed to be a mistake. - * takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful. - * takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : ["foo", "bar"]); // Error, at runtime it could be an array of the wrong type and that isn't handled. Notably this would succeed with `OverlapsWith`. - * ``` - */ -export type ArrayOverlaps = - Extract extends readonly Item[] ? OverlapsWith : readonly Item[]; - -/** - * Use this whenever a type is given that should match some constraint but is - * not guaranteed to. For example when additional properties can be declaration - * merged into an interface. When the type does not conform then `ConformTo` is - * used instead. - * - * See `MustConform` for a version that throws a compilation error when the type - * cannot be statically known to conform. - */ -export type MakeConform = [T] extends [ConformTo] ? T : ConformTo; - -/** - * This is useful when you want to ensure that a type conforms to a certain - * constraint. If it is not guaranteed to conform then a compilation error is - * thrown. This makes it too conservative in some cases. - */ -export type MustConform = T; - -/** - * This allows you to treat all interfaces as a plain object. But beware, if the - * interface represents a function, array, or constructor then these will be - * stripped from the interface. - * - * This is generally intended for cases where an interface is given in order to - * be declaration merged and then must be assigned to a plain object type. - * - * The constraint `T extends object` is used because `object` includes functions - * and arrays etc. This is crucial to allow interfaces to be given to this type. - */ -export type InterfaceToObject = { - // Mapped types are no-ops on most types (even primitives like string) but for - // functions, classes, and arrays they convert them to "proper" objects by - // stripping constructors/function signatures. One side effect is a type like - // `() => number` will result in `{}`. - [K in keyof T]: T[K]; -}; - -/** - * This is a helper type that allows you to ensure that a record conforms to a - * certain shape. This is useful when you want to ensure that a record has all - * keys of a certain type. - * - * When a value does not conform it is replaced with `never` to indicate that - * there is an issue. - */ -export type ConformRecord = { - [K in keyof T]: T[K] extends V ? T[K] : never; -}; - -/** - * This is a helper type that gets the right DatabaseOperation (including the - * proper options) for a particular Document type. +/** + * @deprecated without replacement, use `ConfiguredModule` instead. + */ +export type ConfiguredModuleData = utils.ConfiguredModuleData; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type ConfiguredModule = utils.ConfiguredModule; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type LoggingLevels = utils.LoggingLevels; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type GetKey = utils.GetKey; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type IntentionalPartial = utils.IntentionalPartial; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type OverlapsWith = utils.OverlapsWith; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type ArrayOverlaps = utils.ArrayOverlaps; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type MakeConform = utils.MakeConform; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type MustConform = utils.MustConform; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type InterfaceToObject = utils.InterfaceToObject; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type ConformRecord = utils.ConformRecord; + +/** + * @deprecated {@link Document.DatabaseOperationsFor | `Document.DatabaseOperationsFor`}. */ export type DatabaseOperationsFor< Name extends Document.Type, ConcreteOperation extends Operation, -> = DatabaseOperationMap[Name][ConcreteOperation]; - -/** - * Converts a regular function type into a function derived from a method. - * - * Methods have a special exception in TypeScript that allows unsound subtyping - * that unfortunately has been deeply engrained into not just JavaScript codebases - * but the core APIs of JavaScript itself in the DOM. - * - * It might seem odd to want to opt-in to this unsoundness but it's unfortunately - * useful in several cases, such as when you have a property like - * `prop: ((arg: Options) => number) | undefined` and you want to meet the expectations - * from other similar methods. - * - * @example - * ```typescript - * declare class ExampleBaseClass { - * // This demonstrates a typical example of where the allowed unsoundness is useful. - * methodOne(arg: { x: string }): number; - * - * // This helps demonstrates an example that may be easier to recognize as unsound. - * methodTwo(arg: string): number; - * - * functionProperty: (arg: string) => number; - * methodLikeProperty: ToMethod<(arg: string) => number>; - * } - * - * // TypeScript allows this without any errors. - * declare class MethodSubclassing extends ExampleBaseClass { - * // It's a very common thing for subclasses to ask for extra arguments. - * methodOne(arg: { x: string; y: string }): number; - * - * // Only taking `"foo" | "bar"` should seem pretty unsound. - * // The above is actually equally unsound but it's less obvious to many people. - * methodTwo(arg: "foo" | "bar"): number; - * } - * - * const exampleMethodSubclass: ExampleBaseClass = new MethodSubclassing(); - * - * // This is allowed, however at runtime `MethodSubclassing#methodOne` could - * // will almost certainly error as it has the required property `y`. - * // The reason why there's no errors is an intentional unsoundness in TypeScript. - * exampleMethodSubclass.methodOne({ x: "foo" }); - * - * // Similarly this is allowed. - * // Both methods show taking arguments that are 'subtypes' of the original. - * // In the case of functions this is unsound as demonstrated because in both - * // examples you're substituting a function that has to be able to be called - * // with a wide variety of arguments with one that will error for many of them. - * exampleMethodSubclass.methodTwo("lorem"); - * - * declare class PropertySubclassing extends ExampleBaseClass { - * // This errors right here. This preventative error is because of the prior - * // explained unsoundness. It errors here because there's really only 3 - * // places to error at compile time to prevent a runtime error: - * // 1. At the call site when a subclass is used unsoundly. Unfortunately - * // at this point it's too late to know for certain if it's a subclass - * // or not. For example there could be a guarded condition to avoid - * // subclasses that TypeScript can't possibly track. - * // 2. When trying to assign `PropertySubclassing` to `ExampleBaseClass`. - * // This would be a feasible alternative but would likely come as a - * // surprise as the subclass could have been used for quite a while - * // before trying to be assigned to its superclass. - * // 3. Error at the definition. This is where TypeScript has chosen to error. - * // The error is unfortunately not the most intuitive but it is correct. - * functionProperty: (arg: "foo" | "bar") => number; - * } - * - * declare class MethodLikeSubclassing { - * // This is unsound but by using the `ToMethod` in the parent class it's allowed. - * methodLikeProperty: (arg: "foo" | "bar") => number; - * } - * ``` - * - * The TypeScript FAQ explains this in a way that may either be intuitive and - * explain all lingering questions or be confusing and muddle the waters. - * It's also worth mentioning that it claims all function parameters work this way, - * this behavior is disabled for functions in most codebases (including this one) - * because of the `strictFunctionTypes` compiler flag, implicit under `strict: true`. - * See: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant - */ -export type ToMethod = { - method(...args: Parameters): ReturnType; -}["method"]; - -// Deprecated types, to be removed in the first stable v12 release or at the latest v13. +> = Document.DatabaseOperationsFor; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type ToMethod = utils.ToMethod; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type Brand = utils.Brand; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type PrettifyType = utils.PrettifyType; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type PrettifyTypeDeep = utils.PrettifyTypeDeep; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type UnionToIntersection = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void + ? I + : never; + +/** + * @deprecated {@link Document.ConfiguredSheetClassFor | `Document.ConfiguredSheetClassFor`} + */ +export type ConfiguredSheetClass = Document.ConfiguredSheetClassFor + +/** + * @deprecated {@link Document.ConfiguredObjectClassFor | `Document.ConfiguredObjectClassFor`} + */ +export type ObjectClass = Document.ConfiguredObjectClassFor; + +/** + * @deprecated {@link Document.ConfiguredLayerClassFor | `Document.ConfiguredLayerClassFor`} + */ +export type LayerClass = Document.ConfiguredLayerClassFor; + +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type MaybeEmpty = + | T + | { + [K in keyof T]?: never; + }; + +/** + * The following uses `extends object` instead of `AnyObject` to allow `O = typeof SomeClass` + */ +export type PropertiesOfType = { + [K in keyof O]: [O[K], T] extends [T, O[K]] ? K : never; +}[keyof O]; + +/** + * @deprecated {@link Folder.DocumentType | `Folder.DocumentType`}. + */ +export type FolderDocumentTypes = Folder.DocumentType; /** * @deprecated {@link Document.SystemType | `Document.SystemType`}. @@ -301,42 +170,6 @@ export type DocumentType = Document.Type; */ export type PlaceableDocumentType = Document.PlaceableType; -export type ConfiguredSheetClass = GetKey< - GetKey, - "sheetClass", - T ->; - -export type ObjectClass = GetKey< - GetKey, - "objectClass", - T ->; - -export type LayerClass = GetKey< - GetKey, - "layerClass", - T ->; - -/** - * Actual document types that go in folders - */ -export type FolderDocumentTypes = Exclude; - -export type MaybeEmpty = - | T - | { - [K in keyof T]?: never; - }; - -/** - * The following uses `extends object` instead of `AnyObject` to allow `O = typeof SomeClass` - */ -export type PropertiesOfType = { - [K in keyof O]: [O[K], T] extends [T, O[K]] ? K : never; -}[keyof O]; - /** * @deprecated {@link Document.SubTypesOf | `Document.SubTypesOf`}. */ @@ -345,7 +178,7 @@ export type DocumentSubTypes = Document.SubTypesOf; /** * @deprecated {@link Document.ConfiguredClassForName | `Document.ConfiguredClassForName`}. */ -export type ConfiguredDocumentClassForName = ConfiguredDocuments[Name]; +export type ConfiguredDocumentClassForName = Document.ConfiguredClassForName; /** * @deprecated {@link Document.ConfiguredInstanceForName | `Document.ConfiguredInstanceForName`}. @@ -364,220 +197,26 @@ export type ConfiguredObjectClassForName = export type ConfiguredLayerClassForName = CONFIG[Name]["layerClass"]; /** - * See {@link Document.ConfiguredDataForName | `Document.ConfiguredDataForName`}. + * @deprecated {@link Document.ConfiguredDataForName | `Document.ConfiguredDataForName`}. */ -export type ConfiguredData = Document.ConfiguredDataForName>; +export type ConfiguredData = Document.ConfiguredDataForName>; /** - * See {@link Document.ConfiguredDataForName | `Document.ConfiguredDataForName`}. + * @deprecated {@link Document.ConfiguredDataForName | `Document.ConfiguredDataForName`}. */ -export type ConfiguredSource = Document.ConfiguredDataForName>; +export type ConfiguredSource = Document.ConfiguredDataForName>; /** - * See {@link Document.ConfiguredFlagsForName | `Document.ConfiguredFlagsForName`}. + * @deprecated {@link Document.ConfiguredFlagsForName | `Document.ConfiguredFlagsForName`}. */ -export type ConfiguredFlags = Document.ConfiguredFlagsForName>; +export type ConfiguredFlags = Document.ConfiguredFlagsForName>; /** * @deprecated {@link Document.ToObjectFalseType | `Document.ToObjectFalseType`}. */ -export type ToObjectFalseType = Document.ToObjectFalseType>; +export type ToObjectFalseType = Document.ToObjectFalseType>; /** * @deprecated {@link PropertyKey | `PropertyKey`} */ export type AnyKey = keyof any; - -declare class Branded { - #brand: BrandName; -} - -/** - * Brands a type such that is behaves just like the input type while preventing - * assignment to it. This is useful to create types that indicate a specific - * invariant that the type must adhere to that a more basic type wouldn't have. - * - * Note: You can brand most types but due to its implementation this - * helper is incompatible with `any`, `unknown`, and `never`. See "Brand Implementation" - * for more details. - * - * For example enum members can be branded to prevent an arbitrary number from - * being mistakenly used in their place: - * - * @example - * ```ts - * type NUMBER_ENUM = Brand; - * - * const NUMBER_ENUM: { - * X: NUMBER_ENUM, - * Y: NUMBER_ENUM - * }; - * - * function useNumberEnum(value: NUMBER_ENUM) { ... } - * usesNumberEnum(NUMBER_ENUM.X); // Works. - * usesNumberEnum(1); // Error. - * ``` - * - * ### Brand Implementation - * - * The fundamental trick of the implementation is that it intersects the base - * type with a compile-time only marker property. This marker property will not - * exist on the base type and so prevents assignment just like how `{ foo: string }` - * can't be assigned to `{ foo: string; bar: number }` because it's missing a property. - * - * A more basic implementation might look like this: - * - * ```ts - * type Brand = BaseType & { brandType: BrandName }; - * ``` - * - * But this has two problems: - * - In theory anyone can add this `brandType` property. - * - The `brandType` property is accessible and visible, e.g. - * `keyof Brand` would include `brandType` because it's a visible property. - * - * The implementation here solves both of these problems by using a private class field. - * This class is unexported and so due to the way that private class properties work this - * means there is no other way to create a compatible property (outside of `any`). Using a - * class also has the added benefit that the type parameter can be specifically marked as - * invariant for a bit of extra protection. - * - * This does mean that `Brand` only works with types where an intersection is meaningful. - * These are the problematic types: - * - `any` will become `any` still because `any & T` is still `any`. This makes `Brand` useless. - * - `never` stays `never` because `never & T` is `never`. This makes `Brand` useless. - * - `unknown` becomes `Branded` because `unknown & T` is `T`. This is a problem because `unknown` can be any type, e.g. `number` but `Branded` is always an object. - * - * Unfortunately there aren't really good workarounds either. - */ -export type Brand = BaseType & Branded; - -/** - * An at a best effort level expands a type from something complex that shows up like - * `DeepPartial<{ x: { y: number } }>` in intellisense to `{ x?: { y?: number } }`. - * This is useful for when you want to see what a type looks like in a more human - * readable form. - * - * Using this type is a performance tradeoff, might increase the likelihood of - * circularities, and technically in some extremely niche cases changes the type behavior. - * ```@example - * // The implementation of this type is outside the scope of this example. - * // See UnionToIntersection. - * type UnionToIntersection = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never; - * - * type ObjectIntersection = UnionToIntersection<{ x: string } | { y: number }>; - * // ^ { x: string } & { y: number } - * - * type PrettyObjectIntersection = PrettifyType; - * // ^ { x: string, y: number } - * - * function example(t: T) { - * Object.assign(t, { a: "foo" }, {b: 2}) satisfies ObjectIntersection - * Object.assign(t, { a: "foo" }, {b: 2}) satisfies PrettyObjectIntersection - * // ^ Type 'T & { a: string; } & { b: number; }' does not satisfy the expected type '{ a: string; b: number; }'. - * // This is an example of changing type behavior. The first line is allowed but the second errors. - * // This type of situation will realistically never come up in real code because it's so contrived. - * // Note that this difference only appears when generic, specifically `T extends Object | NonObject`. - * // See https://github.com/microsoft/TypeScript/pull/60726 for some context. - * } - * ``` - */ -export type PrettifyType = T extends AnyObject - ? { - [K in keyof T]: T[K]; - } - : T & unknown; - -/** - * This behaves the same as {@link PrettifyType | `PrettifyType`} except instead - * of prettifying only the first level it prettifies all levels of an object. of prettifying only the first level it prettifies all levels of an object. - */ -export type PrettifyTypeDeep = T extends AnyObject - ? { - [K in keyof T]: PrettifyTypeDeep; - } - : T & unknown; - -/** - * Convert a union of the form `T1 | T2 | T3 | ...` into an intersection of the form `T1 & T2 & T3 & ...`. - * - * ### Implementation Details - * - * Breaking this type down into steps evaluation begins with the expression - * `U extends unknown ? ... : never`. Note that `U` is a "bare type parameter", - * that is written directly as opposed to being wrapped like `U[]`. Because of - * this the type is distributive. - * - * Distributivity means that `U extends unknown ? (arg: U) => void : never` turns the input - * of the form `T1 | T2 | T3 | ...` into `((arg: T1) => void) | ((arg: T2) => void) | ((arg: T3) => void)`. - * Let's call this new union `FunctionUnion` - * - * Finally `FunctionUnion extends (arg: infer I) => void ? I : never` is evaluated. - * This results in `T1 & T2 & T3 | ...` as promised... but why? Even with distributivity - * in play, normally `(T extends unknown ? F : never) extends F ? T : never` - * would just be a complex way of writing `T`. - * - * The complete answer is fairly deep and is unlikely to make sense unless you are - * already well versed in this area. In particular it lies in what happens when `F` - * puts `T` into a contravariant position. In this case inferring `T` back out - * requires an intersection effectively because the covariant assignment rules - * are flipped. - * - * That explanation is unlikely to have helped much and so let's run through two - * examples. - * - * First, a refresher: - * ```ts - * function takesX(arg: { x: number }): number { ... } - * function takesY(arg: { y: string }): string { ... } - * - * let output = ...; - * if (Math.random() > 0.5) { - * output = takesX({ x: 1 }); - * } else { - * output = takesY({ y: "example" }); - * } - * ``` - * - * What is the best type for `output` in this case? Of course, it'd be `number | string`. - * - * What about this example? - * ```ts - * function takesX(arg: { x: number }): number { ... } - * function takesY(arg: { y: string }): string { ... } - * - * let input = ...; - * if (Math.random() > 0.5) { - * takesX(input); - * } else { - * takesY(input); - * } - * ``` - * - * What is the best type for `input` in this case? It might be tempting to say `{ x: number } | { y: string }` - * similarly to how `output` was `number | string`. But that's not quite right. The correct type for `input` is - * actually `{ x: number } & { y: string }`. The reason why this is the case is that it's unpredictable whether - * `takesX` or `takesY` will be called. This means that `input` must be able to used to call both functions. - * - * This is analogous to asking these two questions at the type level: - * ```ts - * type Functions = typeof takesX | typeof takesY; - * type Output = Functions extends (...args: any[]) => infer Output ? Output : never; - * // ^ number | string - * type Input = Functions extends (arg: infer Input) => any ? Input : never; - * // ^ { x: number } & { y: string } - * ``` - * - * And if you reflect on the inciting code, `FunctionUnion extends (arg: infer I) => void ? I : never` - * you'll see that it's effectively doing the same thing. - * - * If you want to read more see TypeScript's handbook section on - * [Distributive Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types) - * for more information on distributivity. There is also a section on - * [Variance](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations) - * in general but it unfortunately doesn't touch too much on specific details and - * the emergent behavior of variance like this. - */ -export type UnionToIntersection = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void - ? I - : never; diff --git a/src/types/index.d.mts b/src/types/index.d.mts index 7ea1ae505..4bb9efb25 100644 --- a/src/types/index.d.mts +++ b/src/types/index.d.mts @@ -2,3 +2,4 @@ import "./augments/index.d.mts"; import "./config.d.mts"; import "./documentConfiguration.d.mts"; import "./utils.d.mts"; +import "./helperTypes.d.mts"; diff --git a/src/types/utils.d.mts b/src/types/utils.d.mts index 5670759de..eab20527a 100644 --- a/src/types/utils.d.mts +++ b/src/types/utils.d.mts @@ -1,100 +1,31 @@ import type { Document } from "../foundry/common/abstract/module.d.mts"; -import type { MakeConform } from "./helperTypes.d.mts"; +import type * as utils from "../utils/index.d.mts"; /** - * Recursively sets keys of an object to optional. Used primarily for update methods - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type DeepPartial = T extends unknown - ? IsObject extends true - ? { - [P in keyof T]?: DeepPartial; - } - : T - : T; +export type DeepPartial = utils.DeepPartial; /** - * Gets all possible keys of `T`. This is useful because if `T` is a union type - * it will get the properties of all types in the union. Otherwise it functions identically to `keyof T`. + * @deprecated import from `fvtt-types/utils` instead. */ -export type AllKeysOf = T extends unknown ? keyof T : never; +export type AllKeysOf = utils.AllKeysOf; /** - * Make all properties in `T` optional and explicitly allow `undefined` - * - * ### Picking the right helper type - * - Favor `NullishProps` whenever it is valid. Allowing both `null` and - * `undefined` is convenient for the end user and it is very common that - * wherever `undefined` is valid so is `null`. For some examples it is valid - * for `options.prop ??= "default"`, `options.prop ||= "default"`, - * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. - * - Use `IntentionalPartial` when an explicit `undefined` is problematic but - * leaving off the property entirely is fine. This primarily occurs when - * patterns like `options = { ...defaultOptions, ...options }`, - * `Object.assign({}, defaultOptions, options)`, - * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. - * - * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} - * also expands the object. So once `ExpandsTo` exists you should also use - * that helper type. - * - * What these patterns have in common is that if `options` looks like - * `{ prop: undefined }` that will override whatever is in `defaultOptions` - * and may cause issues. Note that even if you see one of these patterns you - * also need to ensure that `undefined` would cause issues down the road - * before using `IntentionalPartial` as it could be an intended way of - * resetting a property. - * - Use `InexactPartial` when `null` is problematic but `undefined` is not. - * The most common time this shows up is with the pattern - * `exampleFunction({ prop = "foo" } = {}) { ... }`. - * - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type InexactPartial = AllKeysOf> = { - [K2 in keyof T as Extract]?: T[K2] | undefined; -} & { - // Note(LukeAbby): This effectively inlines `Omit`, hoping for slightly better type display. - [K2 in keyof T as Exclude]: T[K2]; -}; +export type InexactPartial = utils.AllKeysOf> = utils.InexactPartial< + T, + K +>; /** - * Makes select properties in `T` optional and explicitly allows both `null` and - * `undefined` values. - * - * ### Picking the right helper type - * - Favor `NullishProps` whenever it is valid. Allowing both `null` and - * `undefined` is convenient for the end user and it is very common that - * wherever `undefined` is valid so is `null`. For some examples it is valid - * for `options.prop ??= "default"`, `options.prop ||= "default"`, - * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. - * - Use `IntentionalPartial` when an explicit `undefined` is problematic but - * leaving off the property entirely is fine. This primarily occurs when - * patterns like `options = { ...defaultOptions, ...options }`, - * `Object.assign({}, defaultOptions, options)`, - * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. - * - * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} - * also expands the object. So once `ExpandsTo` exists you should also use - * that helper type. - * - * What these patterns have in common is that if `options` looks like - * `{ prop: undefined }` that will override whatever is in `defaultOptions` - * and may cause issues. Note that even if you see one of these patterns you - * also need to ensure that `undefined` would cause issues down the road - * before using `IntentionalPartial` as it could be an intended way of - * resetting a property. - * - Use `InexactPartial` when `null` is problematic but `undefined` is not. - * The most common time this shows up is with the pattern - * `exampleFunction({ prop = "foo" } = {}) { ... }`. - * - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type NullishProps = AllKeysOf> = { - [K2 in keyof T as Extract]?: T[K2] | null | undefined; -} & { - // Note(LukeAbby): This effectively inlines `Omit`, hoping for slightly better type display. - [K2 in keyof T as Exclude]: T[K2]; -}; +export type NullishProps = utils.AllKeysOf> = utils.NullishProps< + T, + K +>; /** * @deprecated - Deprecated with no replacement. This type is almost always an anti-pattern because @@ -122,110 +53,44 @@ export type NullishProps = AllKeysOf export type ConstructorOf = new (arg0: never, ...args: never[]) => T; /** - * Expand an object that contains keys in dotted notation - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type Expanded = O extends AnyObject - ? { - [KO in keyof O as KO extends `${infer A}.${string}` ? A : KO]: KO extends `${string}.${infer B}` - ? Expanded<{ [EB in B]: O[KO] }> - : Expanded; - } - : O; +export type Expanded = utils.Expanded; /** - * Union type of the types of the values in `T` - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type ValueOf = T extends ReadonlyArray ? V : T[keyof T]; +export type ValueOf = utils.ValueOf; -type OmitIndex = string extends K - ? never - : number extends K - ? never - : symbol extends K - ? never - : K; +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type ConcreteKeys = utils.ConcreteKeys; /** - * Gets the keys of `T` but excluding index signatures unlike `keyof T`. For example `Record & { foo: number }` will produce `string` with `keyof` but `foo` with `ConcreteKeys`. + * @deprecated import from `fvtt-types/utils` instead. */ -export type ConcreteKeys = T extends never - ? never - : keyof { - [K in keyof T as OmitIndex]: never; - }; +export type RemoveIndexSignatures = utils.RemoveIndexSignatures; /** - * Removes all index signatures from an object. Use this instead of `[K in keyof ConcreteKeys]` to preserve modifiers e.g. readonly, or optional. + * @deprecated import from `fvtt-types/utils` instead. */ -// NOTE(LukeAbby): It may seem easier to write `Pick>` but this stops it from being a homomorphic mapped type and regresses its power when given a generic type parameter or `this`. -// See: https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBDAnmYcDCEB2BjKwbADSwiAzgDwAqAfHALxwDWJEAZnAN4BQccA2oTgBLTExbtKcAIak4pGFBEBzOKAKYAJrMEB+OJmAA3YFDgAufQFcAtgCMTqkOq1xd+ow4ulEdiABtHZ204PQNjUwtCAF0LMJMAbi4AX0SuJBQ4ACVgawhjAElNUABlISVMKRhLPAoaejgABSFsRioAGnQsXHwiElrqalTsPxlZABFKqQBZCA1gP3Ji7AALHKlabl454ak8OFy5vwts3IKikFLyyurgCiXV63Xkri4d0lliy1sZw8WVtcCwE0sg4cCUQJMzQaUAgYAsUkwiHi-EIXgUyhiVjsDiStDUQJcExg01m8z+D3WnB4+3wy1mAAoAJRU3i8AD0bLglGWQlkYBhKCgiDkdMsfg0jl58FslngGggt0wAHIYAA6am8GA80iqg7zVXggyKbDQ2GpVkIbW60l+VVSWzYRK8JLJIA -export type RemoveIndexSignatures = { - [K in keyof T as OmitIndex]: T[K]; -}; +export type Titlecase = utils.Titlecase; /** - * Transforms a string to lowercase and the first character to uppercase. - * @internal + * @deprecated import from `fvtt-types/utils` instead. */ -export type Titlecase = S extends `${infer A} ${infer B}` - ? `${Titlecase} ${Titlecase}` - : Capitalize>; +export type Merge = utils.Merge; /** - * Deeply merge two types. If either of the given types is not an object then `U` - * simply overwrites `T`. - * - * Nested properties of type `object` are merged recursively unless the property - * in `U` is an `Array`. - * - * @typeParam T - The base type that `U` will be merged into. - * @typeParam U - The type that will be merged into `T`. - */ -export type Merge = - IsObject extends true - ? IsObject extends true - ? SimpleMerge< - T, - { - [K in keyof U]: T extends { readonly [_ in K]?: infer V } ? Merge : U[K]; - } - > - : U - : U; - -/** - * Returns whether the type is a plain object. Excludes functions and arrays while still being friendly to interfaces. - * - * @example - * ```ts - * interface ObjectInterface { - * prop: number; - * } - * - * type Interface = IsObject; // true - * type Object = IsObject<{ prop: number }>; // true - * type Array = IsObject; // false - * type Function = IsObject<() => void>; // false - * - * // By comparison, simply comparing against `Record` fails. - * type RecordFails = Interface extends Record ? true : false; // false - * ``` + * @deprecated import from `fvtt-types/utils` instead. */ -// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style -export type IsObject = T extends { readonly [K: string]: any } - ? T extends AnyArray | AnyFunction - ? false - : true - : false; +export type IsObject = utils.IsObject; /** - * A simple, non-recursive merge type. - * @typeParam Target - the target type to merge into - * @typeParam Override - the type whose properties override the ones in Target + * @deprecated import from `fvtt-types/utils` instead. */ -export type SimpleMerge = Omit & Override; +export type SimpleMerge = utils.SimpleMerge; /** * @deprecated - {@link GetKey | `GetKey`} @@ -233,293 +98,101 @@ export type SimpleMerge = Omit & Overr export type PropertyTypeOrFallback = Key extends keyof T ? T[Key] : Fallback; /** - * Makes the given keys `K` of the type `T` required + * @deprecated import from `fvtt-types/utils` instead. */ -export type RequiredProps = Required> & Omit; - -export type Mixin = MixinClass & BaseClass; - -interface GetDataConfigOptions { - partial: Partial & Record; - exact: T; - object: object; -} - -type GetDataConfigOption = GetDataConfig extends { - mode: infer Mode extends keyof GetDataConfigOptions; -} - ? Mode - : "object"; +export type RequiredProps = utils.RequiredProps< + Extract, + Extract>> +>; -export type GetDataReturnType = GetDataConfigOptions[GetDataConfigOption]; +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type Mixin = utils.Mixin< + MixinClass, + BaseClass +>; /** - * Replaces the type `{}` with `Record` by default which is - * usually a better representation of an empty object. The type `{}` actually - * allows any type be assigned to it except for `null` and `undefined`. - * - * The theory behind this is that all non-nullish types allow - * you to access any property on them without erroring. Primitive types like - * `number` will not store the property but it still will not error to simply - * try to get and set properties. - * - * The type `{}` can appear for example after operations like `Omit` if it - * removes all properties rom an object, because an empty interface was given, - * or so on. - * - * Type params extend `object` instead of `AnyObject` to allow interfaces - * - * @example - * ```ts - * type ObjectArray> = T[]; - * - * // As you would hope a union can't be assigned. It errors with: - * // "type 'string' is not assignable to type 'Record'." - * type UnionErrors = ObjectArray; - * - * // However, this works. - * type EmptyObjectArray = ObjectArray<{}>; - * - * // But it allows likely unsound behavior like this: - * const emptyObject: EmptyObjectArray = [1, "foo", () => 3]; - * - * // So it may be better to define `ObjectArray` like so: - * type ObjectArray> = HandleEmptyObject[]; - * - * // If it were, then this line would error appropriately! - * const emptyObject: EmptyObjectArray = [1, "foo", () => 3]; - * ``` + * @deprecated import from `fvtt-types/utils` instead. */ -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -export type HandleEmptyObject = [{}] extends [T] ? D : T; +export type GetDataReturnType = utils.GetDataReturnType; /** - * This type allows any plain objects. In other words it disallows functions - * and arrays. - * - * Use this type instead of: - * - `object`/`Record` - This allows functions, classes, and arrays. - * - `{}` - This type allows anything besides `null` and `undefined`. - * - `Record` - This is the appropriate type for any mutable object but doesn't allow readonly objects. + * @deprecated import from `fvtt-types/utils` instead. */ -// This type is not meant to be extended and it has to use an indexed type. -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/consistent-indexed-object-style -export type AnyObject = { - readonly [K: string]: unknown; -}; +export type HandleEmptyObject = utils.HandleEmptyObject; /** - * This type allows mutable plain objects. This means readonly objects cannot be - * assigned. - * - * Use this type instead of: - * - `object` - This allows functions and arrays. - * - `Record`/`{}` - These allows anything besides `null` and `undefined`. - * - `Record` - These types are equivalent but `AnyMutableObject` is preferred for explicitness. + * @deprecated import from `fvtt-types/utils` instead. */ -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/consistent-indexed-object-style -export type AnyMutableObject = { - [K: string]: unknown; -}; +export type AnyObject = utils.AnyObject; /** - * Use this type to allow any array. This allows readonly arrays which is - * generally what you want. If you need a mutable array use the - * {@link MutableArray | `MutableArray`} type instead of the builtin `T[]` or - * `Array` types. This allows us to be more explicit about intent. - * - * Consider being more specific if possible. You should generally try to use a - * concrete array with a union or add a type parameter first. - * - * Use this instead of: - * - `any[]` - When elements of this array are accessed you get `any` which is not safe. - * - `unknown[]` - This is the appropriate type for any mutable array but doesn't allow readonly arrays. + * @deprecated import from `fvtt-types/utils` instead. */ -export type AnyArray = readonly unknown[]; +export type AnyMutableObject = utils.AnyMutableObject; /** - * Use this type to allow a mutable array of type `T`. Only use this if the - * array can be soundly mutated. Otherwise you should be using - * `readonly T[]` or {@link ReadonlyArray | `ReadonlyArray`} + * @deprecated import from `fvtt-types/utils` instead. */ -export type MutableArray = Array; +export type AnyArray = utils.AnyArray; /** - * Use this type to allow any function. Notably since this allows any function - * it is difficult to call the function in a safe way. This means its uses are - * mostly niche and it should be avoided. - * - * Make sure you have a good reason to use this type. It is almost always better - * to use a more specific function type. Please consider leaving a comment about - * why this type is necessary. - * - * Use this instead of: - * - `Function` - This refers to the fundamental `Function` object in JS. It allows classes. - * - `(...args: any[]) => any` - If someone explicitly accesses the parameters or uses the return value you get `any` which is not safe. - * - `(...args: any[]) => any` - If someone explicitly accesses the parameters or uses the return value you get `any` which is not safe. - * - `(...args: unknown[]) => unknown` - This allows obviously unsound calls like `fn(1, "foo")` because it indicates it can take any arguments. + * @deprecated import from `fvtt-types/utils` instead. */ -// The explicit arg0 does not prevent a function with no arguments from being assigned to `AnyFunction` because any function that takes less arguments can be assigned to one that takes more. -// The point of this is to prevent it from being possible to call with 0 arguments. -// never is used to make it impossible to call with anything besides `never` or `any`. This makes it the most type safe way to define any function. -export type AnyFunction = (arg0: never, ...args: never[]) => unknown; +export type MutableArray = utils.MutableArray; /** - * Use this type to allow any class, abstract class, or class-like constructor. - * - * See {@link AnyConcreteConstructor | `AnyConcreteConstructor`} if you cannot - * allow abstract classes. Please also consider writing a comment - * explaining why {@link AnyConcreteConstructor | `AnyConcreteConstructor`} is - * necessary. - * - * @example - * ```ts - * const concrete: AnyConstructor = class Concrete { ... } - * const abstract: AnyConstructor = abstract class Abstract { ... } - * - * // `Date` is not actually a class but it can be used as a constructor. - * const classLike: AnyConstructor = Date; - * ``` + * @deprecated import from `fvtt-types/utils` instead. */ -export type AnyConstructor = abstract new (arg0: never, ...args: never[]) => unknown; +export type AnyFunction = utils.AnyFunction; /** - * Use this type to allow any class or class-like constructor but disallow - * class-like constructors. - * - * Use this type only when abstract classes would be problematic such as the - * base type of a mixin. Please consider writing a comment explaining why. - * See {@link AnyConstructor | `AnyConstructor`} to also allow abstract classes. - * - * @example - * ```ts - * const concrete: AnyConcreteConstructor = class Concrete { ... } - * - * // `Date` is not actually a class but it can be used as a constructor. - * const classLike: AnyConcreteConstructor = Date; - * - * // This next line errors: - * const abstract: AnyConcreteConstructor = abstract class Abstract { ... } - * ``` + * @deprecated import from `fvtt-types/utils` instead. */ -export type AnyConcreteConstructor = new (arg0: never, ...args: never[]) => unknown; +export type AnyConstructor = utils.AnyConstructor; /** - * This type is equivalent to `Promise` but exists to give an explicit signal - * that this is not a mistake. When Foundry accepts an asynchronous callback the - * vast majority of the time it is best to use {@link MaybePromise | `MaybePromise`}. - * - * By doing it this way the maximum flexibility is given to the definer of the - * callback. This is okay because typically asynchronous callbacks are simply - * awaited, meaning that there's no noticeable difference between a `Promise` - * and {@link MaybePromise | `MaybePromise`}. Even functions like - * {@link Promise.allSettled | `Promise.allSettled`} function correctly - * with {@link MaybePromise | `MaybePromise`}. - * - * Do not use this type or {@link MaybePromise | `MaybePromise`} for the return - * type of asynchronous methods on classes. For example for - * {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing - * should be `Promise` and not this type. In theory we could use - * {@link MaybePromise | `MaybePromise`} in this context as well but this seems - * more likely to be confusing than to be helpful. - * - * Use this type only in the rare case where a callback's return type must be a - * `Promise`, for example if `promise.then` or `promise.catch` is explicitly - * called. Please also writing a comment explaining why - * {@link MaybePromise | `MaybePromise`} is problematic in this context. + * @deprecated import from `fvtt-types/utils` instead. */ -export type MustBePromise = Promise; +export type AnyConcreteConstructor = utils.AnyConcreteConstructor; /** - * Use when a type may be either a promise or not. This is most useful in - * asynchronous callbacks where in most cases it's sound to provide a synchronous - * callback instead. - * - * If it is not sound to provide a non-Promise for whatever reason, see - * {@link MustBePromise | `MustBePromise`} to declare this more explicitly than simply writing - * `Promise`. - * - * This should generally not be used in asynchronous methods. For example in - * {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing - * is `Promise` because it's declared as an async method. Overriding an - * asynchronous method with a synchronous method is more confusing than - * helpful. + * @deprecated import from `fvtt-types/utils` instead. */ -export type MaybePromise = T | Promise; +export type MustBePromise = utils.MustBePromise; /** - * Use this to allow any type besides `null` or `undefined`. - * - * This type is equivalent to the type `{}`. It exists to give this type a - * better name. `{}` is not a type representing an empty object. In reality it - * allows assigning any type besides `null` or `undefined`. This is frustrating - * but it seems the theory is supposed to be that all types except for `null` - * and `undefined` will return `undefined` for any property accessed on them. - * - * Even primitives like `number` will not error when you get or even set a - * property on them, although they will not preserve the property. Since the - * only type that cannot be indexed is `null` or `undefined` this is the chosen - * semantics of `{}` in TypeScript. + * @deprecated import from `fvtt-types/utils` instead. */ -// This type is not meant to be extended and it's meant to be the explicit version of what the type `{}` does, i.e. allow any type besides `null` or `undefined`. -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-object-type -export type NonNullish = {}; +export type MaybePromise = utils.MaybePromise; /** - * This is the closest approximation to a type representing an empty object. - * - * Use instead of `{}` when you want to represent an empty object. `{}` actually - * allows any type that is not `null` or `undefined`. see - * {@link NonNullish | `NonNullish`} if you want that behavior. + * @deprecated import from `fvtt-types/utils` instead. */ -// It would be unsound to merge into so an interface is not used. -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type EmptyObject = Record; +export type NonNullish = utils.NonNullish; -declare const empty: unique symbol; +/** + * @deprecated import from `fvtt-types/utils` instead. + */ +export type EmptyObject = utils.EmptyObject; /** - * This helper type helps emulate index signatures for types with incompatible concrete keys. - * - * For example the type `{ foo: number; [K: string]: string }` is not allowed because the index signature is incompatible with the concrete key `foo`. - * It may seem like tricks like `{ foo: number; } & { [K: string]: string }` work but this defers the error to the caller. - * - * @example - * ```typescript - * type NaiveType = { foo: number; [K: string]: boolean }; - * // ^ Property 'foo' of type 'number' is not assignable to 'string' index type 'boolean'. - * - * type NaiveIntersection = { foo: number } & { [K: string]: string }; - * - * function usesIntersection(intersection: NaiveIntersection) { ... } - * - * usesIntersection({ foo: 1, x: true }); - * // ^ Argument of type '{ foo: number; }' is not assignable to parameter of type 'NaiveIntersection'. - * // Type '{ foo: number; }' is not assignable to type '{ [K: string]: boolean; }'. - * // Property 'foo' is incompatible with index signature. - * // Type 'number' is not assignable to type 'boolean'. - * - * function usesCorrectly(withIndex: ShapeWithIndexSignature) { ... } - * - * usesCorrectly({ foo: 1, x: true }); - * ``` + * @deprecated import from `fvtt-types/utils` instead. */ -// Note: If https://github.com/microsoft/TypeScript/issues/17867 or https://github.com/microsoft/TypeScript/issues/43826 (depending on implementation) is implemented it's likely this type can be expressed in a better way. export type ShapeWithIndexSignature< - T extends AnyObject, + T extends utils.AnyObject, // Uses `extends object` to allow interfaces and if useful other objects. PrimaryShape extends object, IndexSignature extends PropertyKey, IndexType, -> = PrimaryShape & { - readonly [K in keyof T & IndexSignature]: K extends keyof PrimaryShape ? PrimaryShape[K] : IndexType; -}; +> = utils.ShapeWithIndexSignature; /** - * Defer is a utility type that allows you to defer the evaluation of a type. - * The use cases for this are extremely advanced. In essence they have to do with breaking cycles in evaluation. + * @deprecated import from `fvtt-types/utils` instead. */ -export type Defer = [T][T extends any ? 0 : never]; +export type Defer = utils.Defer; /** * @deprecated {@link Document.ToConfiguredStored | `Document.ToConfiguredStored`} @@ -530,10 +203,10 @@ export type ConfiguredStoredDocument = Docume * @deprecated {@link Document.Stored | `Document.Stored`} */ export type StoredDocument = Document.Stored< - MakeConform + utils.MakeConform >; /** * @deprecated {@link Document.Temporary | `Document.Temporary`} */ -export type TemporaryDocument = Document.Temporary>; +export type TemporaryDocument = Document.Temporary>; diff --git a/src/utils/index.d.mts b/src/utils/index.d.mts new file mode 100644 index 000000000..1aa58800a --- /dev/null +++ b/src/utils/index.d.mts @@ -0,0 +1,968 @@ +import type { Document } from "../foundry/common/abstract/module.d.mts"; + +type ConfiguredModuleData = Name extends keyof ModuleConfig ? ModuleConfig[Name] : EmptyObject; + +export type ConfiguredModule = Name extends keyof RequiredModules + ? ConfiguredModuleData + : + | ({ active: true } & ConfiguredModuleData) + // flawed, can't use `key in module` this way, but omitting the Partial Record type kills nullish + // collocating, which is probably the better DX. + | ({ active: false } & Record, undefined>); + +/** Keys of functions of console.log / globalThis.logger */ +export type LoggingLevels = "debug" | "log" | "info" | "warn" | "error"; + +/** + * `GetKey` accesses a property while intentionally ignoring index signatures. This means `GetKey, "foo">` will return `never`. + */ +// Note(LukeAbby): There are two tricky cases: +// - `T = {}` would regularly always return `unknown`. The fix here adding a single dummy property `{ _?: any } & T`. +// - `T = never` would regularly always return `unknown`. The fix here is adding `_GetKey` which makes the type distributive and therefore `never` as an input becomes `never` in the output. +export type GetKey = _GetKey<{ _?: any } & T, K, D>; + +type _GetKey = T extends { readonly [_ in K]?: infer V } ? V : D; + +/** + * `Partial` is usually the wrong type. + * In order to make it easier to audit unintentional uses of `Partial` this type is provided. + * + * ### Picking the right helper type + * - Favor `NullishProps` whenever it is valid. Allowing both `null` and + * `undefined` is convenient for the end user and it is very common that + * wherever `undefined` is valid so is `null`. For some examples it is valid + * for `options.prop ??= "default"`, `options.prop ||= "default"`, + * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. + * - Use `IntentionalPartial` when an explicit `undefined` is problematic but + * leaving off the property entirely is fine. This primarily occurs when + * patterns like `options = { ...defaultOptions, ...options }`, + * `Object.assign({}, defaultOptions, options)`, + * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. + * + * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} + * also expands the object. So once `ExpandsTo` exists you should also use + * that helper type. + * + * What these patterns have in common is that if `options` looks like + * `{ prop: undefined }` that will override whatever is in `defaultOptions` + * and may cause issues. Note that even if you see one of these patterns you + * also need to ensure that `undefined` would cause issues down the road + * before using `IntentionalPartial` as it could be an intended way of + * resetting a property. + * - Use `InexactPartial` when `null` is problematic but `undefined` is not. + * The most common time this shows up is with the pattern + * `exampleFunction({ prop = "foo" } = {}) { ... }`. + */ +export type IntentionalPartial = Partial; + +/** + * This type is used to make a constraint where `T` must be statically known to overlap with `U`. + * + * @example + * ```ts + * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.` + * function takesNumber(input: OverlapsWith): void { + * // This function body is an example of a method this might be useful for. + * // If the input isn't an number it simply returns in this case. + * if (typeof input !== "number") { + * return; + * } + * + * // Assumes, unchecked, that `element` is a number. + * // This means an input like `number[] | string[]` would be unsound as it could be a string. + * element + 1; + * } + * + * takesNumber(1); // Ok! + * takesNumber("foo"); // Error, statically known to never an number and so presumed to be a mistake. + * takesNumber(Math.random() > 0.5 ? 1 : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful. + * ``` + */ +export type OverlapsWith = [Extract, any] extends [U, Extract] ? T : U extends T ? T : U; + +/** + * Used to build a constraint where `T` to overlap with `Item[]` but disallows unrelated arrays. + * This is safer than what `OverlapsWith` provides as it ensures that if the type is an array it is an array of `Item`. + * Assumes readonly arrays are permitted. + * + * Note that `never[]` and `any[]` are still accepted due to the unsoundness of those types. + * + * @example + * ```ts + * // The `const T` allows inference to be a bit more specific. This is useful for a utility type like this.` + * function takesNumericArray(input: ArrayOverlaps): void { + * // This function body is an example of a method this might be useful for. + * // If the input isn't an array it simply returns in this case. + * if (!Array.isArray(input)) { + * return; + * } + * + * for (const element of input) { + * // Assumes, unchecked, that `element` is a number. + * // This means an input like `number[] | string[]` would be unsound as it could be a string. + * element + 1; + * } + * } + * + * takesNumericArray([1, 2, 3]); // Ok! + * takesNumericArray("foo"); // Error, statically known to never an array and so presumed to be a mistake. + * takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : "foo"); // Ok, `"foo"` doesn't actually cause any runtime issues, it was just disallowed above because then it'd never do anything useful. + * takesNumericArray(Math.random() > 0.5 ? [1, 2, 3] : ["foo", "bar"]); // Error, at runtime it could be an array of the wrong type and that isn't handled. Notably this would succeed with `OverlapsWith`. + * ``` + */ +export type ArrayOverlaps = + Extract extends readonly Item[] ? OverlapsWith : readonly Item[]; + +/** + * Use this whenever a type is given that should match some constraint but is + * not guaranteed to. For example when additional properties can be declaration + * merged into an interface. When the type does not conform then `ConformTo` is + * used instead. + * + * See `MustConform` for a version that throws a compilation error when the type + * cannot be statically known to conform. + */ +export type MakeConform = [T] extends [ConformTo] ? T : ConformTo; + +/** + * This is useful when you want to ensure that a type conforms to a certain + * constraint. If it is not guaranteed to conform then a compilation error is + * thrown. This makes it too conservative in some cases. + */ +export type MustConform = T; + +/** + * This allows you to treat all interfaces as a plain object. But beware, if the + * interface represents a function, array, or constructor then these will be + * stripped from the interface. + * + * This is generally intended for cases where an interface is given in order to + * be declaration merged and then must be assigned to a plain object type. + * + * The constraint `T extends object` is used because `object` includes functions + * and arrays etc. This is crucial to allow interfaces to be given to this type. + */ +export type InterfaceToObject = { + // Mapped types are no-ops on most types (even primitives like string) but for + // functions, classes, and arrays they convert them to "proper" objects by + // stripping constructors/function signatures. One side effect is a type like + // `() => number` will result in `{}`. + [K in keyof T]: T[K]; +}; + +/** + * This is a helper type that allows you to ensure that a record conforms to a + * certain shape. This is useful when you want to ensure that a record has all + * keys of a certain type. + * + * When a value does not conform it is replaced with `never` to indicate that + * there is an issue. + */ +export type ConformRecord = { + [K in keyof T]: T[K] extends V ? T[K] : never; +}; + +/** + * Converts a regular function type into a function derived from a method. + * + * Methods have a special exception in TypeScript that allows unsound subtyping + * that unfortunately has been deeply engrained into not just JavaScript codebases + * but the core APIs of JavaScript itself in the DOM. + * + * It might seem odd to want to opt-in to this unsoundness but it's unfortunately + * useful in several cases, such as when you have a property like + * `prop: ((arg: Options) => number) | undefined` and you want to meet the expectations + * from other similar methods. + * + * @example + * ```typescript + * declare class ExampleBaseClass { + * // This demonstrates a typical example of where the allowed unsoundness is useful. + * methodOne(arg: { x: string }): number; + * + * // This helps demonstrates an example that may be easier to recognize as unsound. + * methodTwo(arg: string): number; + * + * functionProperty: (arg: string) => number; + * methodLikeProperty: ToMethod<(arg: string) => number>; + * } + * + * // TypeScript allows this without any errors. + * declare class MethodSubclassing extends ExampleBaseClass { + * // It's a very common thing for subclasses to ask for extra arguments. + * methodOne(arg: { x: string; y: string }): number; + * + * // Only taking `"foo" | "bar"` should seem pretty unsound. + * // The above is actually equally unsound but it's less obvious to many people. + * methodTwo(arg: "foo" | "bar"): number; + * } + * + * const exampleMethodSubclass: ExampleBaseClass = new MethodSubclassing(); + * + * // This is allowed, however at runtime `MethodSubclassing#methodOne` could + * // will almost certainly error as it has the required property `y`. + * // The reason why there's no errors is an intentional unsoundness in TypeScript. + * exampleMethodSubclass.methodOne({ x: "foo" }); + * + * // Similarly this is allowed. + * // Both methods show taking arguments that are 'subtypes' of the original. + * // In the case of functions this is unsound as demonstrated because in both + * // examples you're substituting a function that has to be able to be called + * // with a wide variety of arguments with one that will error for many of them. + * exampleMethodSubclass.methodTwo("lorem"); + * + * declare class PropertySubclassing extends ExampleBaseClass { + * // This errors right here. This preventative error is because of the prior + * // explained unsoundness. It errors here because there's really only 3 + * // places to error at compile time to prevent a runtime error: + * // 1. At the call site when a subclass is used unsoundly. Unfortunately + * // at this point it's too late to know for certain if it's a subclass + * // or not. For example there could be a guarded condition to avoid + * // subclasses that TypeScript can't possibly track. + * // 2. When trying to assign `PropertySubclassing` to `ExampleBaseClass`. + * // This would be a feasible alternative but would likely come as a + * // surprise as the subclass could have been used for quite a while + * // before trying to be assigned to its superclass. + * // 3. Error at the definition. This is where TypeScript has chosen to error. + * // The error is unfortunately not the most intuitive but it is correct. + * functionProperty: (arg: "foo" | "bar") => number; + * } + * + * declare class MethodLikeSubclassing { + * // This is unsound but by using the `ToMethod` in the parent class it's allowed. + * methodLikeProperty: (arg: "foo" | "bar") => number; + * } + * ``` + * + * The TypeScript FAQ explains this in a way that may either be intuitive and + * explain all lingering questions or be confusing and muddle the waters. + * It's also worth mentioning that it claims all function parameters work this way, + * this behavior is disabled for functions in most codebases (including this one) + * because of the `strictFunctionTypes` compiler flag, implicit under `strict: true`. + * See: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant + */ +export type ToMethod = { + method(...args: Parameters): ReturnType; +}["method"]; + +export type ConfiguredSheetClass = GetKey< + GetKey, + "sheetClass", + T +>; + +export type ObjectClass = GetKey< + GetKey, + "objectClass", + T +>; + +export type LayerClass = GetKey< + GetKey, + "layerClass", + T +>; + +/** + * Actual document types that go in folders + */ +export type FolderDocumentTypes = Exclude; + +export type MaybeEmpty = + | T + | { + [K in keyof T]?: never; + }; + +/** + * The following uses `extends object` instead of `AnyObject` to allow `O = typeof SomeClass` + */ +export type PropertiesOfType = { + [K in keyof O]: [O[K], T] extends [T, O[K]] ? K : never; +}[keyof O]; + +declare class Branded { + #brand: BrandName; +} + +/** + * Brands a type such that is behaves just like the input type while preventing + * assignment to it. This is useful to create types that indicate a specific + * invariant that the type must adhere to that a more basic type wouldn't have. + * + * Note: You can brand most types but due to its implementation this + * helper is incompatible with `any`, `unknown`, and `never`. See "Brand Implementation" + * for more details. + * + * For example enum members can be branded to prevent an arbitrary number from + * being mistakenly used in their place: + * + * @example + * ```ts + * type NUMBER_ENUM = Brand; + * + * const NUMBER_ENUM: { + * X: NUMBER_ENUM, + * Y: NUMBER_ENUM + * }; + * + * function useNumberEnum(value: NUMBER_ENUM) { ... } + * usesNumberEnum(NUMBER_ENUM.X); // Works. + * usesNumberEnum(1); // Error. + * ``` + * + * ### Brand Implementation + * + * The fundamental trick of the implementation is that it intersects the base + * type with a compile-time only marker property. This marker property will not + * exist on the base type and so prevents assignment just like how `{ foo: string }` + * can't be assigned to `{ foo: string; bar: number }` because it's missing a property. + * + * A more basic implementation might look like this: + * + * ```ts + * type Brand = BaseType & { brandType: BrandName }; + * ``` + * + * But this has two problems: + * - In theory anyone can add this `brandType` property. + * - The `brandType` property is accessible and visible, e.g. + * `keyof Brand` would include `brandType` because it's a visible property. + * + * The implementation here solves both of these problems by using a private class field. + * This class is unexported and so due to the way that private class properties work this + * means there is no other way to create a compatible property (outside of `any`). Using a + * class also has the added benefit that the type parameter can be specifically marked as + * invariant for a bit of extra protection. + * + * This does mean that `Brand` only works with types where an intersection is meaningful. + * These are the problematic types: + * - `any` will become `any` still because `any & T` is still `any`. This makes `Brand` useless. + * - `never` stays `never` because `never & T` is `never`. This makes `Brand` useless. + * - `unknown` becomes `Branded` because `unknown & T` is `T`. This is a problem because `unknown` can be any type, e.g. `number` but `Branded` is always an object. + * + * Unfortunately there aren't really good workarounds either. + */ +export type Brand = BaseType & Branded; + +/** + * An at a best effort level expands a type from something complex that shows up like + * `DeepPartial<{ x: { y: number } }>` in intellisense to `{ x?: { y?: number } }`. + * This is useful for when you want to see what a type looks like in a more human + * readable form. + * + * Using this type is a performance tradeoff, might increase the likelihood of + * circularities, and technically in some extremely niche cases changes the type behavior. + * ```@example + * // The implementation of this type is outside the scope of this example. + * // See UnionToIntersection. + * type UnionToIntersection = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never; + * + * type ObjectIntersection = UnionToIntersection<{ x: string } | { y: number }>; + * // ^ { x: string } & { y: number } + * + * type PrettyObjectIntersection = PrettifyType; + * // ^ { x: string, y: number } + * + * function example(t: T) { + * Object.assign(t, { a: "foo" }, {b: 2}) satisfies ObjectIntersection + * Object.assign(t, { a: "foo" }, {b: 2}) satisfies PrettyObjectIntersection + * // ^ Type 'T & { a: string; } & { b: number; }' does not satisfy the expected type '{ a: string; b: number; }'. + * // This is an example of changing type behavior. The first line is allowed but the second errors. + * // This type of situation will realistically never come up in real code because it's so contrived. + * // Note that this difference only appears when generic, specifically `T extends Object | NonObject`. + * // See https://github.com/microsoft/TypeScript/pull/60726 for some context. + * } + * ``` + */ +export type PrettifyType = T extends AnyObject + ? { + [K in keyof T]: T[K]; + } + : T & unknown; + +/** + * This behaves the same as {@link PrettifyType | `PrettifyType`} except instead + * of prettifying only the first level it prettifies all levels of an object. of prettifying only the first level it prettifies all levels of an object. + */ +export type PrettifyTypeDeep = T extends AnyObject + ? { + [K in keyof T]: PrettifyTypeDeep; + } + : T & unknown; + +/** + * Convert a union of the form `T1 | T2 | T3 | ...` into an intersection of the form `T1 & T2 & T3 & ...`. + * + * ### Implementation Details + * + * Breaking this type down into steps evaluation begins with the expression + * `U extends unknown ? ... : never`. Note that `U` is a "bare type parameter", + * that is written directly as opposed to being wrapped like `U[]`. Because of + * this the type is distributive. + * + * Distributivity means that `U extends unknown ? (arg: U) => void : never` turns the input + * of the form `T1 | T2 | T3 | ...` into `((arg: T1) => void) | ((arg: T2) => void) | ((arg: T3) => void)`. + * Let's call this new union `FunctionUnion` + * + * Finally `FunctionUnion extends (arg: infer I) => void ? I : never` is evaluated. + * This results in `T1 & T2 & T3 | ...` as promised... but why? Even with distributivity + * in play, normally `(T extends unknown ? F : never) extends F ? T : never` + * would just be a complex way of writing `T`. + * + * The complete answer is fairly deep and is unlikely to make sense unless you are + * already well versed in this area. In particular it lies in what happens when `F` + * puts `T` into a contravariant position. In this case inferring `T` back out + * requires an intersection effectively because the covariant assignment rules + * are flipped. + * + * That explanation is unlikely to have helped much and so let's run through two + * examples. + * + * First, a refresher: + * ```ts + * function takesX(arg: { x: number }): number { ... } + * function takesY(arg: { y: string }): string { ... } + * + * let output = ...; + * if (Math.random() > 0.5) { + * output = takesX({ x: 1 }); + * } else { + * output = takesY({ y: "example" }); + * } + * ``` + * + * What is the best type for `output` in this case? Of course, it'd be `number | string`. + * + * What about this example? + * ```ts + * function takesX(arg: { x: number }): number { ... } + * function takesY(arg: { y: string }): string { ... } + * + * let input = ...; + * if (Math.random() > 0.5) { + * takesX(input); + * } else { + * takesY(input); + * } + * ``` + * + * What is the best type for `input` in this case? It might be tempting to say `{ x: number } | { y: string }` + * similarly to how `output` was `number | string`. But that's not quite right. The correct type for `input` is + * actually `{ x: number } & { y: string }`. The reason why this is the case is that it's unpredictable whether + * `takesX` or `takesY` will be called. This means that `input` must be able to used to call both functions. + * + * This is analogous to asking these two questions at the type level: + * ```ts + * type Functions = typeof takesX | typeof takesY; + * type Output = Functions extends (...args: any[]) => infer Output ? Output : never; + * // ^ number | string + * type Input = Functions extends (arg: infer Input) => any ? Input : never; + * // ^ { x: number } & { y: string } + * ``` + * + * And if you reflect on the inciting code, `FunctionUnion extends (arg: infer I) => void ? I : never` + * you'll see that it's effectively doing the same thing. + * + * If you want to read more see TypeScript's handbook section on + * [Distributive Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types) + * for more information on distributivity. There is also a section on + * [Variance](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations) + * in general but it unfortunately doesn't touch too much on specific details and + * the emergent behavior of variance like this. + */ +export type UnionToIntersection = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void + ? I + : never; + +// Helper Types + +/** + * Recursively sets keys of an object to optional. Used primarily for update methods + * @internal + */ +export type DeepPartial = T extends unknown + ? IsObject extends true + ? { + [P in keyof T]?: DeepPartial; + } + : T + : T; + +/** + * Gets all possible keys of `T`. This is useful because if `T` is a union type + * it will get the properties of all types in the union. Otherwise it functions identically to `keyof T`. + */ +export type AllKeysOf = T extends unknown ? keyof T : never; + +/** + * Make all properties in `T` optional and explicitly allow `undefined` + * + * ### Picking the right helper type + * - Favor `NullishProps` whenever it is valid. Allowing both `null` and + * `undefined` is convenient for the end user and it is very common that + * wherever `undefined` is valid so is `null`. For some examples it is valid + * for `options.prop ??= "default"`, `options.prop ||= "default"`, + * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. + * - Use `IntentionalPartial` when an explicit `undefined` is problematic but + * leaving off the property entirely is fine. This primarily occurs when + * patterns like `options = { ...defaultOptions, ...options }`, + * `Object.assign({}, defaultOptions, options)`, + * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. + * + * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} + * also expands the object. So once `ExpandsTo` exists you should also use + * that helper type. + * + * What these patterns have in common is that if `options` looks like + * `{ prop: undefined }` that will override whatever is in `defaultOptions` + * and may cause issues. Note that even if you see one of these patterns you + * also need to ensure that `undefined` would cause issues down the road + * before using `IntentionalPartial` as it could be an intended way of + * resetting a property. + * - Use `InexactPartial` when `null` is problematic but `undefined` is not. + * The most common time this shows up is with the pattern + * `exampleFunction({ prop = "foo" } = {}) { ... }`. + * + * @internal + */ +export type InexactPartial = AllKeysOf> = { + [K2 in keyof T as Extract]?: T[K2] | undefined; +} & { + // Note(LukeAbby): This effectively inlines `Omit`, hoping for slightly better type display. + [K2 in keyof T as Exclude]: T[K2]; +}; + +/** + * Makes select properties in `T` optional and explicitly allows both `null` and + * `undefined` values. + * + * ### Picking the right helper type + * - Favor `NullishProps` whenever it is valid. Allowing both `null` and + * `undefined` is convenient for the end user and it is very common that + * wherever `undefined` is valid so is `null`. For some examples it is valid + * for `options.prop ??= "default"`, `options.prop ||= "default"`, + * `if (options.prop) { ... }`, `if (options.prop == null)`, or so on. + * - Use `IntentionalPartial` when an explicit `undefined` is problematic but + * leaving off the property entirely is fine. This primarily occurs when + * patterns like `options = { ...defaultOptions, ...options }`, + * `Object.assign({}, defaultOptions, options)`, + * `foundry.utils.mergeObject(defaultOptions, options)`, or so on. + * + * Note that {@link foundry.utils.mergeObject | `foundry.utils.mergeObject`} + * also expands the object. So once `ExpandsTo` exists you should also use + * that helper type. + * + * What these patterns have in common is that if `options` looks like + * `{ prop: undefined }` that will override whatever is in `defaultOptions` + * and may cause issues. Note that even if you see one of these patterns you + * also need to ensure that `undefined` would cause issues down the road + * before using `IntentionalPartial` as it could be an intended way of + * resetting a property. + * - Use `InexactPartial` when `null` is problematic but `undefined` is not. + * The most common time this shows up is with the pattern + * `exampleFunction({ prop = "foo" } = {}) { ... }`. + * + * @internal + */ +export type NullishProps = AllKeysOf> = { + [K2 in keyof T as Extract]?: T[K2] | null | undefined; +} & { + // Note(LukeAbby): This effectively inlines `Omit`, hoping for slightly better type display. + [K2 in keyof T as Exclude]: T[K2]; +}; + +/** + * Expand an object that contains keys in dotted notation + * @internal + */ +export type Expanded = O extends AnyObject + ? { + [KO in keyof O as KO extends `${infer A}.${string}` ? A : KO]: KO extends `${string}.${infer B}` + ? Expanded<{ [EB in B]: O[KO] }> + : Expanded; + } + : O; + +/** + * Union type of the types of the values in `T` + * @internal + */ +export type ValueOf = T extends ReadonlyArray ? V : T[keyof T]; + +type OmitIndex = string extends K + ? never + : number extends K + ? never + : symbol extends K + ? never + : K; + +/** + * Gets the keys of `T` but excluding index signatures unlike `keyof T`. For example `Record & { foo: number }` will produce `string` with `keyof` but `foo` with `ConcreteKeys`. + */ +export type ConcreteKeys = T extends never + ? never + : keyof { + [K in keyof T as OmitIndex]: never; + }; + +/** + * Removes all index signatures from an object. Use this instead of `[K in keyof ConcreteKeys]` to preserve modifiers e.g. readonly, or optional. + */ +// NOTE(LukeAbby): It may seem easier to write `Pick>` but this stops it from being a homomorphic mapped type and regresses its power when given a generic type parameter or `this`. +// See: https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBDAnmYcDCEB2BjKwbADSwiAzgDwAqAfHALxwDWJEAZnAN4BQccA2oTgBLTExbtKcAIak4pGFBEBzOKAKYAJrMEB+OJmAA3YFDgAufQFcAtgCMTqkOq1xd+ow4ulEdiABtHZ204PQNjUwtCAF0LMJMAbi4AX0SuJBQ4ACVgawhjAElNUABlISVMKRhLPAoaejgABSFsRioAGnQsXHwiElrqalTsPxlZABFKqQBZCA1gP3Ji7AALHKlabl454ak8OFy5vwts3IKikFLyyurgCiXV63Xkri4d0lliy1sZw8WVtcCwE0sg4cCUQJMzQaUAgYAsUkwiHi-EIXgUyhiVjsDiStDUQJcExg01m8z+D3WnB4+3wy1mAAoAJRU3i8AD0bLglGWQlkYBhKCgiDkdMsfg0jl58FslngGggt0wAHIYAA6am8GA80iqg7zVXggyKbDQ2GpVkIbW60l+VVSWzYRK8JLJIA +export type RemoveIndexSignatures = { + [K in keyof T as OmitIndex]: T[K]; +}; + +/** + * Transforms a string to lowercase and the first character to uppercase. + * @internal + */ +export type Titlecase = S extends `${infer A} ${infer B}` + ? `${Titlecase} ${Titlecase}` + : Capitalize>; + +/** + * Deeply merge two types. If either of the given types is not an object then `U` + * simply overwrites `T`. + * + * Nested properties of type `object` are merged recursively unless the property + * in `U` is an `Array`. + * + * @typeParam T - The base type that `U` will be merged into. + * @typeParam U - The type that will be merged into `T`. + */ +export type Merge = + IsObject extends true + ? IsObject extends true + ? SimpleMerge< + T, + { + [K in keyof U]: T extends { readonly [_ in K]?: infer V } ? Merge : U[K]; + } + > + : U + : U; + +/** + * Returns whether the type is a plain object. Excludes functions and arrays while still being friendly to interfaces. + * + * @example + * ```ts + * interface ObjectInterface { + * prop: number; + * } + * + * type Interface = IsObject; // true + * type Object = IsObject<{ prop: number }>; // true + * type Array = IsObject; // false + * type Function = IsObject<() => void>; // false + * + * // By comparison, simply comparing against `Record` fails. + * type RecordFails = Interface extends Record ? true : false; // false + * ``` + */ +// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style +export type IsObject = T extends { readonly [K: string]: any } + ? T extends AnyArray | AnyFunction + ? false + : true + : false; + +/** + * A simple, non-recursive merge type. + * @typeParam Target - the target type to merge into + * @typeParam Override - the type whose properties override the ones in Target + */ +export type SimpleMerge = Omit & Override; + +/** + * Makes the given keys `K` of the type `T` required + */ +export type RequiredProps> = Required> & Omit; + +export type Mixin = MixinClass & BaseClass; + +interface GetDataConfigOptions { + partial: Partial & Record; + exact: T; + object: object; +} + +type GetDataConfigOption = GetDataConfig extends { + mode: infer Mode extends keyof GetDataConfigOptions; +} + ? Mode + : "object"; + +export type GetDataReturnType = GetDataConfigOptions[GetDataConfigOption]; + +/** + * Replaces the type `{}` with `Record` by default which is + * usually a better representation of an empty object. The type `{}` actually + * allows any type be assigned to it except for `null` and `undefined`. + * + * The theory behind this is that all non-nullish types allow + * you to access any property on them without erroring. Primitive types like + * `number` will not store the property but it still will not error to simply + * try to get and set properties. + * + * The type `{}` can appear for example after operations like `Omit` if it + * removes all properties rom an object, because an empty interface was given, + * or so on. + * + * Type params extend `object` instead of `AnyObject` to allow interfaces + * + * @example + * ```ts + * type ObjectArray> = T[]; + * + * // As you would hope a union can't be assigned. It errors with: + * // "type 'string' is not assignable to type 'Record'." + * type UnionErrors = ObjectArray; + * + * // However, this works. + * type EmptyObjectArray = ObjectArray<{}>; + * + * // But it allows likely unsound behavior like this: + * const emptyObject: EmptyObjectArray = [1, "foo", () => 3]; + * + * // So it may be better to define `ObjectArray` like so: + * type ObjectArray> = HandleEmptyObject[]; + * + * // If it were, then this line would error appropriately! + * const emptyObject: EmptyObjectArray = [1, "foo", () => 3]; + * ``` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export type HandleEmptyObject = [{}] extends [T] ? D : T; + +/** + * This type allows any plain objects. In other words it disallows functions + * and arrays. + * + * Use this type instead of: + * - `object`/`Record` - This allows functions, classes, and arrays. + * - `{}` - This type allows anything besides `null` and `undefined`. + * - `Record` - This is the appropriate type for any mutable object but doesn't allow readonly objects. + */ +// This type is not meant to be extended and it has to use an indexed type. +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/consistent-indexed-object-style +export type AnyObject = { + readonly [K: string]: unknown; +}; + +/** + * This type allows mutable plain objects. This means readonly objects cannot be + * assigned. + * + * Use this type instead of: + * - `object` - This allows functions and arrays. + * - `Record`/`{}` - These allows anything besides `null` and `undefined`. + * - `Record` - These types are equivalent but `AnyMutableObject` is preferred for explicitness. + */ +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/consistent-indexed-object-style +export type AnyMutableObject = { + [K: string]: unknown; +}; + +/** + * Use this type to allow any array. This allows readonly arrays which is + * generally what you want. If you need a mutable array use the + * {@link MutableArray | `MutableArray`} type instead of the builtin `T[]` or + * `Array` types. This allows us to be more explicit about intent. + * + * Consider being more specific if possible. You should generally try to use a + * concrete array with a union or add a type parameter first. + * + * Use this instead of: + * - `any[]` - When elements of this array are accessed you get `any` which is not safe. + * - `unknown[]` - This is the appropriate type for any mutable array but doesn't allow readonly arrays. + */ +export type AnyArray = readonly unknown[]; + +/** + * Use this type to allow a mutable array of type `T`. Only use this if the + * array can be soundly mutated. Otherwise you should be using + * `readonly T[]` or {@link ReadonlyArray | `ReadonlyArray`} + */ +export type MutableArray = Array; + +/** + * Use this type to allow any function. Notably since this allows any function + * it is difficult to call the function in a safe way. This means its uses are + * mostly niche and it should be avoided. + * + * Make sure you have a good reason to use this type. It is almost always better + * to use a more specific function type. Please consider leaving a comment about + * why this type is necessary. + * + * Use this instead of: + * - `Function` - This refers to the fundamental `Function` object in JS. It allows classes. + * - `(...args: any[]) => any` - If someone explicitly accesses the parameters or uses the return value you get `any` which is not safe. + * - `(...args: any[]) => any` - If someone explicitly accesses the parameters or uses the return value you get `any` which is not safe. + * - `(...args: unknown[]) => unknown` - This allows obviously unsound calls like `fn(1, "foo")` because it indicates it can take any arguments. + */ +// The explicit arg0 does not prevent a function with no arguments from being assigned to `AnyFunction` because any function that takes less arguments can be assigned to one that takes more. +// The point of this is to prevent it from being possible to call with 0 arguments. +// never is used to make it impossible to call with anything besides `never` or `any`. This makes it the most type safe way to define any function. +export type AnyFunction = (arg0: never, ...args: never[]) => unknown; + +/** + * Use this type to allow any class, abstract class, or class-like constructor. + * + * See {@link AnyConcreteConstructor | `AnyConcreteConstructor`} if you cannot + * allow abstract classes. Please also consider writing a comment + * explaining why {@link AnyConcreteConstructor | `AnyConcreteConstructor`} is + * necessary. + * + * @example + * ```ts + * const concrete: AnyConstructor = class Concrete { ... } + * const abstract: AnyConstructor = abstract class Abstract { ... } + * + * // `Date` is not actually a class but it can be used as a constructor. + * const classLike: AnyConstructor = Date; + * ``` + */ +export type AnyConstructor = abstract new (arg0: never, ...args: never[]) => unknown; + +/** + * Use this type to allow any class or class-like constructor but disallow + * class-like constructors. + * + * Use this type only when abstract classes would be problematic such as the + * base type of a mixin. Please consider writing a comment explaining why. + * See {@link AnyConstructor | `AnyConstructor`} to also allow abstract classes. + * + * @example + * ```ts + * const concrete: AnyConcreteConstructor = class Concrete { ... } + * + * // `Date` is not actually a class but it can be used as a constructor. + * const classLike: AnyConcreteConstructor = Date; + * + * // This next line errors: + * const abstract: AnyConcreteConstructor = abstract class Abstract { ... } + * ``` + */ +export type AnyConcreteConstructor = new (arg0: never, ...args: never[]) => unknown; + +/** + * This type is equivalent to `Promise` but exists to give an explicit signal + * that this is not a mistake. When Foundry accepts an asynchronous callback the + * vast majority of the time it is best to use {@link MaybePromise | `MaybePromise`}. + * + * By doing it this way the maximum flexibility is given to the definer of the + * callback. This is okay because typically asynchronous callbacks are simply + * awaited, meaning that there's no noticeable difference between a `Promise` + * and {@link MaybePromise | `MaybePromise`}. Even functions like + * {@link Promise.allSettled | `Promise.allSettled`} function correctly + * with {@link MaybePromise | `MaybePromise`}. + * + * Do not use this type or {@link MaybePromise | `MaybePromise`} for the return + * type of asynchronous methods on classes. For example for + * {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing + * should be `Promise` and not this type. In theory we could use + * {@link MaybePromise | `MaybePromise`} in this context as well but this seems + * more likely to be confusing than to be helpful. + * + * Use this type only in the rare case where a callback's return type must be a + * `Promise`, for example if `promise.then` or `promise.catch` is explicitly + * called. Please also writing a comment explaining why + * {@link MaybePromise | `MaybePromise`} is problematic in this context. + */ +export type MustBePromise = Promise; + +/** + * Use when a type may be either a promise or not. This is most useful in + * asynchronous callbacks where in most cases it's sound to provide a synchronous + * callback instead. + * + * If it is not sound to provide a non-Promise for whatever reason, see + * {@link MustBePromise | `MustBePromise`} to declare this more explicitly than simply writing + * `Promise`. + * + * This should generally not be used in asynchronous methods. For example in + * {@link foundry.abstract.Document._preCreate | `Document#_preCreate`} the typing + * is `Promise` because it's declared as an async method. Overriding an + * asynchronous method with a synchronous method is more confusing than + * helpful. + */ +export type MaybePromise = T | Promise; + +/** + * Use this to allow any type besides `null` or `undefined`. + * + * This type is equivalent to the type `{}`. It exists to give this type a + * better name. `{}` is not a type representing an empty object. In reality it + * allows assigning any type besides `null` or `undefined`. This is frustrating + * but it seems the theory is supposed to be that all types except for `null` + * and `undefined` will return `undefined` for any property accessed on them. + * + * Even primitives like `number` will not error when you get or even set a + * property on them, although they will not preserve the property. Since the + * only type that cannot be indexed is `null` or `undefined` this is the chosen + * semantics of `{}` in TypeScript. + */ +// This type is not meant to be extended and it's meant to be the explicit version of what the type `{}` does, i.e. allow any type besides `null` or `undefined`. +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-object-type +export type NonNullish = {}; + +/** + * This is the closest approximation to a type representing an empty object. + * + * Use instead of `{}` when you want to represent an empty object. `{}` actually + * allows any type that is not `null` or `undefined`. see + * {@link NonNullish | `NonNullish`} if you want that behavior. + */ +// It would be unsound to merge into so an interface is not used. +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions +export type EmptyObject = Record; + +declare const empty: unique symbol; + +/** + * This helper type helps emulate index signatures for types with incompatible concrete keys. + * + * For example the type `{ foo: number; [K: string]: string }` is not allowed because the index signature is incompatible with the concrete key `foo`. + * It may seem like tricks like `{ foo: number; } & { [K: string]: string }` work but this defers the error to the caller. + * + * @example + * ```typescript + * type NaiveType = { foo: number; [K: string]: boolean }; + * // ^ Property 'foo' of type 'number' is not assignable to 'string' index type 'boolean'. + * + * type NaiveIntersection = { foo: number } & { [K: string]: string }; + * + * function usesIntersection(intersection: NaiveIntersection) { ... } + * + * usesIntersection({ foo: 1, x: true }); + * // ^ Argument of type '{ foo: number; }' is not assignable to parameter of type 'NaiveIntersection'. + * // Type '{ foo: number; }' is not assignable to type '{ [K: string]: boolean; }'. + * // Property 'foo' is incompatible with index signature. + * // Type 'number' is not assignable to type 'boolean'. + * + * function usesCorrectly(withIndex: ShapeWithIndexSignature) { ... } + * + * usesCorrectly({ foo: 1, x: true }); + * ``` + */ +// Note: If https://github.com/microsoft/TypeScript/issues/17867 or https://github.com/microsoft/TypeScript/issues/43826 (depending on implementation) is implemented it's likely this type can be expressed in a better way. +export type ShapeWithIndexSignature< + T extends AnyObject, + // Uses `extends object` to allow interfaces and if useful other objects. + PrimaryShape extends object, + IndexSignature extends PropertyKey, + IndexType, +> = PrimaryShape & { + readonly [K in keyof T & IndexSignature]: K extends keyof PrimaryShape ? PrimaryShape[K] : IndexType; +}; + +/** + * Defer is a utility type that allows you to defer the evaluation of a type. + * The use cases for this are extremely advanced. In essence they have to do with breaking cycles in evaluation. + */ +export type Defer = [T][T extends any ? 0 : never]; diff --git a/tests/foundry/client-esm/dice/roll.test-d.ts b/tests/foundry/client-esm/dice/roll.test-d.ts index 0b2a92e39..bd1c0b26f 100644 --- a/tests/foundry/client-esm/dice/roll.test-d.ts +++ b/tests/foundry/client-esm/dice/roll.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { EmptyObject } from "../../../../src/types/utils.d.mts"; +import type { EmptyObject } from "fvtt-types/utils"; class CustomRoll = EmptyObject> extends Roll {} diff --git a/tests/foundry/client-esm/helpers/compendium-art.test-d.ts b/tests/foundry/client-esm/helpers/compendium-art.test-d.ts index 891ef59fe..c7977d3e3 100644 --- a/tests/foundry/client-esm/helpers/compendium-art.test-d.ts +++ b/tests/foundry/client-esm/helpers/compendium-art.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { types } from "../../../../src/foundry/client-esm/helpers/_module.d.mts"; +import types = foundry.helpers; const caInfo = { actor: "actorId", token: { randomImg: false }, credit: "Me" }; expectTypeOf(caInfo).toMatchTypeOf; diff --git a/tests/foundry/client/apps/app.test-d.ts b/tests/foundry/client/apps/app.test-d.ts index f147c59ab..256177dc8 100644 --- a/tests/foundry/client/apps/app.test-d.ts +++ b/tests/foundry/client/apps/app.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; expectTypeOf(Application.defaultOptions).toEqualTypeOf(); diff --git a/tests/foundry/client/apps/hud/container.test-d.ts b/tests/foundry/client/apps/hud/container.test-d.ts index 9be6fa89e..813e19f9d 100644 --- a/tests/foundry/client/apps/hud/container.test-d.ts +++ b/tests/foundry/client/apps/hud/container.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; const display = new HeadsUpDisplay(); expectTypeOf(display.token).toEqualTypeOf(); diff --git a/tests/foundry/client/apps/hud/hotbar.test-d.ts b/tests/foundry/client/apps/hud/hotbar.test-d.ts index 7631f60c9..8756844a4 100644 --- a/tests/foundry/client/apps/hud/hotbar.test-d.ts +++ b/tests/foundry/client/apps/hud/hotbar.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; const hotbar = new Hotbar(); expectTypeOf(hotbar.page).toEqualTypeOf(); diff --git a/tests/foundry/client/apps/hud/hud.test-d.ts b/tests/foundry/client/apps/hud/hud.test-d.ts index 0a0bbcdb5..10baa5c5b 100644 --- a/tests/foundry/client/apps/hud/hud.test-d.ts +++ b/tests/foundry/client/apps/hud/hud.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; class MyPlaceableHud extends BasePlaceableHUD {} diff --git a/tests/foundry/client/apps/placeables/drawing-hud.test-d.ts b/tests/foundry/client/apps/placeables/drawing-hud.test-d.ts index aa4f52ace..0d88727f5 100644 --- a/tests/foundry/client/apps/placeables/drawing-hud.test-d.ts +++ b/tests/foundry/client/apps/placeables/drawing-hud.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; declare const drawing: Drawing; diff --git a/tests/foundry/client/apps/placeables/tile-hud.test-d.ts b/tests/foundry/client/apps/placeables/tile-hud.test-d.ts index f5a7f682b..2c27e9daf 100644 --- a/tests/foundry/client/apps/placeables/tile-hud.test-d.ts +++ b/tests/foundry/client/apps/placeables/tile-hud.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; declare const tile: Tile; diff --git a/tests/foundry/client/apps/placeables/token-hud.test-d.ts b/tests/foundry/client/apps/placeables/token-hud.test-d.ts index ebf3e5a12..965ef15b5 100644 --- a/tests/foundry/client/apps/placeables/token-hud.test-d.ts +++ b/tests/foundry/client/apps/placeables/token-hud.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybePromise } from "../../../../../src/types/utils.d.mts"; +import type { MaybePromise } from "fvtt-types/utils"; declare const token: Token; diff --git a/tests/foundry/client/apps/sidebar/tabs/combat-tracker.test-d.ts b/tests/foundry/client/apps/sidebar/tabs/combat-tracker.test-d.ts index 3f0e1f017..d56c3f5d8 100644 --- a/tests/foundry/client/apps/sidebar/tabs/combat-tracker.test-d.ts +++ b/tests/foundry/client/apps/sidebar/tabs/combat-tracker.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; declare const combat: Combat; diff --git a/tests/foundry/client/config.test-d.ts b/tests/foundry/client/config.test-d.ts index 41cc91783..bbd271af4 100644 --- a/tests/foundry/client/config.test-d.ts +++ b/tests/foundry/client/config.test-d.ts @@ -1,4 +1,4 @@ -import type { AnyObject } from "../../../src/types/utils.d.mts"; +import type { AnyObject } from "fvtt-types/utils"; class D20Roll extends Roll {} diff --git a/tests/foundry/client/core/issues.test-d.ts b/tests/foundry/client/core/issues.test-d.ts index 0df1b8914..7e4c7823e 100644 --- a/tests/foundry/client/core/issues.test-d.ts +++ b/tests/foundry/client/core/issues.test-d.ts @@ -1,6 +1,7 @@ import { expectTypeOf } from "vitest"; -import type { DocumentType } from "../../../../src/types/helperTypes.d.mts"; -import type { DataModelValidationError } from ",,/../../src/foundry/common/data/validation-failure.d.mts"; + +import Document = foundry.abstract.Document; +import DataModelValidationError = foundry.data.validation.DataModelValidationError; const issues = new ClientIssues(); @@ -9,5 +10,5 @@ expectTypeOf(issues.getAllSubtypeCounts()).toEqualTypeOf>(); expectTypeOf(issues.packageCompatibilityIssues).toEqualTypeOf<{ error: string[]; warning: string[] }>(); expectTypeOf(issues.validationFailures).toEqualTypeOf< - Record> + Record> >(); diff --git a/tests/foundry/client/core/settings.test-d.ts b/tests/foundry/client/core/settings.test-d.ts index a03ba168e..6976291f9 100644 --- a/tests/foundry/client/core/settings.test-d.ts +++ b/tests/foundry/client/core/settings.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { MaybeEmpty } from "../../../../src/types/helperTypes.d.mts"; +import type { MaybeEmpty } from "fvtt-types/utils"; const clientSettings = new ClientSettings([]); diff --git a/tests/foundry/client/core/socket.test-d.ts b/tests/foundry/client/core/socket.test-d.ts index 56afb82a7..8a077fe19 100644 --- a/tests/foundry/client/core/socket.test-d.ts +++ b/tests/foundry/client/core/socket.test-d.ts @@ -1,7 +1,8 @@ import { expectTypeOf } from "vitest"; -import type { DocumentSocketRequest } from "../../../../src/foundry/common/abstract/_types.d.mts"; -declare const request: DocumentSocketRequest<"get">; +import Document = foundry.abstract.Document; + +declare const request: Document.SocketRequest<"get">; declare const request2: ManageCompendiumRequest; expectTypeOf(SocketInterface.dispatch("", request)).toEqualTypeOf>(); diff --git a/tests/foundry/client/core/utils.test-d.ts b/tests/foundry/client/core/utils.test-d.ts index dd3502b80..863704cad 100644 --- a/tests/foundry/client/core/utils.test-d.ts +++ b/tests/foundry/client/core/utils.test-d.ts @@ -1,5 +1,5 @@ import { assertType } from "vitest"; -import type { AnyFunction } from "../../../../src/types/utils.d.mts"; +import type { AnyFunction } from "fvtt-types/utils"; // prove that they are global assertType(saveDataToFile); diff --git a/tests/foundry/client/data/abstract/canvas-document.test-d.ts b/tests/foundry/client/data/abstract/canvas-document.test-d.ts index 906435f3b..b2240253a 100644 --- a/tests/foundry/client/data/abstract/canvas-document.test-d.ts +++ b/tests/foundry/client/data/abstract/canvas-document.test-d.ts @@ -1,5 +1,6 @@ import { assertType, expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; + +import Document = foundry.abstract.Document; const doc = new AmbientLightDocument(); diff --git a/tests/foundry/client/data/collections/actors.test-d.ts b/tests/foundry/client/data/collections/actors.test-d.ts index b7418ab1f..df9add3e8 100644 --- a/tests/foundry/client/data/collections/actors.test-d.ts +++ b/tests/foundry/client/data/collections/actors.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const actors = new Actors([]); expectTypeOf(actors.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/combats.test-d.ts b/tests/foundry/client/data/collections/combats.test-d.ts index 9c8bf6f47..514c9cd6a 100644 --- a/tests/foundry/client/data/collections/combats.test-d.ts +++ b/tests/foundry/client/data/collections/combats.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const combatEncounters = new CombatEncounters([]); expectTypeOf(combatEncounters.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/compendium-collection.test-d.ts b/tests/foundry/client/data/collections/compendium-collection.test-d.ts index f6c8ad786..cd0502206 100644 --- a/tests/foundry/client/data/collections/compendium-collection.test-d.ts +++ b/tests/foundry/client/data/collections/compendium-collection.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; -import type { DeepPartial } from "../../../../../src/types/utils.d.mts"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import type { DeepPartial } from "fvtt-types/utils"; +import Document = foundry.abstract.Document; const compendiumCollection = await CompendiumCollection.createCompendium({ type: "JournalEntry" as const, diff --git a/tests/foundry/client/data/collections/fog.test-d.ts b/tests/foundry/client/data/collections/fog.test-d.ts index edeee5cd3..edbb5381d 100644 --- a/tests/foundry/client/data/collections/fog.test-d.ts +++ b/tests/foundry/client/data/collections/fog.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const fogExplorations = new FogExplorations([]); expectTypeOf(fogExplorations.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/folder.test-d.ts b/tests/foundry/client/data/collections/folder.test-d.ts index 729d7389c..ff7ceff88 100644 --- a/tests/foundry/client/data/collections/folder.test-d.ts +++ b/tests/foundry/client/data/collections/folder.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const folders = new Folders(); expectTypeOf(folders.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/items.test-d.ts b/tests/foundry/client/data/collections/items.test-d.ts index af890efd2..18593c934 100644 --- a/tests/foundry/client/data/collections/items.test-d.ts +++ b/tests/foundry/client/data/collections/items.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const items = new Items([]); expectTypeOf(items.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/journal.test-d.ts b/tests/foundry/client/data/collections/journal.test-d.ts index 8be75ec2e..d12b417f7 100644 --- a/tests/foundry/client/data/collections/journal.test-d.ts +++ b/tests/foundry/client/data/collections/journal.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const journal = new Journal([]); expectTypeOf(journal.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/macros.test-d.ts b/tests/foundry/client/data/collections/macros.test-d.ts index d92d29b2e..f2ed272f5 100644 --- a/tests/foundry/client/data/collections/macros.test-d.ts +++ b/tests/foundry/client/data/collections/macros.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const macros = new Macros([]); expectTypeOf(macros.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/messages.test-d.ts b/tests/foundry/client/data/collections/messages.test-d.ts index 4083dfee0..5bf901335 100644 --- a/tests/foundry/client/data/collections/messages.test-d.ts +++ b/tests/foundry/client/data/collections/messages.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const messages = new Messages([]); expectTypeOf(messages.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/playlists.test-d.ts b/tests/foundry/client/data/collections/playlists.test-d.ts index aa1641ea6..5d2a8b499 100644 --- a/tests/foundry/client/data/collections/playlists.test-d.ts +++ b/tests/foundry/client/data/collections/playlists.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const playlists = new Playlists([]); expectTypeOf(playlists.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/scenes.test-d.ts b/tests/foundry/client/data/collections/scenes.test-d.ts index c93dfdd97..f4fb95056 100644 --- a/tests/foundry/client/data/collections/scenes.test-d.ts +++ b/tests/foundry/client/data/collections/scenes.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(Scenes.documentName).toEqualTypeOf<"Scene">(); diff --git a/tests/foundry/client/data/collections/settings.test-d.ts b/tests/foundry/client/data/collections/settings.test-d.ts index f7aa5a581..f0e198d9e 100644 --- a/tests/foundry/client/data/collections/settings.test-d.ts +++ b/tests/foundry/client/data/collections/settings.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const worldSettings = new WorldSettings([]); expectTypeOf(worldSettings.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/tables.test-d.ts b/tests/foundry/client/data/collections/tables.test-d.ts index 492bd275a..81e272a6d 100644 --- a/tests/foundry/client/data/collections/tables.test-d.ts +++ b/tests/foundry/client/data/collections/tables.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const rollTables = new RollTables([]); expectTypeOf(rollTables.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/collections/users.test-d.ts b/tests/foundry/client/data/collections/users.test-d.ts index 88d657bef..c039381df 100644 --- a/tests/foundry/client/data/collections/users.test-d.ts +++ b/tests/foundry/client/data/collections/users.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const users = new Users(); expectTypeOf(users.get("", { strict: true })).toEqualTypeOf>(); diff --git a/tests/foundry/client/data/documents/active-effect.test-d.ts b/tests/foundry/client/data/documents/active-effect.test-d.ts index 6af87b39a..1e9bf52d7 100644 --- a/tests/foundry/client/data/documents/active-effect.test-d.ts +++ b/tests/foundry/client/data/documents/active-effect.test-d.ts @@ -1,6 +1,8 @@ import { expectTypeOf } from "vitest"; -import type { DataModel, Document } from "../../../../../src/foundry/common/abstract/module.d.mts"; -import type { EffectChangeData } from "../../../../../src/foundry/common/documents/_types.d.mts"; + +import DataModel = foundry.abstract.DataModel; +import Document = foundry.abstract.Document; +import EffectChangeData = foundry.types.EffectChangeData; // @ts-expect-error - ActiveEffect requires name. new ActiveEffect(); diff --git a/tests/foundry/client/data/documents/adventure.test-d.ts b/tests/foundry/client/data/documents/adventure.test-d.ts index 4db39b414..013cbc50c 100644 --- a/tests/foundry/client/data/documents/adventure.test-d.ts +++ b/tests/foundry/client/data/documents/adventure.test-d.ts @@ -1,6 +1,7 @@ import { expectTypeOf } from "vitest"; -import type { DataModel } from "../../../../../src/foundry/common/abstract/module.d.mts"; -import type { fields } from "../../../../../src/foundry/common/data/module.d.mts"; + +import DataModel = foundry.abstract.DataModel; +import fields = foundry.data.fields; // @ts-expect-error - Adventure requires name. new Adventure(); diff --git a/tests/foundry/client/data/documents/card.test-d.ts b/tests/foundry/client/data/documents/card.test-d.ts index e3d222519..5fa5e5cc6 100644 --- a/tests/foundry/client/data/documents/card.test-d.ts +++ b/tests/foundry/client/data/documents/card.test-d.ts @@ -1,5 +1,6 @@ import { expectTypeOf } from "vitest"; -import type { CardFaceData } from "../../../../../src/foundry/common/documents/_types.d.mts"; + +import CardFaceData = foundry.data.CardFaceData; // @ts-expect-error - Card requires name. new Card(); diff --git a/tests/foundry/client/data/documents/cards.test-d.ts b/tests/foundry/client/data/documents/cards.test-d.ts index 6399a0c8d..2595e7323 100644 --- a/tests/foundry/client/data/documents/cards.test-d.ts +++ b/tests/foundry/client/data/documents/cards.test-d.ts @@ -1,5 +1,6 @@ import { expectTypeOf } from "vitest"; -import type { FilePathField } from "../../../../../src/foundry/common/data/fields.d.mts"; + +import FilePathField = foundry.common.fields.FilePathField; // @ts-expect-error - Cards requires name. new Cards(); diff --git a/tests/foundry/client/data/documents/chat-message.test-d.ts b/tests/foundry/client/data/documents/chat-message.test-d.ts index f08461784..d9b589c12 100644 --- a/tests/foundry/client/data/documents/chat-message.test-d.ts +++ b/tests/foundry/client/data/documents/chat-message.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; -import type { ChatSpeakerData } from "../../../../../src/foundry/common/documents/_types.d.mts"; +import Document = foundry.abstract.Document; +import ChatSpeakerData = foundry.data.ChatSpeakerData; expectTypeOf(new ChatMessage()).toEqualTypeOf(); expectTypeOf(new ChatMessage({})).toEqualTypeOf(); diff --git a/tests/foundry/client/data/documents/combatant.test-d.ts b/tests/foundry/client/data/documents/combatant.test-d.ts index 813e9f2b2..27ca20641 100644 --- a/tests/foundry/client/data/documents/combatant.test-d.ts +++ b/tests/foundry/client/data/documents/combatant.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const combatant = new Combatant({}, {}); diff --git a/tests/foundry/client/data/documents/macro.test-d.ts b/tests/foundry/client/data/documents/macro.test-d.ts index bfd287281..39fb23680 100644 --- a/tests/foundry/client/data/documents/macro.test-d.ts +++ b/tests/foundry/client/data/documents/macro.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; // @ts-expect-error data is required new Macro(); diff --git a/tests/foundry/client/data/documents/setting.test-d.ts b/tests/foundry/client/data/documents/setting.test-d.ts index a742fd241..a337212a1 100644 --- a/tests/foundry/client/data/documents/setting.test-d.ts +++ b/tests/foundry/client/data/documents/setting.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; -import type { AnyObject } from "../../../../../src/types/utils.d.mts"; +import Document = foundry.abstract.Document; +import type { AnyObject } from "fvtt-types/utils"; // @ts-expect-error - requires key new Setting(); diff --git a/tests/foundry/client/game.test-d.ts b/tests/foundry/client/game.test-d.ts index f1cb7585f..5946c847c 100644 --- a/tests/foundry/client/game.test-d.ts +++ b/tests/foundry/client/game.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf, assertType } from "vitest"; -import type { EmptyObject } from "../../../src/types/utils.d.mts"; +import type { EmptyObject } from "fvtt-types/utils"; declare const aGame: Game; diff --git a/tests/foundry/client/pixi/board.test-d.ts b/tests/foundry/client/pixi/board.test-d.ts index 7f8e899da..69dbfbdb6 100644 --- a/tests/foundry/client/pixi/board.test-d.ts +++ b/tests/foundry/client/pixi/board.test-d.ts @@ -1,8 +1,7 @@ import { assertType, expectTypeOf } from "vitest"; -import type { ConstructorOf } from "../../../../src/types/utils.d.mts"; const myCanvas = new Canvas(); -assertType>>>(Canvas.layers); +assertType>>(Canvas.layers); expectTypeOf(myCanvas.draw(new Scene({ name: "My Scene" }))).toEqualTypeOf>(); expectTypeOf(myCanvas.getLayerByEmbeddedName("AmbientLight")).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/core/interaction/mouse-handler.test-d.ts b/tests/foundry/client/pixi/core/interaction/mouse-handler.test-d.ts index eb02f270f..dc3e4c6fd 100644 --- a/tests/foundry/client/pixi/core/interaction/mouse-handler.test-d.ts +++ b/tests/foundry/client/pixi/core/interaction/mouse-handler.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { ValueOf } from "../../../../../../src/types/utils.d.mts"; +import type { ValueOf } from "fvtt-types/utils"; () => { const myCanvas = new Canvas(); diff --git a/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts b/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts index 3d5c3c09e..eaa619ae9 100644 --- a/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts +++ b/tests/foundry/client/pixi/layers/base/placeables-layer.test-d.ts @@ -1,8 +1,8 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollection from "../../../../../../src/foundry/common/abstract/embedded-collection.d.mts"; -import type { ConstructorOf } from "../../../../../../src/types/utils.d.mts"; import type { Container, DisplayObject } from "pixi.js"; +import EmbeddedCollection = foundry.abstract.EmbeddedCollection; + class SomeLightLayer extends PlaceablesLayer<"AmbientLight"> { static override get layerOptions() { return foundry.utils.mergeObject(super.layerOptions, { @@ -20,7 +20,7 @@ expectTypeOf(SomeLightLayer.layerOptions.objectClass).toEqualTypeOf(); // T expectTypeOf(PlaceablesLayer.documentName).toEqualTypeOf< "AmbientLight" | "AmbientSound" | "Drawing" | "MeasuredTemplate" | "Note" | "Tile" | "Token" | "Wall" >(); -expectTypeOf(PlaceablesLayer.placeableClass).toEqualTypeOf>(); +expectTypeOf(PlaceablesLayer.placeableClass).toEqualTypeOf(); const layer = new SomeLightLayer(); expectTypeOf(layer.options.objectClass).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/controls/ruler.test-d.ts b/tests/foundry/client/pixi/layers/controls/ruler.test-d.ts index 7f7f5a96c..1e080833c 100644 --- a/tests/foundry/client/pixi/layers/controls/ruler.test-d.ts +++ b/tests/foundry/client/pixi/layers/controls/ruler.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Color from "../../../../../../src/foundry/common/utils/color.d.mts"; +import Color = foundry.utils.Color; if (game instanceof Game) { expectTypeOf(new Ruler(undefined)).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/layers/effects/visibility.test-d.ts b/tests/foundry/client/pixi/layers/effects/visibility.test-d.ts index 26c3a76f8..ccdf59a89 100644 --- a/tests/foundry/client/pixi/layers/effects/visibility.test-d.ts +++ b/tests/foundry/client/pixi/layers/effects/visibility.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { ValueOf } from "../../../../../../src/types/utils.d.mts"; +import type { ValueOf } from "fvtt-types/utils"; const layer = new CanvasVisibility(); diff --git a/tests/foundry/client/pixi/layers/grid/layer.test-d.ts b/tests/foundry/client/pixi/layers/grid/layer.test-d.ts index 24c2aa8a0..02ac79698 100644 --- a/tests/foundry/client/pixi/layers/grid/layer.test-d.ts +++ b/tests/foundry/client/pixi/layers/grid/layer.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type BaseGrid from "../../../../../../src/foundry/common/grid/base.d.mts"; +import BaseGrid = foundry.documents.BaseGrid; expectTypeOf(GridLayer.instance).toEqualTypeOf(); expectTypeOf(GridLayer.layerOptions).toEqualTypeOf(); diff --git a/tests/foundry/client/pixi/perception/detection-mode.test-d.ts b/tests/foundry/client/pixi/perception/detection-mode.test-d.ts index e2439434a..9b1ef372a 100644 --- a/tests/foundry/client/pixi/perception/detection-mode.test-d.ts +++ b/tests/foundry/client/pixi/perception/detection-mode.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { ValueOf } from "../../../../../src/types/utils.d.mts"; +import type { ValueOf } from "fvtt-types/utils"; class MyDetectionMode extends DetectionMode {} diff --git a/tests/foundry/client/pixi/placeables/token.test-d.ts b/tests/foundry/client/pixi/placeables/token.test-d.ts index 43dbd4610..68a81aba7 100644 --- a/tests/foundry/client/pixi/placeables/token.test-d.ts +++ b/tests/foundry/client/pixi/placeables/token.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; const token = new Token(new TokenDocument()); expectTypeOf(token.id).toEqualTypeOf(); diff --git a/tests/foundry/client/ui/filepicker.test-d.ts b/tests/foundry/client/ui/filepicker.test-d.ts index d3bc1ed27..cf26bdf97 100644 --- a/tests/foundry/client/ui/filepicker.test-d.ts +++ b/tests/foundry/client/ui/filepicker.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { EmptyObject, MaybePromise } from "../../../../src/types/utils.d.mts"; +import type { EmptyObject, MaybePromise } from "fvtt-types/utils"; const filepicker = new FilePicker(); expectTypeOf(filepicker).toEqualTypeOf(); diff --git a/tests/foundry/common/abstract/document.mjs.test-d.ts b/tests/foundry/common/abstract/document.mjs.test-d.ts index 5e93ae282..e9f6b8ede 100644 --- a/tests/foundry/common/abstract/document.mjs.test-d.ts +++ b/tests/foundry/common/abstract/document.mjs.test-d.ts @@ -1,13 +1,11 @@ import { expectTypeOf } from "vitest"; -import type { - DatabaseCreateOperation, - DatabaseDeleteOperation, - DatabaseUpdateOperation, -} from "../../../../src/foundry/common/abstract/_types.d.mts"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; -import type { EffectChangeData } from "../../../../src/foundry/common/documents/_types.d.mts"; -import type BaseActiveEffect from "../../../../src/foundry/common/documents/active-effect.d.mts"; -import type { DatabaseOperationsFor } from "../../../../src/types/helperTypes.d.mts"; +import type { DatabaseOperationsFor } from "fvtt-types/utils"; +import Document = foundry.abstract.Document; +import DatabaseCreateOperation = Document.DatabaseCreateOperation; +import DatabaseDeleteOperation = Document.DatabaseDeleteOperation; +import DatabaseUpdateOperation = Document.DatabaseUpdateOperation; +import EffectChangeData = foundry.data.EffectChangeData; +import BaseActiveEffect = foundry.documents.BaseActiveEffect; declare const configuredActiveEffect: Document.ToConfiguredInstance; expectTypeOf(configuredActiveEffect).toEqualTypeOf(); diff --git a/tests/foundry/common/abstract/type-data.mjs.test-d.ts b/tests/foundry/common/abstract/type-data.mjs.test-d.ts index 66b357906..e78330362 100644 --- a/tests/foundry/common/abstract/type-data.mjs.test-d.ts +++ b/tests/foundry/common/abstract/type-data.mjs.test-d.ts @@ -1,8 +1,9 @@ import { expectTypeOf } from "vitest"; -import type { fields } from "../../../../src/foundry/common/data/module.d.mts"; -import type BaseJournalEntryPage from "../../../../src/foundry/common/documents/journal-entry-page.d.mts"; -import type BaseUser from "../../../../src/foundry/common/documents/user.d.mts"; -import type { DeepPartial, EmptyObject } from "../../../../src/types/utils.d.mts"; +import type { DeepPartial, EmptyObject } from "fvtt-types/utils"; + +import fields = foundry.data.fields; +import BaseUser = foundry.documents.BaseUser; +import BaseJournalEntryPage = foundry.documents.BaseJournalEntryPage; import TypeDataModel = foundry.abstract.TypeDataModel; diff --git a/tests/foundry/common/constants.test-d.ts b/tests/foundry/common/constants.test-d.ts index d6891476b..189241c7f 100644 --- a/tests/foundry/common/constants.test-d.ts +++ b/tests/foundry/common/constants.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { ValueOf } from "../../../src/types/utils.d.mts"; +import type { ValueOf } from "fvtt-types/utils"; expectTypeOf().toMatchTypeOf(); expectTypeOf().toMatchTypeOf(); diff --git a/tests/foundry/common/documents/active-effect.test-d.ts b/tests/foundry/common/documents/active-effect.test-d.ts index 33f201237..e3f823ee6 100644 --- a/tests/foundry/common/documents/active-effect.test-d.ts +++ b/tests/foundry/common/documents/active-effect.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseActiveEffect.create({})).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/actor-delta.test-d.ts b/tests/foundry/common/documents/actor-delta.test-d.ts index 2767633ea..2d5ca042c 100644 --- a/tests/foundry/common/documents/actor-delta.test-d.ts +++ b/tests/foundry/common/documents/actor-delta.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollectionDelta from "../../../../src/foundry/common/abstract/embedded-collection-delta.d.mts"; +import EmbeddedCollectionDelta = foundry.abstract.EmbeddedCollectionDelta; const myDelta = new foundry.documents.BaseActorDelta(); diff --git a/tests/foundry/common/documents/actor.test-d.ts b/tests/foundry/common/documents/actor.test-d.ts index 4b6b9941e..93c7d97f8 100644 --- a/tests/foundry/common/documents/actor.test-d.ts +++ b/tests/foundry/common/documents/actor.test-d.ts @@ -1,7 +1,9 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollection from "../../../../src/foundry/common/abstract/embedded-collection.d.mts"; -import type { NumberField, SchemaField } from "../../../../src/foundry/common/data/fields.d.mts"; -import type { AnyMutableObject, AnyObject, EmptyObject } from "../../../../src/types/utils.d.mts"; +import type { AnyMutableObject, AnyObject, EmptyObject } from "fvtt-types/utils"; +import EmbeddedCollection = foundry.abstract.EmbeddedCollection; +import fields = foundry.data.fields; +import NumberField = fields.NumberField; +import SchemaField = fields.SchemaField; import TypeDataModel = foundry.abstract.TypeDataModel; diff --git a/tests/foundry/common/documents/card.test-d.ts b/tests/foundry/common/documents/card.test-d.ts index 4866ed344..c3dc24e9b 100644 --- a/tests/foundry/common/documents/card.test-d.ts +++ b/tests/foundry/common/documents/card.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { CardFaceData } from "../../../../src/foundry/common/documents/_types.d.mts"; +import CardFaceData = foundry.types.CardFaceData; // @ts-expect-error Name is required new foundry.documents.BaseCard(); diff --git a/tests/foundry/common/documents/cards.test-d.ts b/tests/foundry/common/documents/cards.test-d.ts index 95bcb2af4..0e6f36a76 100644 --- a/tests/foundry/common/documents/cards.test-d.ts +++ b/tests/foundry/common/documents/cards.test-d.ts @@ -1,6 +1,8 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollection from "../../../../src/foundry/common/abstract/embedded-collection.d.mts"; -import type { CardData, CardFaceData } from "../../../../src/foundry/common/documents/_types.d.mts"; + +import EmbeddedCollection = foundry.abstract.EmbeddedCollection; +import CardData = foundry.documents.CardData; +import CardFaceData = foundry.types.CardFaceData; // @ts-expect-error data argument is non-optional const baseCards = new foundry.documents.BaseCards(); diff --git a/tests/foundry/common/documents/chat-message.test-d.ts b/tests/foundry/common/documents/chat-message.test-d.ts index b314851f3..ee21f1f86 100644 --- a/tests/foundry/common/documents/chat-message.test-d.ts +++ b/tests/foundry/common/documents/chat-message.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseChatMessage.create({})).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/combat.test-d.ts b/tests/foundry/common/documents/combat.test-d.ts index 3335354d1..168f782fb 100644 --- a/tests/foundry/common/documents/combat.test-d.ts +++ b/tests/foundry/common/documents/combat.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; new foundry.documents.BaseCombat(); diff --git a/tests/foundry/common/documents/combatant.test-d.ts b/tests/foundry/common/documents/combatant.test-d.ts index 2633cb8bb..5dcfc6e2b 100644 --- a/tests/foundry/common/documents/combatant.test-d.ts +++ b/tests/foundry/common/documents/combatant.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseCombatant.create({ actorId: "someID", tokenId: "someOtherId" })).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/drawing.test-d.ts b/tests/foundry/common/documents/drawing.test-d.ts index f360508f3..f4001158d 100644 --- a/tests/foundry/common/documents/drawing.test-d.ts +++ b/tests/foundry/common/documents/drawing.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseDrawing.create({})).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/fog-exploration.test-d.ts b/tests/foundry/common/documents/fog-exploration.test-d.ts index 4d4d8c88e..9c24bad15 100644 --- a/tests/foundry/common/documents/fog-exploration.test-d.ts +++ b/tests/foundry/common/documents/fog-exploration.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(new foundry.documents.BaseFogExploration()).toEqualTypeOf(); expectTypeOf(new foundry.documents.BaseFogExploration({})).toEqualTypeOf(); diff --git a/tests/foundry/common/documents/folder.test-d.ts b/tests/foundry/common/documents/folder.test-d.ts index 2521a6386..49cc37277 100644 --- a/tests/foundry/common/documents/folder.test-d.ts +++ b/tests/foundry/common/documents/folder.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseFolder.create({ name: "Some Folder", type: "Item" })).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/item.test-d.ts b/tests/foundry/common/documents/item.test-d.ts index 609c70682..d7a144e23 100644 --- a/tests/foundry/common/documents/item.test-d.ts +++ b/tests/foundry/common/documents/item.test-d.ts @@ -1,7 +1,6 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollection from "../../../../src/foundry/common/abstract/embedded-collection.d.mts"; -import type { AnyObject } from "../../../../src/types/utils.d.mts"; - +import type { AnyObject } from "fvtt-types/utils"; +import EmbeddedCollection = foundry.abstract.EmbeddedCollection; import BaseItem = foundry.documents.BaseItem; import Document = foundry.abstract.Document; diff --git a/tests/foundry/common/documents/journal-entry.test-d.ts b/tests/foundry/common/documents/journal-entry.test-d.ts index 2d69e3351..30c74e2a8 100644 --- a/tests/foundry/common/documents/journal-entry.test-d.ts +++ b/tests/foundry/common/documents/journal-entry.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseJournalEntry.create({ name: "Some JournalEntry" })).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/scene.test-d.ts b/tests/foundry/common/documents/scene.test-d.ts index b88ced56b..7f8e373bd 100644 --- a/tests/foundry/common/documents/scene.test-d.ts +++ b/tests/foundry/common/documents/scene.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; -import type EmbeddedCollection from "../../../../src/foundry/common/abstract/embedded-collection.d.mts"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import EmbeddedCollection = foundry.abstract.EmbeddedCollection; +import Document = foundry.abstract.Document; // @ts-expect-error - A BaseScene requires data. foundry.documents.BaseScene.create(); diff --git a/tests/foundry/common/documents/setting.test-d.ts b/tests/foundry/common/documents/setting.test-d.ts index 8b3fbfc86..638835c83 100644 --- a/tests/foundry/common/documents/setting.test-d.ts +++ b/tests/foundry/common/documents/setting.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseSetting.create({ key: "foo.bar", value: "bar" })).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/documents/user.test-d.ts b/tests/foundry/common/documents/user.test-d.ts index 3bba012a7..92526c263 100644 --- a/tests/foundry/common/documents/user.test-d.ts +++ b/tests/foundry/common/documents/user.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type Document from "../../../../src/foundry/common/abstract/document.d.mts"; +import Document = foundry.abstract.Document; expectTypeOf(foundry.documents.BaseUser.create({ name: "SomeUser" })).toEqualTypeOf< Promise | undefined> diff --git a/tests/foundry/common/packages/base-module.mjs.test-d.ts b/tests/foundry/common/packages/base-module.mjs.test-d.ts index 65676c3f8..09485c864 100644 --- a/tests/foundry/common/packages/base-module.mjs.test-d.ts +++ b/tests/foundry/common/packages/base-module.mjs.test-d.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "vitest"; -import type { AnyObject } from "../../../../src/types/utils.d.mts"; -import type AdditionalTypesField from "../../../../src/foundry/common/packages/sub-types.d.mts"; +import type { AnyObject } from "fvtt-types/utils"; +import AdditionalTypesField = foundry.common.packages.subTypes.AdditionalTypesField; const mySystem = new foundry.packages.BaseModule({ changelog: "Test", diff --git a/tests/foundry/common/packages/base-package.mjs.test-d.ts b/tests/foundry/common/packages/base-package.mjs.test-d.ts index f0dbdfdfe..85f75710a 100644 --- a/tests/foundry/common/packages/base-package.mjs.test-d.ts +++ b/tests/foundry/common/packages/base-package.mjs.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { CompendiumOwnershipField } from "../../../../src/foundry/common/packages/base-package.d.mts"; +import CompendiumOwnershipField = foundry.common.packages.CompendiumOwnershipField; const myPackage = new foundry.packages.BasePackage({ id: "foobar", diff --git a/tests/foundry/common/packages/base-world.mjs.test-d.ts b/tests/foundry/common/packages/base-world.mjs.test-d.ts index ee616da34..c7f59930d 100644 --- a/tests/foundry/common/packages/base-world.mjs.test-d.ts +++ b/tests/foundry/common/packages/base-world.mjs.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from "vitest"; -import type { DataModelValidationFailure } from "../../../../src/foundry/common/data/validation-failure.d.mts"; +import DataModelValidationFailure = foundry.data.DataModelValidationFailure; const myWorld = new foundry.packages.BaseWorld({ changelog: "Test", diff --git a/tests/foundry/common/prosemirror/prosemirror.test-d.ts b/tests/foundry/common/prosemirror/prosemirror.test-d.ts index 65ba23e4f..2681ddd38 100644 --- a/tests/foundry/common/prosemirror/prosemirror.test-d.ts +++ b/tests/foundry/common/prosemirror/prosemirror.test-d.ts @@ -1,7 +1,6 @@ import type { Schema } from "prosemirror-model"; import type { EditorState } from "prosemirror-state"; import { expectTypeOf } from "vitest"; -import "../../../../src/foundry/common/prosemirror/index.d.mts"; expectTypeOf(ProseMirror.EditorState).toEqualTypeOf(); expectTypeOf(ProseMirror.Schema).toEqualTypeOf(); diff --git a/tests/foundry/common/utils/helpers.mjs.test-d.ts b/tests/foundry/common/utils/helpers.mjs.test-d.ts index b9d7de23f..0b6ab0d29 100644 --- a/tests/foundry/common/utils/helpers.mjs.test-d.ts +++ b/tests/foundry/common/utils/helpers.mjs.test-d.ts @@ -1,5 +1,5 @@ import { expectTypeOf, assertType } from "vitest"; -import type { AnyFunction, NonNullish } from "../../../../src/types/utils.d.mts"; +import type { AnyFunction, NonNullish } from "fvtt-types/utils"; // Global export test expectTypeOf(benchmark).toEqualTypeOf(foundry.utils.benchmark); diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 2a8a1d833..9868d1771 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -2,11 +2,12 @@ "$schema": "https://json.schemastore.org/tsconfig.json", "extends": "../tsconfig.json", "compilerOptions": { + "types": ["fvtt-types"], "outDir": ".typescript-build", "composite": true, "noEmit": false, "emitDeclarationOnly": true, - "typeRoots": ["../node_modules/@fvtt-types"] + "typeRoots": ["../node_modules"] }, "include": ["**/*.test-d.ts", "**/*.d.ts"] } diff --git a/tests/types/utils.test-d.ts b/tests/types/utils.test-d.ts index 61af8ac3c..5a75dfa0b 100644 --- a/tests/types/utils.test-d.ts +++ b/tests/types/utils.test-d.ts @@ -1,6 +1,6 @@ import { assertType, expectTypeOf } from "vitest"; -import type { DeepPartial, Expanded, MaybePromise, RequiredProps, Titlecase } from "../../src/types/utils.d.mts"; -import type Document from "../../src/foundry/common/abstract/document.d.mts"; +import type { DeepPartial, Expanded, MaybePromise, RequiredProps, Titlecase } from "fvtt-types/utils"; +import Document = foundry.abstract.Document; declare const membersBecomeOptional: DeepPartial<{ a: string }>; expectTypeOf(membersBecomeOptional).toEqualTypeOf<{ a?: string }>(); diff --git a/tsconfig.json b/tsconfig.json index 3e96ceb7a..f4ada451d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,8 @@ "strict": true, "target": "ES2021", "verbatimModuleSyntax": true, - "noUncheckedSideEffectImports": true + "noUncheckedSideEffectImports": true, + "baseUrl": "./" }, "include": ["index.d.mts"],