Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unused import generated #1232

Closed
cpaulve-1A opened this issue Jan 16, 2024 · 0 comments
Closed

[Bug]: Unused import generated #1232

cpaulve-1A opened this issue Jan 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@cpaulve-1A
Copy link
Contributor

Package name

schematics

Package version

9.5.*

Reproduction steps

Run schematics @ama-sdk/schematics:typescript-core from a project with enums for instance.

Current result

When running the sdk generator for typescript, many imports are added without any reference to them. Not only this is confusing, but some of these imports do not even exist within the code generated,

Expected result

Useless imports should not be generated in the different files. There should be no reference to inexistant methods

Additional comments

No response

@cpaulve-1A cpaulve-1A added the bug Something isn't working label Jan 16, 2024
@cpaulve-1A cpaulve-1A self-assigned this Jan 16, 2024
cpaulve-1A added a commit that referenced this issue Jan 16, 2024
To avoid references to revivers of non object models in the reviveModel, the generator checks the nonObjectDefinition vendor of the property

As a reviver should revive both its properties and the ones inherited from the parents,

it is based on the allVars property which was forgotten prior to this PR

An additional fix cleans the unused import
@cpaulve-1A cpaulve-1A changed the title [Bug]: Unused import generatted [Bug]: Unused import generated Jan 16, 2024
cpaulve-1A added a commit that referenced this issue Jan 17, 2024
To avoid references to revivers of non object models in the reviveModel, the generator checks the nonObjectDefinition vendor of the property

As a reviver should revive both its properties and the ones inherited from the parents,

it is based on the allVars property which was forgotten prior to this PR

An additional fix cleans the unused import
cpaulve-1A added a commit that referenced this issue Jan 18, 2024
To avoid references to revivers of non object models in the reviveModel, the generator checks the nonObjectDefinition vendor of the property

As a reviver should revive both its properties and the ones inherited from the parents,

it is based on the allVars property which was forgotten prior to this PR

An additional fix cleans the unused import
cpaulve-1A added a commit that referenced this issue Jan 18, 2024
## Context
To avoid reviving non object models in the revivers, the generator
checks the nonObjectDefinition vendor of the property. This means that
the property is based on a model which is not an object and therefore
cannot be revive, the revival will be skipped.

As a reviver should handle both the model properties and the ones
inherited from the parents, it is based on the allVars property which
was forgotten prior to this PR.
Today, we do not add the correct vendor on the allVar property used in
the templates but rely on the isEnumRef and isEnum property of the
models. Unfortunately, they are false in case of Maps and Arrays.

## Proposed change
Add nonObjectModel vendor to the allVars properties and remove the logic
to detect enum within Map and Array as it is faulty.
An additional fix cleans the unused import to avoid any reference to
unused or non-existant models

## Related issues

- 🐛 Fixes #1232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant