Skip to content

Fix TypeScript error with verbatimModuleSyntax (use type-only import for ReactNode) #138

@AdityaChowdhury2

Description

@AdityaChowdhury2

Hi thanks for maintaining this project.

When using modern TypeScript (>=5.5) with "verbatimModuleSyntax": true, the current type definitions fail to compile.

Error

TS1484: 'ReactNode' is a type and must be imported using a type-only import

Cause
@types/index.ts imports ReactNode as a value instead of a type.

Fix
Switch to a type-only import:

import React from 'react';
import type { ReactNode } from 'react';

I’ve attached a minimal diff below that resolves the issue without changing runtime behavior.

This affects users on strict ESM / modern TS setups (Vite, React 18/19, etc.).

Thanks!

Here is the diff that solved my problem:

diff --git a/node_modules/react-parallax/@types/index.ts b/node_modules/react-parallax/@types/index.ts
index cc6bf84..c5dea9c 100644
--- a/node_modules/react-parallax/@types/index.ts
+++ b/node_modules/react-parallax/@types/index.ts
@@ -1,4 +1,5 @@
-import React, { ReactNode } from 'react';
+import React from 'react';
+import type { ReactNode } from 'react';
 
 export type DynamicBlurProp = { min: number; max: number };
 export type BlurProp = number | DynamicBlurProp;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions