Skip to content

Commit

Permalink
Fix types for import.meta.env
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Dec 16, 2024
1 parent a22da12 commit d2c69bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
20 changes: 0 additions & 20 deletions global.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/circuit-ui/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* limitations under the License.
*/

/// <reference types="vite/client" />

import type { Theme as CircuitTheme } from '@sumup-oss/design-tokens';

import 'react';
Expand Down
10 changes: 6 additions & 4 deletions packages/circuit-ui/util/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export function transformModulesToTranslations<
const { default: unused, ...strings } = exports;
const matches = importPath.match(/[a-z]{2}-[A-Z]{2}/);

// @ts-expect-error This environment variable is set by Vite.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This is fine, but ESLint complains because it's configured for CJS at the project root.
if (import.meta.env.DEV && !matches) {
throw new Error(
`Failed to extract a locale from the import path: ${importPath}`,
Expand All @@ -124,7 +125,8 @@ export function transformModulesToTranslations<
// biome-ignore lint/style/noNonNullAssertion:
const locale = matches![0] as SupportedLocale;

// @ts-expect-error This environment variable is set by Vite.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This is fine, but ESLint complains because it's configured for CJS at the project root.
if (import.meta.env.DEV && !SUPPORTED_LOCALES.includes(locale)) {
throw new Error(`Unsupported locale: ${importPath}`);
}
Expand All @@ -134,8 +136,8 @@ export function transformModulesToTranslations<
},
{} as Translations<Key>,
);

// @ts-expect-error This environment variable is set by Vite.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This is fine, but ESLint complains because it's configured for CJS at the project root.
if (import.meta.env.DEV) {
SUPPORTED_LOCALES.forEach((locale) => {
if (!translations[locale]) {
Expand Down

0 comments on commit d2c69bd

Please sign in to comment.