-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Edit Site: Add tsconfig.json validation for package #67406
base: trunk
Are you sure you want to change the base?
Changes from all commits
82c5e6f
a11bb55
4f06088
012211b
66c301a
eb54b09
475c20b
26ae4de
1890f71
a28e41f
ae36151
1b8c418
a8c931c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
// @wordpress/blocks imports are not typed. | ||
// @ts-expect-error | ||
import { getCategories } from '@wordpress/blocks'; | ||
|
||
/** | ||
|
@@ -29,15 +31,19 @@ export function getExamplesByCategory( | |
if ( ! categoryDefinition?.slug || ! examples?.length ) { | ||
return; | ||
} | ||
|
||
if ( categoryDefinition?.subcategories?.length ) { | ||
return categoryDefinition.subcategories.reduce( | ||
const categories: CategoryExamples[] = | ||
categoryDefinition?.subcategories ?? []; | ||
if ( categories.length ) { | ||
return categories.reduce( | ||
( acc, subcategoryDefinition ) => { | ||
const subcategoryExamples = getExamplesByCategory( | ||
subcategoryDefinition, | ||
examples | ||
); | ||
if ( subcategoryExamples ) { | ||
if ( ! acc.subcategories ) { | ||
acc.subcategories = []; | ||
} | ||
acc.subcategories = [ | ||
...acc.subcategories, | ||
subcategoryExamples, | ||
|
@@ -48,7 +54,6 @@ export function getExamplesByCategory( | |
{ | ||
title: categoryDefinition.title, | ||
slug: categoryDefinition.slug, | ||
subcategories: [], | ||
} | ||
); | ||
} | ||
|
@@ -84,8 +89,9 @@ export function getTopLevelStyleBookCategories(): StyleBookCategory[] { | |
...STYLE_BOOK_THEME_SUBCATEGORIES, | ||
...STYLE_BOOK_CATEGORIES, | ||
].map( ( { slug } ) => slug ); | ||
const extraCategories = getCategories().filter( | ||
const extraCategories: StyleBookCategory[] = getCategories(); | ||
const extraCategoriesFiltered = extraCategories.filter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this is for the TS parser If there are any major type tweaks required, I'd rather do them in a follow up. This is just to get typing working for this package. |
||
( { slug } ) => ! reservedCategories.includes( slug ) | ||
); | ||
return [ ...STYLE_BOOK_CATEGORIES, ...extraCategories ]; | ||
return [ ...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered ]; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||||||
{ | ||||||||||
"$schema": "https://json.schemastore.org/tsconfig.json", | ||||||||||
"extends": "../../tsconfig.base.json", | ||||||||||
"compilerOptions": { | ||||||||||
"rootDir": "src", | ||||||||||
"declarationDir": "build-types" | ||||||||||
}, | ||||||||||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This becomes redundant after ca61601 (rebase required):
Suggested change
|
||||||||||
"references": [ | ||||||||||
{ "path": "../a11y" }, | ||||||||||
{ "path": "../api-fetch" }, | ||||||||||
{ "path": "../autop" }, | ||||||||||
{ "path": "../blob" }, | ||||||||||
{ "path": "../block-library" }, | ||||||||||
{ "path": "../block-editor" }, | ||||||||||
{ "path": "../components" }, | ||||||||||
{ "path": "../compose" }, | ||||||||||
{ "path": "../core-data" }, | ||||||||||
{ "path": "../data" }, | ||||||||||
{ "path": "../dataviews" }, | ||||||||||
{ "path": "../date" }, | ||||||||||
{ "path": "../deprecated" }, | ||||||||||
{ "path": "../dom" }, | ||||||||||
{ "path": "../editor" }, | ||||||||||
{ "path": "../element" }, | ||||||||||
{ "path": "../escape-html" }, | ||||||||||
{ "path": "../fields" }, | ||||||||||
{ "path": "../hooks" }, | ||||||||||
{ "path": "../html-entities" }, | ||||||||||
{ "path": "../i18n" }, | ||||||||||
{ "path": "../icons" }, | ||||||||||
{ "path": "../interactivity" }, | ||||||||||
{ "path": "../interactivity-router" }, | ||||||||||
{ "path": "../media-utils" }, | ||||||||||
{ "path": "../notices" }, | ||||||||||
{ "path": "../keycodes" }, | ||||||||||
{ "path": "../plugins" }, | ||||||||||
{ "path": "../primitives" }, | ||||||||||
{ "path": "../private-apis" }, | ||||||||||
{ "path": "../rich-text" }, | ||||||||||
{ "path": "../router" }, | ||||||||||
{ "path": "../style-engine" }, | ||||||||||
{ "path": "../url" }, | ||||||||||
{ "path": "../wordcount" } | ||||||||||
], | ||||||||||
// NOTE: This package is being progressively typed. You are encouraged to | ||||||||||
// expand this array with files which can be type-checked. At some point in | ||||||||||
// the future, this can be simplified to an `includes` of `src/**/*`. | ||||||||||
"files": [ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't use globs apparently, except in |
||||||||||
"src/components/style-book/categories.ts", | ||||||||||
"src/components/style-book/constants.ts", | ||||||||||
"src/components/style-book/types.ts", | ||||||||||
"src/components/style-book/color-examples.tsx", | ||||||||||
"src/components/style-book/duotone-examples.tsx", | ||||||||||
"src/components/style-book/examples.tsx" | ||||||||||
] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After ca61601, it becomes necessary to override the default
Suggested change
|
||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line would expose the types to the world (public consumers via npm). It doesn't seem like this package is ready to be typed, but this PR is trying to fix internal build issues for Gutenberg.
I'd remove this line: