facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
17.37k stars 1.43k forks source link

Bug: private module 'shared' is referenced in shipped type declarations #5918

Closed pvdstel closed 1 week ago

pvdstel commented 1 week ago

Lexical version: 0.14.5, change introduced in 0.14.4 (via #5831).

Steps To Reproduce

  1. Create a new project (pnpm init).
  2. Add the relevant dependencies (pnpm add typescript lexical @lexical/utils).
  3. Add a file index.ts in VSCode with the following contents:
    import { CAN_USE_DOM } from '@lexical/utils';
  4. Navigate to the symbol CAN_USE_DOM. TypeScript will be complaining:
    Cannot find module 'shared/canUseDOM' or its corresponding type declarations.

    The same is true for shared/environment.

Screenshot of Visual Studio Code showing the errors in the shipped type definition files

It should be noted that this is merely a TypeScript issue, as the names are exported from the JS bundles.

The current behavior

TypeScript is showing errors since the private module shared cannot be found. This is affecting TypeScript projects that use Lexical 0.14.5.

The expected behavior

The declarations of these variables should not rely on the private package.

etrepum commented 1 week ago

Confirmed that this only affects the one module:

❯ rg "'shared/" '.ts-temp/'
.ts-temp/lexical-utils/src/index.d.ts
13:export { CAN_USE_DOM } from 'shared/canUseDOM';
14:export { CAN_USE_BEFORE_INPUT, IS_ANDROID, IS_ANDROID_CHROME, IS_APPLE, IS_APPLE_WEBKIT, IS_CHROME, IS_FIREFOX, IS_IOS, IS_SAFARI, } from 'shared/environment';