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

fix: form-associated base classes need stubs for mixin classes with private/protected members #5061

Closed
radium-v opened this issue Aug 14, 2021 · 3 comments
Labels
area:fast-foundation Pertains to fast-foundation closed:obsolete No longer valid improvement A non-feature-adding improvement status:needs-investigation Needs additional investigation

Comments

@radium-v
Copy link
Collaborator

🐛 Bug Report

Any form-associated components that use the FormAssociated() mixin function require the use of a stub class and interface for TypeScript to properly handle private/protected members.

💻 Repro or Code Sample

Ideally, we'd be able to create these stubs for form-associated components:

import { FormAssociated } from "../form-associated/form-associated";
import { FoundationElement } from "../foundation-element";

export class FormAssociatedComponent extends FormAssociated(
    class extends FoundationElement {
        public proxy: HTMLInputElement = document.createElement("input");
    }
) {}

export interface FormAssociatedComponent extends FormAssociated {}

😯 Current Behavior

TS throws errors on the properties in FoundationElement which are private or protected:

error TS4094: Property '$presentation' of exported class expression may not be private or protected.
error TS4094: Property '_presentation' of exported class expression may not be private or protected.
error TS4094: Property 'stylesChanged' of exported class expression may not be private or protected.
error TS4094: Property 'templateChanged' of exported class expression may not be private or protected.

💁 Solution

The workaround for this bug requires creating an empty base class which extends FoundationElement (or the base component class, ex. Listbox) and its interface which extends FormAssociated. This class should be passed to the FormAssociated() function. The proxy property should then be defined in the class body instead of in the stub class.

import { FormAssociated } from "../form-associated/form-associated";
import { FoundationElement } from "../foundation-element";

class _Component extends FoundationElement {}
interface _Component extends FormAssociated {}

export class FormAssociatedComponent extends FormAssociated(_Component) {
    public proxy: HTMLInputElement = document.createElement("input");
}

export interface FormAssociatedComponent extends FormAssociated {}

🔦 Context

microsoft/TypeScript#30355
microsoft/TypeScript#36060
microsoft/TypeScript#17744 (comment)

@radium-v radium-v added the status:triage New Issue - needs triage label Aug 14, 2021
@EisenbergEffect EisenbergEffect added area:fast-components area:fast-foundation Pertains to fast-foundation improvement A non-feature-adding improvement status:needs-investigation Needs additional investigation and removed status:triage New Issue - needs triage labels Aug 16, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the warning:stale No recent activity within a reasonable amount of time label Apr 16, 2022
@radium-v
Copy link
Collaborator Author

This might be actionable once #5788 goes in.

@stale stale bot removed the warning:stale No recent activity within a reasonable amount of time label Apr 21, 2022
@janechu
Copy link
Collaborator

janechu commented May 29, 2024

Unfortunately @microsoft/fast-components has been deprecated for some time and @microsoft/fast-foundation is being deprecated per #6955.

@janechu janechu closed this as completed May 29, 2024
@janechu janechu added the closed:obsolete No longer valid label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fast-foundation Pertains to fast-foundation closed:obsolete No longer valid improvement A non-feature-adding improvement status:needs-investigation Needs additional investigation
Projects
None yet
Development

No branches or pull requests

3 participants