modelina icon indicating copy to clipboard operation
modelina copied to clipboard

feat!: export and import interfaces as types when using named imports and ESM Module Syntax

Open marakalwa opened this issue 2 years ago • 6 comments

Description

When using modelType 'interface', exportType 'named' and moduleSystem 'ESM' export and import interfaces as types to support verbatimModuleSyntax. This should not be a breaking change, interfaces are types even when not using verbatimModuleSyntax, explicitly marking them as types is optional in that case though.

Related Issue

fixes #1793

Checklist

  • [x] The code follows the project's coding standards and is properly linted (npm run lint).
  • [x] Tests have been added or updated to cover the changes.
  • [ ] Documentation has been updated to reflect the changes.
  • [x] All tests pass successfully locally.(npm run test).

Additional Notes

This PR also includes a change that makes sure only interfaces are imported/exported as types, as the previous version of this PR also exported enums as types.

marakalwa avatar Mar 09 '24 23:03 marakalwa

Deploy Preview for modelina canceled.

Name Link
Latest commit 8dff9369b8748c6fa696af4464cf955af51149db
Latest deploy log https://app.netlify.com/sites/modelina/deploys/65ecf7b7e594030008a0904c

netlify[bot] avatar Mar 09 '24 23:03 netlify[bot]

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Mar 09 '24 23:03 sonarqubecloud[bot]

Pull Request Test Coverage Report for Build 8218001195

Details

  • 8 of 9 (88.89%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 92.323%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/generators/typescript/TypeScriptDependencyManager.ts 5 6 83.33%
<!-- Total: 8 9
Files with Coverage Reduction New Missed Lines %
src/generators/typescript/TypeScriptDependencyManager.ts 1 94.87%
<!-- Total: 1
Totals Coverage Status
Change from base Build 8203318802: 0.02%
Covered Lines: 6000
Relevant Lines: 6331

💛 - Coveralls

coveralls avatar Mar 10 '24 00:03 coveralls

Gonna have to re-target to next because of the breaking changes to the dependency manager (it's exposed to users). Just need to make a quick update #1876 before I can do it.

Do you mind adding those changes to the migration docs: https://github.com/asyncapi/modelina/blob/next/docs/migrations/version-3-to-4.md

You should be able to easily merge next into your branch 🙂

Are you sure this needs to go into the migration guide? This should not break anything afaik, environments that haven't used verbatim module Syntax before should still work with interfaces now exported/imported as types and environments that do will now work without causing errors. 🤔 I could certainly add this into the migration guide, it feels wrong there though as there is no action required.

marakalwa avatar Mar 24 '24 15:03 marakalwa

Are you sure this needs to go into the migration guide? This should not break anything afaik, environments that haven't used verbatim module Syntax before should still work with interfaces now exported/imported as types and environments that do will now work without causing errors.

Its not the new feature that is breaking, but the syntax of the dependency manager functions, which are public interface for people to use 🙂

jonaslagoni avatar Mar 24 '24 19:03 jonaslagoni