codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.95k stars 377 forks source link

Linter example no longer works on Ubuntu 24.04? #1379

Closed JoD closed 6 months ago

JoD commented 6 months ago

Describe the issue

Got a grammar + simple autocomplete + simple linter working fine on Ubuntu 22.04 for a custom programming language, which can be seen working on manyworlds.site.

On Ubuntu 24.04, Running npm install on the same source files gives the error:

src/index.ts → dist/index.cjs, ./dist...
[!] (plugin Typescript) TS2345: Argument of type 'import("/home/jod/workspace/manyworlds-website/client/node_modules/@codemirror/state/dist/index").EditorState' is not assignable to parameter of type 'import("/home/jod/workspace/manyworlds-website/client/lang-manyworlds/node_modules/@codemirror/state/dist/index").EditorState'.
  The types of 'selection.ranges' are incompatible between these types.
    Type 'readonly import("/home/jod/workspace/manyworlds-website/client/node_modules/@codemirror/state/dist/index").SelectionRange[]' is not assignable to type 'readonly import("/home/jod/workspace/manyworlds-website/client/lang-manyworlds/node_modules/@codemirror/state/dist/index").SelectionRange[]'.
      Type 'import("/home/jod/workspace/manyworlds-website/client/node_modules/@codemirror/state/dist/index").SelectionRange' is not assignable to type 'import("/home/jod/workspace/manyworlds-website/client/lang-manyworlds/node_modules/@codemirror/state/dist/index").SelectionRange'.
        Types have separate declarations of a private property 'flags'.
src/index.ts (52:14)

Points to the linter part of index.ts in attachment, but that is almost completely the same as the linter example on the website.

In a nutshell, does the linter example on the website not play nice with Ubuntu 24.04's default packages or am I doing something wrong? Source files in attachment.

syntax.grammar.txt index.ts.txt

Browser and platform

No response

Reproduction link

No response

marijnh commented 6 months ago

This has nothing to do with your OS version. You seem to be using multiple node_module trees in a single project, which doesn't work with this library (and never worked before either). Use a recent version of npm with the 'workspaces' feature to get a unified, properly deduplicated dependency tree.

JoD commented 6 months ago

You're right, apologies for opening this phantom issue.

Thanks for pointing out it was an issue with the node_modules tree. Got it to work the old way without workspaces for now, but will try to incorporate workspaces at the next project refactor.