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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CSS Style Declaration types to support latest TypeScript #773

Merged
merged 1 commit into from
Aug 1, 2020
Merged

Refactor CSS Style Declaration types to support latest TypeScript #773

merged 1 commit into from
Aug 1, 2020

Conversation

BarryThePenguin
Copy link
Contributor

I saw a note in your Chagelog about #757

This PR is an attempt at solving any issues caused by the latest version of TypeScript 馃檲

Happy to make any changes needed 馃憢

Comment on lines +27 to +29
type CSSStyleDeclarationProperty = keyof CSSStyleDeclaration;

type ActualCSSStyleDeclaration = Partial<Record<CSSStyleDeclarationProperty, unknown>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CSSStyleDeclaration requires all properties to be defined

Using Partial allows the assertions to define a subset of CSSStyleDeclaration properties

Using unknown here allows us to get around the issue of CSSStyleDeclaration having properties like readonly length: number; and readonly parentRule: CSSRule | null;

Really, they can be anything as they're passed in by tests as expectedProperties

message?: string
): DOMAssertions {
let element = this.findTargetElement();
if (!element) return this;

let computedStyle = window.getComputedStyle(element, selector);
let expectedProperties = Object.keys(expected) as [keyof CSSStyleDeclaration];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[keyof CSSStyleDeclaration] indicates an array with a single item of keyof CSSStyleDeclaration

Is that deliberate?

@Turbo87 Turbo87 changed the title refactor: CSS Style Declaration types to support latest TypeScript Refactor CSS Style Declaration types to support latest TypeScript Aug 1, 2020
Copy link
Collaborator

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

looks good, thanks! 馃憤

@Turbo87 Turbo87 merged commit a4eb05e into mainmatter:master Aug 1, 2020
@BarryThePenguin BarryThePenguin deleted the refactor/css-declaration-types branch September 18, 2020 03:16
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

2 participants