Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDroryAu committed Dec 24, 2024
1 parent e1a08ff commit 005d7bf
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 41 deletions.
3 changes: 1 addition & 2 deletions packages/sku/src/context/configSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Validator from 'fastest-validator';

// @ts-expect-error
const validator = new Validator();
const validator = new (Validator as unknown as typeof Validator.default)();

const languagesToCompile = {
optional: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/sku/src/context/defaultSkuConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join } from 'node:path';
import isCompilePackage from '../lib/isCompilePackage.js';
import type { SkuConfig } from '../../sku-types.d.ts';

const defaultDecorator = (a: any) => a;
const defaultDecorator = <T>(a: T) => a;

export default {
clientEntry: 'src/client.js',
Expand Down
13 changes: 7 additions & 6 deletions packages/sku/src/context/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import defaultSkuConfig from './defaultSkuConfig.js';
import defaultClientEntry from './defaultClientEntry.js';
import type { SkuConfig } from '../../sku-types.d.ts';
import { hasErrorMessage } from '../lib/utils/error-guards.js';
import type { ValidationError } from 'fastest-validator';

const availableConfigKeys = Object.keys(defaultSkuConfig);

Expand Down Expand Up @@ -34,17 +35,17 @@ export default (skuConfig: SkuConfig) => {
});

// Validate schema types
const schemaCheckResult = configSchema(skuConfig);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(
({ message, field }: { message: string; field: string }) => {
if (!configSchema.async) {
const schemaCheckResult = configSchema(skuConfig);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(({ message, field }: ValidationError) => {
const errorMessage = message
? `🚫 ${message.replace(field, `${chalk.bold(field)}`)}`
: `🚫 '${chalk.bold(field)}' is invalid`;

errors.push(errorMessage);
},
);
});
}
}

// Validate library entry has corresponding libraryName
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/src/entry/client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// '__sku_alias__clientEntry' is a webpack alias
// pointing to the consuming apps client entry
import client from '__sku_alias__clientEntry';
import dedent from 'dedent';

import { loadableReady } from '@loadable/component';

import clientContextKey from '../clientContextKey.js';

if (process.env.NODE_ENV === 'development') {
if (typeof client !== 'function') {
// eslint-disable-next-line
throw new Error(require('dedent')`
throw new Error(dedent`
The sku client entry ('${__SKU_CLIENT_PATH__}') must export a function that calls hydrateRoot. e.g.
import { hydrateRoot } from 'react-dom/client';
Expand Down
Loading

0 comments on commit 005d7bf

Please sign in to comment.