Skip to content

[SDK] Typescript aliases in import paths are not resolved after compilation #164

Description

@ilyamore88

Description

SDK package uses @/ alias for src folder:

    "paths": {
      "@/*": ["./src/*"]
    }

Typescript compilation doesn't replace this alias in imports paths. See https://www.typescriptlang.org/tsconfig/#paths

Note that this feature does not change how import paths are emitted by tsc, so paths should only be used to inform TypeScript that another tool has this mapping and will use it at runtime or when bundling.

Problems caused

ts-jest library uses compiled version of sdk from dist folder. When I run tests on core package, it can't resolve path to type and fails with Typescript error. Example: https://github.com/editor-js/document-model/actions/runs/29044585271/job/86209971879

FAIL src/plugins/ClipboardPlugin.spec.ts
  ● Test suite failed to run

    src/tools/ToolsManager.ts:135:38 - error TS2339: Property 'prepare' does not exist on type 'ToolConstructable'.
      Property 'prepare' does not exist on type 'BlockToolConstructor<any, any, any>'.

       if (isFunction(toolConstructor.prepare)) {
                                             ~~~~~~~
    src/tools/ToolsManager.ts:143:35 - error TS2339: Property 'prepare' does not exist on type 'ToolConstructable'.
      Property 'prepare' does not exist on type 'BlockToolConstructor<any, any, any>'.

             await toolConstructor.prepare!({
                                          ~~~~~~~

Possible solutions

  1. Remove alias from core package
  2. Use library like tsc-alias after compilation

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions