cardinal TS workaround
Copy of request to Sinica on Jan 2022
(Sorry for the reply delay on this thread, as Tiago is away, and I am picking up these issues when I can.). The https://github.com/PrivateSky/cardinal is used as a dependency on most OpenDSU projects.
I am not sure if we can just remove it.If we remove it as a dependency, we get other errors using webcardinal. (Separate thread on this? Probably more important than the fix on cardinal...)
If we build cardinal standalone,
git clone https://github.com/PrivateSky/cardinal
cd cardinal
npm install
npm run build
It will build ok.But if this is done inside a parent project with a package.json devDependency such as
"@types/node": "^16.0.1"
that strongly types the nodejs setTimeout() return value it will generate the above error:
[ ERROR ] TypeScript: ./src/components/psk-page/psk-page.tsx:174:3
Type 'Timeout' is not assignable to type 'number'.
So I guess that Tiago is asking if you could kindly add a comment like
//@ts-ignore
this.__isScrolling = setTimeout(function () {
or change it to
this.__isScrolling = window.setTimeout(function () {
or change it to
this.__isScrolling = global.setTimeout(function () {
I am not quite sure what is the better fix. And open for suggestions. (I had not yet time to check npm v8.x overrides... or if we can deprecate cardinal soon enough...)
Local workaround proposal:
- write a script bin/cardinalWorkaroundSetTimeout.js that checks the file ./cardinal/src/components/psk-page/psk-page.tsx line 174 and adds a previous line
//@ts-ignore
if still appropriate. (Cardinal might be updated or deprecated meanwhile). - add that script after npm install (on the top-level octopus.json
"cmd": "cd cardinal && npm install && cd .. && node bin/cardinalWorkaroundSetTimeout.js"
from
{
"name": "cardinal",
"src": "http://github.com/privatesky/cardinal.git",
"actions": [
{
"type": "smartClone",
"target": ".",
"collectLog": false
},
{
"type": "execute",
"cmd": "cd cardinal && npm install"
},
{
"type": "execute",
"cmd": "cd cardinal && npm run build"
}
]
},
- update also the octopus-freeze.json
- check that it builds on Windows ok also.