Skip to content

Commit

Permalink
Merge pull request #1182 from UFOMelkor/core-flag-config
Browse files Browse the repository at this point in the history
Moves core flags for ActiveEffect to ActiveEffectData
  • Loading branch information
ghost91- authored Sep 18, 2021
2 parents ee1e63c + 47326ab commit 48e4789
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/foundry/common/data/data.mjs/activeEffectData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ interface ActiveEffectDataSchema extends DocumentSchema {
flags: typeof fields.OBJECT_FIELD; // TODO: add more concrete object type
}

interface CoreFlags {
core?: { statusId?: string; overlay?: boolean };
}

interface ActiveEffectDataProperties {
/**
* The _id which uniquely identifies the ActiveEffect within a parent Actor or Item
Expand Down Expand Up @@ -79,7 +83,7 @@ interface ActiveEffectDataProperties {
* An object of optional key/value flags
* @defaultValue `{}`
*/
flags: ConfiguredFlags<'ActiveEffect'>;
flags: ConfiguredFlags<'ActiveEffect'> & CoreFlags;
}

interface ActiveEffectDataConstructorData {
Expand Down Expand Up @@ -135,7 +139,7 @@ interface ActiveEffectDataConstructorData {
* An object of optional key/value flags
* @defaultValue `{}`
*/
flags?: ConfiguredFlags<'ActiveEffect'> | null;
flags?: (ConfiguredFlags<'ActiveEffect'> & CoreFlags) | null;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/foundry/foundry.js/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,8 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface SourceConfig {}

interface FlagConfig {
ActiveEffect: {
core?: {
statusId?: string;
overlay?: boolean;
};
};
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface FlagConfig {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface WebRTCConfig {}
Expand Down
11 changes: 11 additions & 0 deletions test-d/foundry/foundry.js/clientDocuments/activeEffect.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import { expectError, expectType } from 'tsd';

const eff = new ActiveEffect({});

declare global {
interface FlagConfig {
ActiveEffect: {
mySystem?: {
importantFlag?: boolean;
};
};
}
}

expectType<boolean | undefined>(eff.getFlag('mySystem', 'importantFlag'));
expectType<string | undefined>(eff.getFlag('core', 'statusId'));
expectType<boolean | undefined>(eff.getFlag('core', 'overlay'));
expectError(eff.setFlag('core', 'statusId', 0));
Expand Down

0 comments on commit 48e4789

Please sign in to comment.