Skip to content

Commit 5aa7901

Browse files
committed
fix: correct global type augmentation for ImportMeta.env
- Remove duplicate environment.d.ts file, consolidate into env.d.ts - Add proper declare global wrapper with export {} for module context - Define ImportMetaEnv interface with documented Klever SDK env vars - Use triple-slash reference in index.ts to include global augmentation - Add eslint-disable comment for required triple-slash reference usage - Keep sideEffects: false to allow proper tree-shaking This fixes the esbuild warning about ignored bare imports while ensuring TypeScript correctly picks up the global ImportMeta.env types across all packages. The global augmentation now properly extends ImportMeta with optional env property containing Klever-specific environment variables. Fixes build warning: "Ignoring this import because src/types/env.d.ts was marked as having no side effects"
1 parent 77ac25f commit 5aa7901

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed
Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1-
/// <reference types="vite/client" />
1+
/**
2+
* Global type augmentations for cross-platform compatibility
3+
* Augments ImportMeta to support env properties from Vite and other bundlers
4+
*
5+
* Note: This is a library, so we don't reference vite/client.
6+
* Consumers using Vite will get these types merged with Vite's types automatically.
7+
*/
28

3-
interface ImportMetaEnv {
4-
readonly VITE_KLEVER_LOG_LEVEL?: string
5-
readonly KLEVER_LOG_LEVEL?: string
6-
// Add more env vars as needed
7-
}
9+
declare global {
10+
interface ImportMetaEnv {
11+
/**
12+
* Log level for Klever SDK (Vite convention)
13+
* @example 'debug' | 'info' | 'warn' | 'error' | 'silent'
14+
*/
15+
readonly VITE_KLEVER_LOG_LEVEL?: string
16+
17+
/**
18+
* Log level for Klever SDK (non-Vite environments)
19+
* @example 'debug' | 'info' | 'warn' | 'error' | 'silent'
20+
*/
21+
readonly KLEVER_LOG_LEVEL?: string
822

9-
interface ImportMeta {
10-
readonly env: ImportMetaEnv
23+
// Allow any other env variables
24+
[key: string]: string | undefined
25+
}
26+
27+
interface ImportMeta {
28+
/**
29+
* Environment variables (available in Vite and other modern bundlers)
30+
*/
31+
readonly env?: ImportMetaEnv
32+
}
1133
}
34+
35+
// This export {} makes TypeScript treat this file as a module
36+
// which is required for declare global to work properly
37+
export {}

packages/connect-core/src/types/environment.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/connect-core/src/types/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* Inspired by ethers.js, CosmJS, and @solana/web3.js
44
*/
55

6+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
7+
/// <reference path="./env.d.ts" />
8+
69
// Environment types
710
export type Environment = 'browser' | 'node' | 'react-native' | 'unknown'
811

9-
// Import global type augmentations
10-
import './environment.d.ts'
11-
1212
export * from './branded'
1313
export * from './proposals'
1414
export * from './transactions'

0 commit comments

Comments
 (0)