mathigon/studio

Typescript errors in 0.1.36

nileshtrivedi opened this issue · 4 comments

✘ [ERROR] Transforming JavaScript decorators to the configured target environment ("es2016") is not supported yet

node_modules/@mathigon/studio/frontend/course.ts:38:0:
38 │ @register('x-course')
╵ ^

✘ [ERROR] Transforming JavaScript decorators to the configured target environment ("es2016") is not supported yet

node_modules/@mathigon/studio/frontend/accounts.ts:54:0:
54 │ @register('x-password', {template})

Also this:

TSError: ⨯ Unable to compile TypeScript:
node_modules/@mathigon/studio/server/utilities/utilities.ts:79:21 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'Obj'.
Index signature for type 'string' is missing in type '{}'.

79 deep ? deepExtend(studio, project, (a, b) => b) : Object.assign(studio as any, project);
at createTSError (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:1077:36)
at Object.compile (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:1433:41)
at Module.m._compile (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Object.require.extensions. [as .ts] (/Users/eshnil/code/textbooks/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Function.Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19) {
diagnosticCodes: [ 2345 ]
}

I see this error when running npm start for the latest commit in the textbooks repo which changed studio dependency from 0.1.35 to 0.1.36.

node -v
v18.15.0

npm -v
9.5.0

I suspect that the bundleScripts method in assets.js (which is used as mgon-build) is not passing compiler options correctly.

`> @mathigon/textbooks@0.7.4 start

npm-run-all --parallel watch server

@mathigon/textbooks@0.7.4 watch
mgon-build --assets --watch --locales en

@mathigon/textbooks@0.7.4 server
mgon-serve

✔ Built icons.svg in 36ms
I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
node_modules/@mathigon/studio/server/utilities/utilities.ts:79:21 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'Obj'.
Index signature for type 'string' is missing in type '{}'.

79 deep ? deepExtend(studio, project, (a, b) => b) : Object.assign(studio as any, project); ~~~~~~

at createTSError (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:859:12)
at reportTSError (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:863:19)
at getOutput (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:1077:36)
at Object.compile (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:1433:41)
at Module.m._compile (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Object.require.extensions.<computed> [as .ts] (I:\01_代码\mathigon.org\textbooks\node_modules\ts-node\src\index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19) {

diagnosticCodes: [ 2345 ]
}
ERROR: "server" exited with 1.`
I have also encountered a similar error. How can I solve it? Thank you!

@mougedashu I think this has been fixed in this commmit but studio package has not been published to npm yet.

For now, you can try replacing @mathigon/studio version 0.1.37 to @dhimath/studio version 0.1.38. But you will also have to replace all import statements in files like functions.ts to import ... from '@dhimath/studio';

@plegner If you could publish latest version of the studio package, that would be great. BTW, the docs/example shows this error:

image

@nileshtrivedi,I have successfully solved the problem according to the method you provided. Thank you!