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

1756 - Fix TypeScript Namespace Import Generation #1

Conversation

ScottMorris
Copy link
Owner

@ScottMorris ScottMorris commented Aug 4, 2017

This was made in error!

Fixes #1756. Adds support to the TypeScript Visitor to generate import statements for property types in other namespaces in other generated files.

Checklist

  • A link to the issue/user story that the pull request relates to
  • How to recreate the problem without the fix
  • Design of the fix
  • How to prove that the fix works
  • Automated tests that prove the fix keeps on working
  • Documentation - any JSDoc, website, or Stackoverflow answers?

Issue/User story

Steps to Reproduce

  1. Create models with references to namespaces in other CTO files.
  2. Run composer generator create.
  3. Inspect/Try to compile the generated TypeScript.

Existing issues

When asking about the issue in Rocket Chat it was recommended to submit a GitHub Issue.

Design of the fix

The high level design of the fix is to find all non primitive property types within the class declarations, except enums, within a specific model and index them. Then the namespace imports for the specific model are also indexed and the types that aren't in the current file are added as TypeScript import statements importing the type from the file it is located in.

Validation of the fix

I've included the before and after generated files along with a diff of one of the files generated.

Automated Tests

Not sure what tests I should create for this, any suggestions are welcome and I will update accordingly.

What documentation has been provided for this pull request

Not sure what documentation I should generate, any suggestions are welcome.

jt-nti and others added 2 commits August 3, 2017 11:33
* Bump version to 0.11.0 for release

Signed-off-by: James Taylor <jamest@uk.ibm.com>

* Correct .mp4 video filename for Playground import

* fullstop missing

* Add some firm warnings to not use v0.6 of Fabric

* Fix version of loopback-boot (davidkel's fix for the REST server)

Signed-off-by: James Taylor <jamest@uk.ibm.com>
@ScottMorris ScottMorris merged commit ede185f into ScottMorris:typescriptCodeGenMissingExternalImports Aug 4, 2017
@ScottMorris ScottMorris self-assigned this Aug 4, 2017
@ScottMorris ScottMorris changed the title 1756 - Fix TypeScript Namespace Import Generation - Fix TypeScript Namespace Import Generation Aug 4, 2017
@ScottMorris ScottMorris changed the title - Fix TypeScript Namespace Import Generation 1756 - Fix TypeScript Namespace Import Generation Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants