From 9c0efb00cb2590f7b91a8d2ac50d8fedf125b577 Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Sun, 15 Dec 2024 08:05:00 -0800 Subject: [PATCH] fix(replace): add missing types for `objectGuards` option (#1818) --- packages/replace/test/types.ts | 1 + packages/replace/types/index.d.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/packages/replace/test/types.ts b/packages/replace/test/types.ts index 4dda56bc6..ed7b156c7 100755 --- a/packages/replace/test/types.ts +++ b/packages/replace/test/types.ts @@ -16,6 +16,7 @@ const config: RollupOptions = { include: 'config.js', exclude: 'node_modules/**', delimiters: ['<@', '@>'], + objectGuards: true, preventAssignment: true, VERSION: '1.0.0', ENVIRONMENT: JSON.stringify('development'), diff --git a/packages/replace/types/index.d.ts b/packages/replace/types/index.d.ts index 1f0794719..68f2e9288 100755 --- a/packages/replace/types/index.d.ts +++ b/packages/replace/types/index.d.ts @@ -12,6 +12,7 @@ export interface RollupReplaceOptions { | Replacement | RollupReplaceOptions['include'] | RollupReplaceOptions['values'] + | RollupReplaceOptions['objectGuards'] | RollupReplaceOptions['preventAssignment']; /** @@ -33,6 +34,12 @@ export interface RollupReplaceOptions { * of `foo`, supply delimiters */ delimiters?: [string, string]; + /** + * When replacing dot-separated object properties like `process.env.NODE_ENV`, + * will also replace `typeof process` object guard checks against the objects + * with the string `"object"`. + */ + objectGuards?: boolean; /** * Prevents replacing strings where they are followed by a single equals * sign.