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
- Remove alias from core package
- Use library like tsc-alias after compilation
Description
SDK package uses
@/alias for src folder:Typescript compilation doesn't replace this alias in imports paths. See https://www.typescriptlang.org/tsconfig/#paths
Problems caused
ts-jestlibrary 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/86209971879FAIL 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