release/5.0.0-CF1 Spartacus coping module from source results in error TS2532: Object is possibly 'undefined' - spartacus-storefront

I generate project using release/5.0.0-CF1 libraries and when I take order-history module from source code and paste it into my newly generated project (also adding it to spartacus-features.module.ts) it results with error TS2532: Object is possibly 'undefined' in order-history.component.html
Console output
package.json and all dependencies are the same as in release.
Checked tsconfig.json if strictNullChecks is disabled on source, it's not but works.
When I disable it in my project, everything is ok :)

Strict mode features for older spartacus modules were not enabled when they were developed. Therefore, there will be issues if you copy the component into your project and have strict checks enabled. You will need to disable them or improve them in your custom component.
Do you have strictTemplates enabled in your tsconfig.json? This is a feature that enforces null checking on templates that is not enabled by default in Spartacus for most libraries. When added to the src tsconfig in the cloned Spartacus lib, you will also start to see these template errors on build.

Related

javascript as target in kotlin multiplatform library

I'm building a Kotlin multiplatform library. One of the targets in this project is javascript. In the source set I have added a dependency like this:
val jsMain by getting {
dependencies {
implementation(npm("libphonenumber-js", "1.10.13"))
}
}
The gradle sync was successful, now I want to import the files in jsMain directory. How can I achieve this?
Add npm dependency with generateExternals as you already did
implementation(npm("libphonenumber-js", "1.10.13", generateExternals = true))
generateExternals = true triggers a tool called Dukat that generates Kotlin external declarations from the Typescript definition file of that npm module.
Once your project syncs, it would have externals folder under your shared module's build folder like shown below,
(Ignore kmp-lib-1621 in above image. That would be your module/library name instead)`
Now copy and paste these files in your project (jsMain source set) and remove generateExternal = true from your dependency otherwise it would generate this files everytime. (1) you would lose any manual change (2) if you update the library version then it can potentially break your project
You should be able to call generated external code from Kotlin code, whether you keep it in build folder or you pasted it in your project code.
Important Note: Dukat tool is experiemental and known to create externals that may not work 100% times. So remove all unnecessary code from external generated code so you only end up having few references of classes you want to use from the npm library. Do some trial and error and you would be fine.
Hope this helps!
You have to use js(IR) backend and generate externals
implementation(npm("libphonenumber-js", "1.10.13", generateExternals = true)).

Enable rendering asciidoc operation in InteliJ Idea

Documenting rest api using spring-restdocs in InteliJ Idea is fine, but I missing rendered "include" snippets of operation macro.
== Get Comments sorted
To get sorted according single attribute and with no specific ordering (asc-ending is default), you can refer to this example:
operation::comments/getSortedDescending[snippets='http-request,path-parameters,http-response']
I would expect that somehow I can enable spring-restdocs-asciidoc artefact to be used when rendering things in InteliJ Idea with asciidoctor plugin.
Associated issue https://github.com/asciidoctor/asciidoctor-intellij-plugin/issues/310
I've had a look at spring-restdocs-asciidoctor. The operation::[] is an extension that renders the content. It relies on an attribute snippets that needs to be set.
The IntelliJ plugin for AsciiDoc supports both ruby extensions and attributes for previews as experimental options.
To make it work I did the following:
checkout the project
running gradlew asciidoctor to generate the snippets
add a file .asciidoctorconfig to set the path to the generated snippets
add a directory .asciidoctor and place the extension in this directory
confirm the warning message "This project contains Asciidoctor Extensions..." in the IDE
You need to confirm the warning message every time you restart your IDE. As it will run Ruby code locally, this is a security issue. Maybe we'll enhance it in the future so you only need to reconfirm it once the extension's code changes.
The changes are on the following branch: https://github.com/ahus1/spring-restdocs/tree/poc_extension_intellij

Meteor iron:router as library in Intellij 14

I'm attempting to mark all packages in my Meteor project as JavaScript libraries so I can have features such as auto-completion, etc. in Intellij 14.
Following the instructions found here:
I opened up the package.json file under /.meteor,
clicked on the "import packages as libraries" option (yes, iron:router is listed)
However, the Router object remains unresolved, even though it worked for the other libraries. I noticed someone mentioned later:
Code completion for other Underscore.js functions such as bind, partial, etc and packages like Iron:Router and others are not as complete
Edit:
Pressing alt-enter with the Router object selected, as Matt K suggested, only gives the options of creating a variable named "Router" or renaming the reference, not actually resolving the iron:router library as a dependency.
Does anyone have any suggestions on resolving the iron router library?
Turns out this was as easy as I thought it was with going to .meteor/packages.json and clicking on "import packages as libraries". Not sure what the issue was before but following that same 2-step process whenever the listing changes solves any library recognition issues.

Android Studio Lint check for Unnecessary Module Dependency

When running a Lint check on files in my project I often come across an error that looks like this (actual names of files redacted, but you'll get the idea):
Dependency from module 'name_of_my_project' on module
'some_3rd_party_library' could be probably be removed when
complementary scope to 'File 'filepath_to_the_class_being_analyzed'
also does not contain references on module 'some_3rd_party_library'
I get this error for every single library that isn't compiled with Gradle - i.e. libraries that have been imported whole into the project and then added as dependencies.
Facebook is a great example of a library that even if you wanted to compile it through Gradle you couldn't because they don't support it, and you need to run it as a local library - it seems like you'll then receive this "unnecessary module dependency" warning for every class that doesn't directly call Facebook.
So, the question is - what is the "proper" way of handling this error? Do I ignore it or am I supposed to change the code in some way to make it disappear?
Edit: in the preferences menu for Lint it describes the check as follows (in case this helps figure it out):
This inspection lists modules which contain redundant dependencies on
other modules. These dependencies can be safely removed.
There are known issues with the Lint checkers. I do not get this error in Android Studio 2.1.1. However, if you still do and you know it to be spurious, I would recommend going to Settings --> Editor --> Inspections --> Unnecessary Module Dependency and changing the Severity type from Warning to Info. This way you get a "clean lint build" and avoid a "broken windows" type of state due to bad lint algo. In fact, I've created a special category that has Info severity called Info Due To Bad Lint Algo to which I've assigned whatever I know to be spurious. This way I can periodically review those and see if they've been fixed.
You should report this to them btw, so there is some hope of it getting fixed... Good luck!
You can avoid lint checking using following block of code.
Add following block of code into app build.gradle file inside android {}
lintOptions {
checkReleaseBuilds false
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, only report errors
ignoreWarnings true
abortOnError false
disable "ResourceType"
}

Dependencies between plugins

I wrote an app which uses plugins, everything is ok, I made my plugins with the bundle template of Xcode.
Now, I need to write a plugin that depends on another plugin, let's say plugin A depends on plugin B.
I tried to link plugin A with plugin B by adding it to the project (link binary with libraries) but that does not work (tried with the full bundle and with the plugin object file inside the bundle).
The only way I found for the moment is to add source files of plugin B to the plugin A but it is bad because in the application, both plugin A and B contains same code (Class X is implemented in both Y and Z. One of the two will be used. Which one is undefined).
How can I implement that ? Thank you
Ok, I found a way to achieve that.
Just copy or reference the header of the classes I need and then use the -U linker flag (in the Other Linker Flags option) in the following form :
-Wl,-U -Wl,_OBJC_CLASS_$_NameOfTheClass
(Wl option is needed, see here why : http://www.cocoabuilder.com/archive/xcode/264371-ld-undefined-symbols-argument-is-ignored.html )
The -U flag for a class allows to compile without having the definition of the class.
With that, I can compile the plugin without duplicating the code of plugin on which I depend.