jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Typescript Compile Error When "skipLibCheck": false

Open mickdelaney opened this issue 2 years ago • 1 comments

Describe the bug

getting a compile time error when using typescript (tried versions 4.6.3 & 4.7.4).

build: ../../node_modules/@jsonforms/core/lib/util/type.d.ts(118,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. build: ../../node_modules/@jsonforms/core/lib/util/type.d.ts(118,13): error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'. build: ../../node_modules/@jsonforms/core/lib/util/type.d.ts(137,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. build: ../../node_modules/@jsonforms/core/lib/util/type.d.ts(137,13): error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'. build: error Command failed with exit code 2.

Expected behavior

would expect to compile without error

Steps to reproduce the issue

include @jsonforms/core ensure tsconfig compilerOptions.skipLibCheck = true compile source

Screenshots

No response

In which browser are you experiencing the issue?

nodejs compiler

Framework

React

RendererSet

Vanilla

Additional context

workaround is to set

"compilerOptions": { "skipLibCheck": true },

mickdelaney avatar Jul 25 '22 15:07 mickdelaney

We're currently using Typescript 4.2.3. Maybe a later version is not fully backwards compatible?

The workaround definitely makes sense

"compilerOptions": {
  "skipLibCheck": true
}

sdirix avatar Jul 25 '22 17:07 sdirix

As there was no more information I'll close this for now. Feel free to reopen if you disagree and have more information.

sdirix avatar Nov 08 '22 20:11 sdirix

i'm running into the same problem. and "skipLibCheck" doesn't work.

I suspect that the actual problem lies in the outdated typescript version 4.2.3 (was released in March 2021).

When I install typescript:4.2.3, other nodeModules throw other typescript errors. i haven't found a version where jsonforms and other nodeModules are compiled without errors.

my current workaround is to patch the corresponding files with patch-package and add a //@ts-ignore

what do you think about updating typescript to a current version?

davewwww avatar Nov 16 '23 15:11 davewwww

Hi @davewwww,

In general we would like to update Typescript to a newer version. At the moment we're blocked by the Angular components in our mono repo which do not allow to use a newer version.

I would have expected skipLibCheck: true to mitigate all errors. How does your build setup look like that the error is thrown?

sdirix avatar Nov 17 '23 09:11 sdirix

i have finally found the cause of the problem.

When importing functions from "@jsonforms/core", the import path must not go any deeper. a path to "@jsonforms/core/src/util/renderer" will trigger the error at the vue-tsc command.

//no tsc error
import { computeLabel } from "@jsonforms/core";

//throws tsc error
//import { computeLabel } from "@jsonforms/core/src/util/renderer";

const label = computeLabel("name", true, true)

davewwww avatar Nov 17 '23 09:11 davewwww

Hi @davewwww,

That makes sense! Importing the source code will need a compatible Typescript compiler. We only distribute the source code for convenient debugging support, it's not meant to be imported from ;)

sdirix avatar Nov 17 '23 09:11 sdirix

yes, makes totally sense. I wasn't even aware that my IDE create these full imports paths. and i couldn't find a solution on the internet either. so here's a solution for people who also run into this problem: fix your import paths! :)

davewwww avatar Nov 17 '23 09:11 davewwww