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

Add Type Coverage Checker #11

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ jobs:
run: npm run lint
- name: Unit Test
run: npm run test
- name: Type Coverage
run: npm run type-coverage
- name: Build
run: npm run build
32 changes: 31 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"lint:js:fix": "turbo run lint:js:fix",
"test": "turbo run test",
"test:unit": "turbo run test:unit",
"test:snapshots": "turbo run test:snapshots"
"test:snapshots": "turbo run test:snapshots",
"type-coverage": "turbo run type-coverage"
},
"devDependencies": {
"turbo": "^1.13.3"
Expand Down
6 changes: 4 additions & 2 deletions packages/iconography/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"test": "wp-scripts test-unit-js",
"test:snapshots": "wp-scripts test-unit-js --updateSnapshot",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start"
"start": "wp-scripts start",
"type-coverage": "type-coverage --strict --at-least 99.83"
},
"author": "",
"license": "ISC",
Expand All @@ -26,6 +27,7 @@
"@wordpress/icons": "^9.44.0",
"@wordpress/interface": "^5.30.0",
"@wordpress/scripts": "^27.4.0",
"react": "^18.2.0"
"react": "^18.2.0",
"type-coverage": "^2.28.2"
}
}
2 changes: 1 addition & 1 deletion packages/iconography/src/IconToolbarButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ComponentProps } from 'react';

/* WordPress Dependencies */
import { __ } from '@wordpress/i18n';
Expand Down
4 changes: 2 additions & 2 deletions packages/iconography/src/tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe( 'Should generate a rich-text format from icon', () => {
text: 'zoom_out',
formats: new Array( 8 ).fill( [
{ type: 'content-only/ms-outlined' },
] ),
] ) as { type: 'content-only/ms-outlined' }[],
start: 0,
end: 8,
replacements: [],
Expand All @@ -43,7 +43,7 @@ describe( 'Should generate a rich-text format from icon', () => {
text: 'something_else',
formats: new Array( 14 ).fill( [
{ type: 'content-only/ms-outlined' },
] ),
] ) as { type: 'content-only/ms-outlined' }[],
start: 0,
end: 14,
replacements: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/iconography/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export function generateRichTextFormat(
* @return {IconGroupIcon[]} Array of { name, value } objects.
*/
export const getIconOptions = ( suffix: string ): IconGroupIcon[] => {
const iconNames = IconData.filter( ( iconName ) =>
const iconNames = IconData.filter( ( iconName: string ) =>
iconName.endsWith( suffix )
);

return iconNames.map( ( name ) => {
return iconNames.map( ( name: string ) => {
const value = snakeCase( name.replace( suffix, '' ) );
return { name, value };
} );
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"test": {},
"test:unit": {},
"test:snapshots": {}
"test:snapshots": {},
"type-coverage": {}
}
}
Loading