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

feat: add types #155

Merged
merged 3 commits into from Jan 7, 2022
Merged

feat: add types #155

merged 3 commits into from Jan 7, 2022

Conversation

ludofischer
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

@ludofischer ludofischer left a comment

Choose a reason for hiding this comment

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

It's the first time I convert so much code with JSDoc. Possibly uncovered one bug in the process, but I find all these types add a lot of noise.

isValueType(item.node.type) && item.node.value === 0);
withoutZeroItem.unshift(firstZeroItem)
isValueType(item.node) && item.node.value === 0);
withoutZeroItem.unshift(/** @type Collectible*/(firstZeroItem))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Potential bug? I don't see why firstZeroItem could not be undefined. Without this case TypeScript complains every time you get an element out of collected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, but firstZeroItem can be undefined, we should add check firstNonZeroItem && firstNonZeroItem.preOperator === '-', but it is regarding how ts do checks, because logic is fine here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've replaced the cast with checking if firstZeroItem is truthy before unshifting it. It makes no sense no add an undefined or null item to the array anyway.

src/lib/reducer.js Show resolved Hide resolved
src/lib/transform.js Show resolved Hide resolved
@@ -70,8 +88,11 @@ export default (node, property, options, result) => {
? transformSelector(node[property], options, result, node)
: transformValue(node[property], options, result, node);
} catch (error) {
result.warn(error.message, { node });

if (error instanceof Error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a way to avoid this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using as//** @type {Error} **/ (error)

src/lib/transform.js Show resolved Hide resolved
src/lib/reducer.js Show resolved Hide resolved
@ludofischer ludofischer marked this pull request as ready for review January 4, 2022 23:31
types/index.d.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexander-akait alexander-akait 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 👍

@ludofischer
Copy link
Collaborator Author

I've added PostCssCalcOptions type as you requested, so I think it should be good to merge.

@ludofischer ludofischer merged commit 4c96c79 into master Jan 7, 2022
@ludofischer ludofischer deleted the typescript branch January 7, 2022 11:27
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.

None yet

2 participants