Skip to content

Commit

Permalink
Still-failing CreateOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMeehan committed Dec 14, 2023
1 parent b7ac207 commit b434b7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/foundry/client/pixi/webgl/shaders/filters/filters.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ declare global {

type FilterMode = ValueOf<(typeof VisualEffectsMaskingFilter)["FILTER_MODES"]>;

type CreateOptions = {
/**
* @privateRemarks Attempting to implement https://stackoverflow.com/a/61434547
*/
type CreateOptionsIntersection = {
filterMode?: FilterMode;
postProcessModes?: PostProcessModes;
} & AbstractBaseShader.Uniforms;

type CreateOptions<T> = {
filterMode?: FilterMode;
postProcessModes?: PostProcessModes;
} & {
[K in keyof T]: K extends "filterMode" | "postProcessModes" ? unknown : AbstractBaseShader.UniformValue;
};
}

/**
Expand All @@ -95,9 +105,13 @@ declare global {
filterMode: VisualEffectsMaskingFilter.FilterMode,
);

static create<T1 extends VisualEffectsMaskingFilter, T2 extends VisualEffectsMaskingFilter.CreateOptions<T2>>(
this: ConstructorOf<T1>,
{ filterMode, postProcessModes, ...uniforms }?: T2,
): T1;
static create<T extends VisualEffectsMaskingFilter>(
this: ConstructorOf<T>,
{ filterMode, postProcessModes, ...uniforms }?: VisualEffectsMaskingFilter.CreateOptions,
{ filterMode, postProcessModes, ...uniforms }?: VisualEffectsMaskingFilter.CreateOptionsIntersection,
): T;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/foundry/client/pixi/webgl/filters.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ expectTypeOf(CustomMaskFilter.create()).toEqualTypeOf<CustomMaskFilter>();

expectTypeOf(InverseOcclusionMaskFilter.create()).toEqualTypeOf<InverseOcclusionMaskFilter>();

const x: VisualEffectsMaskingFilter.CreateOptions = {
const x = {
filterMode: "background",
postProcessModes: ["CONTRAST"],
foobar: 3,
Expand Down

0 comments on commit b434b7f

Please sign in to comment.