[ts-interface-generator] interface generation fails if application contains mixins

Abierto
#480 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
tooling

Línea de trabajo

Start with the npx @ui5/ts-interface-generator command and a ClassC.ts containing extends ClassA(ClassB), reproducing the failure from @ui5/[email protected]. Compare this with the workaround using tsconfig-generate-ts-interfaces.json and --config; done means type generation succeeds without excluding files containing mixins.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

ts-interface-generator

Describe the bug
Running npx @ui5/ts-interface-generator command in project containing mixins causing following error:

AppData\Local\npm-cache\_npx\a388873ad1487e68\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:172
                                throw new Error(`Type '${typeNode.getText()}' referenced in ${sourceFile.fileName} in the inheritance clause '${heritageClause.getFullText()}' could not be resolved.
                                ^

Error: Type 'ClassA(ClassB)' referenced in ClassC.ts in the inheritance clause ' extends ClassA(ClassB)' could not be resolved.
Check the respective line in the source code: ts there an error for this type? Make sure the type is properly imported.
If a working "import" is not possible and it is a UI5 type (or type from another library), the issue could be caused by the respective type definitions not being available. They must be found by the TypeScript compiler according to the configuration in tsconfig. To verify this step-by-step, you can do the following:
1. Check whether the (UI5 or other) types are added as dependency in package.json (or available as transitive dependency)
2. Check inside which "node_modules" folder the types are actually available - if they are not, check whether "npm install" (or "yarn" etc.) has run successfully - maybe re-run it
3. Check the "tsconfig.json" file: types outside the default "@types" package must be explicitly added in the "types" or "typeRoots" section. Is the name and path correct?
One known cause of this error is that the "typeRoots" setting in tsconfig.json has wrong paths, which are not actually pointing to the correct location of the type definitions.
Or is there a different reason why this type would not be known?
    at AppData\Local\npm-cache\_npx\a388873ad1487e68\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:172:39
    at Array.forEach (<anonymous>)
    at AppData\Local\npm-cache\_npx\a388873ad1487e68\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:168:46
    at Array.forEach (<anonymous>)
    at AppData\Local\npm-cache\_npx\a388873ad1487e68\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:166:43

This happens whenever project contains file with mixin akin to:

export default class ClassC extends ClassA(ClassB) {
// ...
}

Current workaround is to have separate tsconfig-generate-ts-interfaces.json file which excludes files containin mixin, and pass this file to --config parameter of interface generator.

Expected behavior
Successful type generation for project containing mixins.

Additional context
Reproduced in @ui5/[email protected]

Lenguaje dominante
TypeScript
Estrellas
213
Forks
35
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de UI5/typescript

Todos los issues de UI5/typescript

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.