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

Introduce plugin signatures #39

Merged
merged 13 commits into from
Oct 19, 2022
Merged

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Oct 18, 2022

This was originally implemented here, but was extracted due to being a (required) side-quest of that PR in order to support that PR's original goal.

This PR changes the type arguments for all plugins to use a single type argument, called Signature, inline with (Modifiers / Helpers / Components / Resources)' nomenclature.

Docs: https://34dd5187.ember-headless-table.pages.dev/api/interfaces/plugins.PluginSignature (hash might change)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 18, 2022

// A Real plugin
//////////////////////////////////////////////

import { DataSorting } from '../../plugins/data-sorting';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what allows you to declare imports not at the top of the file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the import linting plugin (same as we use internally) starts a new set of groups after a comment

expectTypeOf<OptionsFor<FullFreeformSignature>>().toEqualTypeOf<AOptions>();
expectTypeOf<TableMetaFor<FullFreeformSignature>>().toEqualTypeOf<ATableMeta>();
expectTypeOf<ColumnMetaFor<FullFreeformSignature>>().toEqualTypeOf<AColumnMeta>();
expectTypeOf<RowMetaFor<FullFreeformSignature>>().toEqualTypeOf<ARowMeta>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type testing is quite interesting... Are there any good resources on the philosophy behind them, best practices, etc? Or do we wait for you to give a talk on it? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, tbh. I learned everything from

/**
* @public
*
* utility class to help with autocompletion / documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

new (...args: Args): T;
}
export type Constructor<T, Args extends any[] = any[]> = new (...args: Args) => T;
// export type Constructor<T, Args extends any[] = any[]> = abstract new (...args: Args) => T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented line. Remove? or if not, add comment to explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! yup, this can be removed

let result = this.plugins.find((plugin) => plugin instanceof klass);

/**
* This is an unsafe cast, because Instance could be unrelated to any of the types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so... if it's unsafe, can we explain why we are doing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added more explanation! thanks!

@danwenzel
Copy link
Contributor

Really nice improvements here!

So what will the migration path look like for someone upgrading to this version? I'm assuming this'll be a major bump, right?

@@ -48,14 +48,22 @@ export interface TableOptions {
handlePosition?: string;
}

interface Signature {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer to read!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

* When interacting with preferences, the value stored in preferenced
* will be the inverse of this value (to save space in storage).
*/
isVisible?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this example of custom Column options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! 🎉

Copy link
Contributor

@ynotdraw ynotdraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Co-authored-by: Dan Wenzel <dan@danwenzel.com>
@NullVoxPopuli
Copy link
Contributor Author

So what will the migration path look like for someone upgrading to this version? I'm assuming this'll be a major bump, right?

Naw, internally what I've been doing is:

  • release initial version in OSS (1.0.0)
  • setup PR that uses the OSS version (we use * internally to mean "latest", so our lockfile ends up pointing at the correct registry with this type of change)
  • merge
  • delete package in internal registry

@NullVoxPopuli NullVoxPopuli merged commit 907b9bc into main Oct 19, 2022
@NullVoxPopuli NullVoxPopuli deleted the introduce-plugin-signatures branch October 19, 2022 16:13
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants