Reputation: 36
I was looking for developing my own theia plugin. First, I want to try the simple "Hello World" plugin with the command yo @theia/plugin.
Yeoman command to generate Theia plugin
I develop with Ubuntu 20.04. I get many TypeScript errors as we can see in the following image.
I tried to figure out by myself. I installed many tsc versions, but nothing worked. I've readed the Prerequisites first and installed every dependencies.
I understand that the TypeScript version may not be the good one, but not sure which one and why.
Here are some versions I use: yarn: 1.22.19 node: v16.14.2 tsc: 3.1.3
Here is the tsconfig file that was autogenetared with yo command:
{
"compilerOptions": {
"strict": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"lib": [
"es6",
"webworker"
],
"sourceMap": true,
"rootDir": "src",
"outDir": "lib",
"skipLibCheck": true
},
"include": [
"src"
]
}
Here is the package.json:
{
"name": "hello",
"publisher": "theia",
"keywords": [
"theia-plugin"
],
"version": "0.0.1",
"license": "none",
"files": [
"src"
],
"activationEvents": [
"*"
],
"devDependencies": {
"@theia/plugin": "next",
"@theia/plugin-packager": "latest",
"rimraf": "2.6.2",
"typescript-formatter": "7.2.2",
"typescript": "3.5.3"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"format-code": "tsfmt -r",
"watch": "tsc -watch",
"compile": "tsc",
"build": "yarn run format-code && yarn run compile && theia-plugin pack"
},
"engines": {
"theiaPlugin": "next"
},
"theiaPlugin": {
"backend": "lib/hello-backend.js"
}
}
I changed nothing from the yo command
I am a little lost as why it happens. Can everyone help me out?
I was expecting the yo and yarn commands to be successful.
Edit: As I mentionned as a comment to Konstantin's answer, I ended up using yo theia-extension
as mentioned here. It solved my problem. However, I appreciate the answer which helped me fix another problem.
Upvotes: 0
Views: 705
Reputation: 173
I faced the same issue. It appears the generator's templates are using Typescript syntax not compatible with the bundled TS package. See https://github.com/eclipse/theia-generator-plugin/issues/33#issuecomment-1183227280
Below are the steps to get this up and running, considering a fresh installation. First, install Yeoman globally, as indicated at https://www.npmjs.com/package/@theia/generator-plugin:
npm install -g yo
Next, create a package to hold the generator dependency itself:
mkdir theia-yeoman-sandbox && cd theia-yeoman-sandbox
npm init -y
npm i @theia/generator-plugin
After launching the generator (e.g. Hello World backend plug-in), tsc
step fails with the following:
node_modules/@theia/plugin/src/theia.d.ts(5775,60): error TS1005: ',' expected.
node_modules/@theia/plugin/src/theia.d.ts(5775,74): error TS1005: ',' expected.
node_modules/@theia/plugin/src/theia.d.ts(5775,92): error TS1005: ',' expected.
node_modules/@theia/plugin/src/theia.d.ts(5775,93): error TS1109: Expression expected.
...
node_modules/@theia/plugin/src/theia.d.ts(15518,5): error TS1005: ',' expected.
node_modules/@types/node/ts4.8/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
node_modules/@types/node/ts4.8/assert.d.ts(279,72): error TS1144: '{' or ';' expected.
...
node_modules/@types/node/ts4.8/test.d.ts(643,77): error TS1005: ',' expected.
node_modules/@types/node/ts4.8/test.d.ts(647,22): error TS1005: ',' expected.
This can be remediated by upgrading the version of typescript
package in plugin's level package.json
:
"typescript": "^4.9.5"
Running yarn
afterwards emits no error messages and completes just fine:
yarn install v1.22.19
warning package.json: License should be a valid SPDX license expression
warning [email protected]: License should be a valid SPDX license expression
[1/5] Validating package.json...
warning [email protected]: License should be a valid SPDX license expression
warning [email protected]: The engine "theiaPlugin" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "@theia/plugin-packager > [email protected]" has unmet peer dependency "glob@*".
[5/5] Building fresh packages...
success Saved lockfile.
$ yarn run clean && yarn run build
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
warning [email protected]: The engine "theiaPlugin" appears to be invalid.
$ rimraf lib
Done in 0.13s.
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
warning [email protected]: The engine "theiaPlugin" appears to be invalid.
$ yarn run format-code && yarn run compile && theia-plugin pack
warning package.json: License should be a valid SPDX license expression
warning [email protected]: The engine "theiaPlugin" appears to be invalid.
$ tsfmt -r
warning package.json: License should be a valid SPDX license expression
warning [email protected]: The engine "theiaPlugin" appears to be invalid.
$ tsc
Packaging of plugin
š Validating...āļø
š Getting dependencies... āļø
š Resolving files... āļø
āļø Excluding files...āļø
āļø Generating Assembly...āļø
š Generated plugin: hello_world.theia
Done in 6.17s.
Done in 8.42s.
Node 16.18.1
Upvotes: 2