ajaxorg / ace

Ace (Ajax.org Cloud9 Editor)

Home Page:https://ace.c9.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`npm run typecheck` fails with newer version of TypeScript

andredcoliveira opened this issue · comments

Ace does not have a package-lock.json file:

ace/.gitignore

Line 14 in d296fd4

package-lock.json
. It's unclear why.

Whenever a new TypeScript version becomes available, CI jobs (that run in PRs, for example), pick up the latest 5.x.x version available:

"typescript": "^5.2.2"

This is presumed to be the cause of the recent CI Job failures. Example:

https://github.com/ajaxorg/ace/actions/runs/8185854158/job/22568680132

##[debug]Evaluating condition for step: 'Run npm run typecheck'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run npm run typecheck
##[debug]Loading inputs
##[debug]Loading env
Run npm run typecheck
##[debug]/usr/bin/bash -e /home/runner/work/_temp/0727b24b-7d3c-4982-b003-8f7966b34fb4.sh

> ace-code@1.32.7 typecheck
> tsc -p tsconfig.json

Error: src/multi_select.js(493,28): error TS2339: Property 'session' does not exist on type 'forEachSelection'.
Error: src/multi_select.js(495,25): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(502,19): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(503,9): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(523,9): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(524,9): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(525,13): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(526,13): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(526,41): error TS18048: 'selection' is possibly 'undefined'.
Error: src/multi_select.js(528,25): error TS2339: Property 'renderer' does not exist on type 'forEachSelection'.
Error: src/multi_select.js(529,14): error TS2339: Property 'onCursorChange' does not exist on type 'forEachSelection'.
Error: src/multi_select.js(530,14): error TS2339: Property 'onSelectionChange' does not exist on type 'forEachSelection'.
Error: src/multi_select.js(532,18): error TS2339: Property 'renderer' does not exist on type 'forEachSelection'.
Error: Process completed with exit code 2.
##[debug]Finishing: Run npm run typecheck

Suggestion

We should either:

  1. Start using package-lock.json
  2. Be more restrictive with the range of versions we allow for TypeScript:
    "typescript": "^5.2.2"
    • E.g.: allow only patch version to automatically increase or pin the full version number

Looks like package-lock.json was removed during #3514. No reasoning provided.

The @this type annotation is present and should be preventing this error:

* @this {Editor}

I checked the release notes and still have no clue why it's failing in typescript@5.4.2: https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/

Restoring package.lock makes sense, it will definitely help to deal with effects of unexpected dependency updates. Though we would need to run dependabot in that case to update those for us regularly.

There is also a PR which fixes the type issue - #5507

@andredcoliveira hi!
I fixed this local error in #5507 , there are some weird bug with not recognising @this when @param {Object} [options] is present. I haven't dig deeper though.

@mkslanc I'll close my PR, then. Let's go with your solution instead of my mitigation :)