SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
200 stars 28 forks source link

Compatibility with Typescript V5 #391

Closed marianfoo closed 1 year ago

marianfoo commented 1 year ago

Describe the bug

After updating typescript from 4.9.5 to 5.0.2 i get a error executing. Do any additional things need to be done with the package so that Typescript V5 can be used?

npx @ui5/ts-interface-generator --watch
npx @ui5/ts-interface-generator --watch
Log level set to: info
Using the following TypeScript configuration file (automatically found, as none was given): ./tsconfig.json
Initializing TypeScript program with all source files and type definitions (this may take a few seconds)...
C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\typescript@5.0.2\node_modules\typescript\lib\typescript.js:20482
      array.pos = -1;
                ^

TypeError: Cannot create property 'pos' on string 'CustomDataType'
    at createNodeArray (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\typescript@5.0.2\node_modules\typescript\lib\typescript.js:20482:17)
    at asNodeArray (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\typescript@5.0.2\node_modules\typescript\lib\typescript.js:23945:22)
    at Object.createTypeParameterDeclaration (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\typescript@5.0.2\node_modules\typescript\lib\typescript.js:20841:24)
    at generateMethods (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\astGenerationHelper.js:307:21) 
    at buildAST (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:350:63)  
    at generateInterface (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:341:17)
    at C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:40:31
    at Array.forEach (<anonymous>)
    at generateInterfaces (C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:39:9)
    at C:\UI5\ui5-cc-excelUpload\node_modules\.pnpm\@ui5+ts-interface-generator@0.5.4\node_modules\@ui5\ts-interface-generator\dist\generateTSInterfaces.js:134:60

Node.js v18.12.1

Additional context

Using my repo https://github.com/marianfoo/ui5-cc-excelUpload

Recreate the error

git clone https://github.com/marianfoo/ui5-cc-excelUpload

Change Typescript to "5.0.2" https://github.com/marianfoo/ui5-cc-excelUpload/blob/2e7e244348de676c9406c16ef744788dfc570d27/package.json#L73

pnpm i
npx @ui5/ts-interface-generator --watch
marianfoo commented 1 year ago

i guess this was fixed with https://github.com/SAP/ui5-typescript/commit/12be9aac888dc334f7870cf21a7b2b28004cb19a can you please publish the @ui5/ts-interface-generator? @akudev

marianfoo commented 1 year ago

tried with the newest version from GitHub, can confirm that the commit fixes the error

akudev commented 1 year ago

Release 0.5.5 with TS 5.0 support was done. Thanks for reporting and verifying that the latest code fixes the issue.

Fixed by https://github.com/SAP/ui5-typescript/commit/12be9aac888dc334f7870cf21a7b2b28004cb19a