Skip to content

Commit c098a92

Browse files
authored
Merge pull request #287 from jorrit/tscheck
Fix Typescript failures and introduce step in GitHub action
2 parents c3ea1eb + b917017 commit c098a92

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

.changeset/silent-paws-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
Fixes several Typescript issues and adds lint check

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
run: yarn run build
3838
- name: Run eslint
3939
run: yarn run eslint
40+
- name: Run Typescript checks
41+
run: yarn run tscheck
4042
test:
4143
name: 'test'
4244
needs: [lint]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"develop": "FORCE_COLOR=1 turbo run watch:link",
1212
"eslint": "turbo run eslint",
1313
"eslint:fix": "turbo run eslint:fix",
14+
"tscheck": "tsc --noEmit",
1415
"release:publish": "turbo run build && changeset publish",
1516
"release:prepare": "changeset version && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install",
1617
"playground:install": "cd playground && yarn dlx yalc add --link strapi-plugin-webtools webtools-addon-sitemap && yarn install",

packages/core/admin/components/PatternField/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const PatternField: FC<Props> = ({
3131
const { get } = getFetchClient();
3232
const fields = useQuery('fields', async () => get<Record<string, string[]>>('/webtools/url-pattern/allowed-fields'));
3333
const { formatMessage } = useIntl();
34-
const inputRef = useRef<HTMLInputElement>();
35-
const popoverRef = useRef();
34+
const inputRef = useRef<HTMLInputElement>(undefined);
35+
const popoverRef = useRef(undefined);
3636

3737
const HoverBox = styled(Box)`
3838
cursor: pointer;

packages/core/server/middlewares/delete-url-alias.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { Modules } from '@strapi/strapi';
22
import { isContentTypeEnabled } from '../util/enabledContentTypes';
33

44
const deleteUrlAliasMiddleware: Modules.Documents.Middleware.Middleware = async (context, next) => {
5-
const { uid, action, params } = context;
6-
const hasWT = isContentTypeEnabled(uid);
5+
const {
6+
uid, action, params, contentType,
7+
} = context;
8+
const hasWT = isContentTypeEnabled(contentType);
79

810
// If Webtools isn't enabled, do nothing.
911
if (!hasWT) {

packages/core/server/middlewares/generate-url-alias.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { getPluginService } from '../util/getPluginService';
44

55
// eslint-disable-next-line max-len
66
const generateUrlAliasMiddleware: Modules.Documents.Middleware.Middleware = async (context, next) => {
7-
const { uid, action } = context;
8-
const hasWT = isContentTypeEnabled(uid);
7+
const { uid, action, contentType } = context;
8+
const hasWT = isContentTypeEnabled(contentType);
99

1010
// If Webtools isn't enabled, do nothing.
1111
if (!hasWT) {

packages/core/server/register.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default ({ strapi }: { strapi: Core.Strapi }) => {
2222

2323
// Add a relation field to the url_alias content type, only
2424
// when webtools is explicitly enabled using pluginOptions.
25-
if (isContentTypeEnabled(contentType.uid)) {
25+
if (isContentTypeEnabled(contentType)) {
2626
set(attributes, 'url_alias', {
2727
writable: true,
2828
private: false,

0 commit comments

Comments
 (0)