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

TypeScript definitions for config & lifecycles #311

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

jpage-godaddy
Copy link
Contributor

Summary

  • Create types for the core gasket engine
  • Create core interfaces which plugins can extend
  • Add config & lifecycle typings for all plugins
  • Add unit tests to check that type validation works

Changelog

TBD

};

type HttpsSettings =
& CustomHttpsSettings
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be something before the & or is this a typescript syntax that I'm not familiar with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's something TypeScript supports. | as well. It's just a syntax thing that lets you do a list of unions/intersections in a nicer-looking way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, that's fine. I'm just surprised that a leading & is allowed. I'd have expected something more like:

type HttpsSettings =
  CustomHttpsSettings &
  Omit<
     SecureContextOptions,
     keyof CustomHttpsSettings | 'secureProtocol' | 'secureOptions'
     >;

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can lint on code styles here (see comment).

@@ -33,13 +34,16 @@
},
"homepage": "https://github.com/godaddy/gasket/tree/master/packages/gasket-plugin-service-worker#readme",
"dependencies": {
"@types/lru-cache": "^5.1.1",
"@types/uglify-js": "^3.13.1",
"deepmerge": "^4.2.2",
"lru-cache": "^5.1.1",
"mkdirp": "^0.5.1",
"uglify-js": "^3.5.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to this PR, but @kinetifex -- should this move to terser?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be updated, but we'll probably go with swc modification.

Copy link
Contributor

@kinetifex kinetifex left a comment

Choose a reason for hiding this comment

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

Very cool and thorough @jpage-godaddy! There are some lifecycles that are executed from the @gasket/cli package that were missed. Also, what are you thinking for the non-plugin packages? - Not going to block on those for the PR, but it'd be good to have follow-up tickets/issues so we do not lose track.

The only thing blocking really is just marking the test package as private. Besides that, some possible lint cleanup, and what are your thoughts on a follow-up to include .ts type files with our linting rules?

@jpage-godaddy
Copy link
Contributor Author

There are some lifecycles that are executed from the @gasket/cli package that were missed.

Thanks. Added those.

Also, what are you thinking for the non-plugin packages?

It can be much the same, just adding to a .d.ts (or converting the package to TypeScript and auto-generating that, which is easier IMO). Could be pretty incremental, maybe could have a ticket per package?

The only thing blocking really is just marking the test package as private.

Fixed.

...what are your thoughts on a follow-up to include .ts type files with our linting rules?

If eslint supports that sure! I'd think we'd have to switch to eslint-config-godaddy-typescript or similar in order for TypeScript to be recognized, but I don't know how well that works when the majority of the codebase is not TypeScript.

@kawikabader kawikabader changed the base branch from master to main January 6, 2022 15:38
- Create types for the core gasket engine
- Create core interfaces which plugins can extend
- Add config & lifecycle typings for all plugins
- Add unit tests to check that type validation works
- Get everything on the same jest version
- Fix `@gasket/redux` test
@kinetifex kinetifex merged commit a2d3ecb into godaddy:main Jan 6, 2022
@jpage-godaddy jpage-godaddy deleted the type-decls branch January 6, 2022 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants