-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: check dependencies when adding imports #1239
Conversation
@@ -114,19 +142,54 @@ public TypeScriptWriter addIgnoredDefaultImport(String name, String from, String | |||
*/ | |||
@Deprecated | |||
public TypeScriptWriter addImport(String name, String as, String from) { | |||
boolean isNodePackage = from.startsWith("node:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should a class wrap the String input from
to provide answers like boolean isNamespaced
, boolean isNodeJSNativePackage
, String getPackageName
etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That probably should go in Dependency
in the long run.
public TypeScriptWriter addImport(String name, String as, PackageContainer from) { | ||
if (from instanceof Dependency) { | ||
addDependency((Dependency) from); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the long run, we should move it to taking Dependency
as the third parameter.
...t-codegen/src/main/java/software/amazon/smithy/typescript/codegen/validation/ImportFrom.java
Show resolved
Hide resolved
* fix: check dependencies when adding imports * avoid method overload with super type * handle node: prefix package imports * exempt node: prefix packages from enforced registration * remove addImportUnchecked * remove stray deprecation tag * convert import logic to class * comment grammar * add internalapi annotation to ImportFrom
* fix: check dependencies when adding imports * avoid method overload with super type * handle node: prefix package imports * exempt node: prefix packages from enforced registration * remove addImportUnchecked * remove stray deprecation tag * convert import logic to class * comment grammar * add internalapi annotation to ImportFrom
when calling
addImport
, the TSWriter will either add the import or throw an error if it determines the import is a non-native package and has not been added via addDependency.this is to prevent calls to
addImport
that forget to also calladdDependency
.