Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate static returns of ClientDocumentMixin #7063

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Generate static returns of ClientDocumentMixin
plus modest Foundry types refactor and dependency upgrade to typescript 5.0.2
  • Loading branch information
stwlam committed Mar 21, 2023
commit c6e771fc6f309d67cd687dbe10469433cba79e09
35 changes: 6 additions & 29 deletions .betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,13 @@
//
exports[`too-much-lint`] = {
value: `{
"types/foundry/client/application/form-application/document-sheet/actor-sheet.d.ts:4046500136": [
[8, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
[9, 14, 3, "Unexpected any. Specify a different type.", "193409811"],
[10, 15, 3, "Unexpected any. Specify a different type.", "193409811"]
"types/foundry/client/application/form-application/document-sheet/actor-sheet.d.ts:2380220550": [
[9, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
[10, 14, 3, "Unexpected any. Specify a different type.", "193409811"],
[11, 15, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/client/collections/compendium-collection.d.ts:775132723": [
[246, 23, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/client/documents/mixins/canvas-document-mixin.d.ts:3303075782": [
[16, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
[21, 57, 3, "Unexpected any. Specify a different type.", "193409811"],
[54, 57, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/client/documents/mixins/client-document-mixin.d.ts:1499800974": [
[8, 18, 3, "Unexpected any. Specify a different type.", "193409811"],
[65, 43, 3, "Unexpected any. Specify a different type.", "193409811"],
[309, 44, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/client/pixi/placeables-layer/base.d.ts:7710705": [
[134, 20, 3, "Unexpected any. Specify a different type.", "193409811"],
[158, 20, 3, "Unexpected any. Specify a different type.", "193409811"],
[164, 31, 3, "Unexpected any. Specify a different type.", "193409811"],
[174, 25, 3, "Unexpected any. Specify a different type.", "193409811"],
[174, 42, 3, "Unexpected any. Specify a different type.", "193409811"],
[174, 56, 3, "Unexpected any. Specify a different type.", "193409811"],
[186, 44, 3, "Unexpected any. Specify a different type.", "193409811"],
[186, 58, 3, "Unexpected any. Specify a different type.", "193409811"]
"types/foundry/client/collections/compendium-collection.d.ts:447575351": [
[251, 23, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/client/ui/filepicker.d.ts:274431795": [
[9, 13, 3, "Unexpected any. Specify a different type.", "193409811"],
Expand All @@ -44,9 +24,6 @@ exports[`too-much-lint`] = {
[128, 45, 3, "Unexpected any. Specify a different type.", "193409811"],
[138, 36, 3, "Unexpected any. Specify a different type.", "193409811"],
[143, 44, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"types/foundry/common/abstract/data.d.ts:2798586197": [
[25, 34, 3, "Unexpected any. Specify a different type.", "193409811"]
]
}`
};
175 changes: 96 additions & 79 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@
"@types/jquery": "^3.5.16",
"@types/jsdom": "^21.1.0",
"@types/luxon": "^3.2.0",
"@types/node": "^18.15.3",
"@types/node": "^18.15.5",
"@types/sortablejs": "^1.15.1",
"@types/tooltipster": "^0.0.31",
"@types/webpack-env": "^1.18.0",
"@types/yaireo__tagify": "^4.16.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"css-minimizer-webpack-plugin": "^4.2.2",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"fs-extra": "^11.1.0",
"glob": "^9.3.0",
"fs-extra": "^11.1.1",
"glob": "^9.3.1",
"gsap": "^3.11.0",
"handlebars": "4.7.7",
"jest": "^29.5.0",
"jest-each": "^29.5.0",
"mini-css-extract-plugin": "^2.7.5",
"null-loader": "^4.0.1",
"pixi.js": "6.5.2",
"prettier": "^2.8.4",
"prettier": "^2.8.5",
"raw-loader": "^4.0.2",
"sass": "^1.59.3",
"sass-loader": "^13.2.0",
"sass-loader": "^13.2.1",
"simple-progress-webpack-plugin": "^2.0.0",
"socket.io": "4.5.1",
"socket.io-client": "4.5.1",
Expand All @@ -73,10 +73,10 @@
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.5",
"typescript": "^5.0.2",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.12.0",
"webpack-dev-server": "^4.13.1",
"webpack-import-glob-loader": "^1.6.3",
"write-file-webpack-plugin": "^4.5.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packs/scripts/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const npcSystemKeys = new Set([

const idsToNames: Map<string, Map<string, string>> = new Map();

type CompendiumDocumentPF2e = ActorPF2e | ItemPF2e | JournalEntry | MacroPF2e | RollTable;
type CompendiumDocumentPF2e = ActorPF2e | ItemPF2e<ActorPF2e | null> | JournalEntry | MacroPF2e | RollTable;
type PackEntry = CompendiumDocumentPF2e["_source"];

function assertDocIdSame(newSource: PackEntry, jsonPath: string): void {
Expand Down
12 changes: 6 additions & 6 deletions packs/scripts/run-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ const isJournalEntryData = (docSource: CompendiumSource): docSource is foundry.d
return "pages" in docSource && Array.isArray(docSource.pages);
};

const isMacroData = (docSource: CompendiumSource): docSource is foundry.data.MacroSource => {
const isMacroData = (docSource: CompendiumSource): docSource is foundry.documents.MacroSource => {
return "type" in docSource && ["chat", "script"].includes(docSource.type);
};

const isTableData = (docSource: CompendiumSource): docSource is foundry.data.RollTableSource => {
const isTableData = (docSource: CompendiumSource): docSource is foundry.documents.RollTableSource => {
return "results" in docSource && Array.isArray(docSource.results);
};

Expand Down Expand Up @@ -201,8 +201,8 @@ async function migrate() {
| ActorSourcePF2e
| ItemSourcePF2e
| foundry.documents.JournalEntrySource
| foundry.data.MacroSource
| foundry.data.RollTableSource;
| foundry.documents.MacroSource
| foundry.documents.RollTableSource;
try {
// Parse file content
source = JSON.parse(content);
Expand All @@ -217,8 +217,8 @@ async function migrate() {
| ActorSourcePF2e
| ItemSourcePF2e
| foundry.documents.JournalEntrySource
| foundry.data.MacroSource
| foundry.data.RollTableSource
| foundry.documents.MacroSource
| foundry.documents.RollTableSource
> => {
source.flags ??= {};
try {
Expand Down
38 changes: 26 additions & 12 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActorPF2e } from "@actor/base";
import { AutomaticBonusProgression } from "@actor/character/automatic-bonus-progression";
import { FeatCategoryOptions } from "@actor/character/feats";
import { CheckModifier, ModifierPF2e, MODIFIER_TYPE, StatisticModifier } from "@actor/modifiers";
import { CheckModifier, MODIFIER_TYPE, ModifierPF2e, StatisticModifier } from "@actor/modifiers";
import { ItemPF2e } from "@item/base";
import { CoinsPF2e } from "@item/physical/helpers";
import { ActiveEffectPF2e } from "@module/active-effect";
Expand Down Expand Up @@ -48,14 +48,14 @@ import { ConditionManager } from "./module/system/conditions";

declare global {
interface Game<
TActor extends Actor,
TActor extends Actor<null>,
TActors extends Actors<TActor>,
TChatMessage extends ChatMessage<TActor>,
TChatMessage extends ChatMessage,
TCombat extends Combat,
TItem extends Item<TActor>,
TItem extends Item<null>,
TMacro extends Macro,
TScene extends Scene,
TUser extends User<TActor>
TUser extends User
> {
pf2e: {
actions: Record<string, Function>;
Expand Down Expand Up @@ -111,10 +111,25 @@ declare global {

namespace globalThis {
// eslint-disable-next-line no-var
var game: Game<ActorPF2e, ActorsPF2e, ChatMessagePF2e, EncounterPF2e, ItemPF2e, MacroPF2e, ScenePF2e, UserPF2e>;
var game: Game<
ActorPF2e<null>,
ActorsPF2e<ActorPF2e<null>>,
ChatMessagePF2e,
EncounterPF2e,
ItemPF2e<null>,
MacroPF2e,
ScenePF2e,
UserPF2e
>;

// eslint-disable-next-line no-var
var ui: FoundryUI<ActorPF2e, ActorDirectoryPF2e<ActorPF2e>, ItemPF2e, ChatLogPF2e, CompendiumDirectoryPF2e>;
var ui: FoundryUI<
ActorPF2e<null>,
ActorDirectoryPF2e<ActorPF2e<null>>,
ItemPF2e<null>,
ChatLogPF2e,
CompendiumDirectoryPF2e
>;
}

interface Window {
Expand Down Expand Up @@ -201,14 +216,13 @@ declare global {
}

type ConfiguredConfig = Config<
AmbientLightDocumentPF2e,
ActiveEffectPF2e,
AmbientLightDocumentPF2e<ScenePF2e | null>,
ActiveEffectPF2e<ActorPF2e | ItemPF2e | null>,
ActorPF2e,
ActorDirectoryPF2e<ActorPF2e>,
ChatLogPF2e,
ChatMessagePF2e,
EncounterPF2e,
CombatantPF2e,
CombatantPF2e<EncounterPF2e | null, TokenDocumentPF2e>,
EncounterTrackerPF2e<EncounterPF2e | null>,
CompendiumDirectoryPF2e,
HotbarPF2e,
Expand All @@ -219,6 +233,6 @@ type ConfiguredConfig = Config<
TokenDocumentPF2e,
WallDocument<ScenePF2e | null>,
ScenePF2e,
UserPF2e<ActorPF2e>,
UserPF2e,
EffectsCanvasGroupPF2e
>;
8 changes: 5 additions & 3 deletions src/module/active-effect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ActorPF2e, ItemPF2e } from "./documents";

/** Disable Active Effects */
export class ActiveEffectPF2e extends ActiveEffect {
export class ActiveEffectPF2e<TParent extends ActorPF2e | ItemPF2e | null> extends ActiveEffect<TParent> {
constructor(
data: DeepPartial<foundry.data.ActiveEffectSource>,
context?: DocumentConstructionContext<ActiveEffectPF2e["parent"]>
data: DeepPartial<foundry.documents.ActiveEffectSource>,
context?: DocumentConstructionContext<TParent>
) {
data.disabled = true;
data.transfer = false;
Expand Down
Loading