"NestModule" , "NestMiddleware", "MiddlewareConsumer" has no exported member in types/#nestjs/common - middleware

I am new to NestJs and tried implementing the middleware specified in NestJs documentation,
https://docs.nestjs.com/middleware
When NestMiddleware is imported i am getting the following error
" Module '"../../types/#nestjs/common"' has no exported member 'NestMiddleware'". and similar errors while importing "NestModule" and "MiddlewareConsumer'.
Iam using nestJs version 6.0.0

NestModule, MiddlewareConsumer, and NestMiddleware are all imported from #nestjs/common. From your project root, that would be <root>/node_modules/#nestjs/common/index. If you are having trouble importing these sources, you may need to re-install your dependencies.

Related

Dart plugin dynamic linking

I am having trouble utilising the libserialport.dart package. I have put a libserialport.so in the root of the project. When trying to run an application I get the following error:
Unhandled exception: Invalid argument(s): Failed to load dynamic library 'libserialport.so': libserialport.so: cannot open shared object file: No such file or directory
This tells me that the package is looking for the file somwhere else - but where?
The original library links the library this way, which results in it not finding the library:
LibSerialPort? _dylib;
LibSerialPort get dylib {
return _dylib ??= LibSerialPort(ffi.DynamicLibrary.open(
resolveDylibPath(
'serialport',
dartDefine: 'LIBSERIALPORT_PATH',
environmentVariable: 'LIBSERIALPORT_PATH',
),
));
}
If I replicate the plugin locally, but changing the linking as such, the library works as expected:
var libraryPath =
path.join(Directory.current.path, 'libserialport.so');
LibSerialPort? _dylib;
LibSerialPort get dylib {
return _dylib ??= LibSerialPort(ffi.DynamicLibrary.open(libraryPath));
}
The question is: where to put the .so file so it would work with the original verison? Where does resolveDylibPath() link to?
If possible I would like to avoid using my modified version as that brings license implications I am not entirely sure how to deal with.
Apparently the function looks for the path in the LIBSERIALPORT_PATH enviroment variable. Setting it to '.' made it work!
In the terminal:
export LIBSERIALPORT_PATH=.

Errors when using parseCpp to parse C++ files

I am trying to use Clair and Rascal to analyze C++ files.
I followed the instructions on the Github page of Clair to add Clair to an empty Rascal project. After importing the required modules successfuly, I attempted to call parseCpp to parse a C++ file and got the following errors:
rascal>parseCpp(|project://myproject3/myFile.cpp|);
|jar+file:///Users/rh07/.m2/repository/org/rascalmpl/clair/0.4.0/clair-0.4.0.jar!/src/lang/cpp/AST.rsc|(24317,206,<455,0>,<456,167>): Java("NoSuchMethodError","\'io.usethesource.vallang.IString org.rascalmpl.library.Prelude.readFile(io.usethesource.vallang.ISourceLocation)\'")
at lang.cpp.internal.CDTParser.parseFileAsCpp(|unknown:///CDTParser.java|(0,0,<202,0>,<202,0>))
at lang.cpp.internal.Parser.parseCpp(|unknown:///Parser.java|(0,0,<349,0>,<349,0>))
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(|unknown:///NativeMethodAccessorImpl.java|(0,0,<0,0>,<0,0>))
at parseCpp(|jar+file:///Users/rh07/.m2/repository/org/rascalmpl/clair/0.4.0/clair-0.4.0.jar!/src/lang/cpp/AST.rsc|(24516,5,<456,160>,<456,165>)Beginning at 2022-11-25T11:35:54.827391Z
WARNING: ResourcesPlugin was null, can't get workspace; not overriding include files
How I can get parseCpp to work? Thanks.
The error is caused by a bad combination of versions. Please use clair-0.5.0 (just released) which will work with rascal-0.27.2 that is distributed with the Rascal VScode extension 0.5.5.
Adopt the pom.xml like so:
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>clair</artifactId>
<version>0.5.0</version>
</dependency>

Adding native swift code to NativeScript application

I'm trying to add native swift code to my NativeScript app. According to these instructions in the documentation I can just add a swift source file to App_Resources/iOS/src/ and then use any publicly exposed classes directly in my TypeScript code.
Unfortunately this just doesn't work. I'll just get Cannot find name 'TestClass' and that's it.
Steps to reproduce:
Get a fresh NS project with ios tns create my-app-name --template tns-template-blank-ts
Update: I actually created the App with vue init nativescript-vue/vue-cli-template testapp. That seems to have caused the problems.
Add a TestClass.swift to App_Resources/iOS/src/
import Foundation
public class TestClass: NSObject {
#objc public func echo(param: String) -> String {
return param
}
}
Instantiate it in any TypeScript source file let instance = new TestClass()
Do tns debug ios
Compilation will fail with Cannot find name 'TestClass'
I have also tried generating TypeScript typings with TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios or or just delcaring it as any with declare let KeyCommander: any; to eliminate the possibility that this is a TS related problem. The first approach doesn't generate any typings for my custom class so the TypeScript code will still not compile. The second approach let's the TS code compile but crashes on execution with JS ERROR ReferenceError: Can't find variable: TestClass.
I have also verified that the swift file is indeed getting compiled by inserting a syntax error which will crash the build process.
My NativeScript version is 6.4.0.
What am I missing?
Update: I just realized I actually created the App with vue init nativescript-vue/vue-cli-template testapp. I verified that as mentioned Tyler Blake's answer in an app created with the tns cli the described process actually works. In an app I just freshly created with vue init it doesn't, the objc!nsswiftsupport.d.ts is not being generated.
The question now is: What's causing the difference?
I followed your steps and I was able to get the typings to generate in objc!nsswiftsupport.d.ts. After you generate typings do you have that file with these contents?
declare class TestClass extends NSObject {
static alloc(): TestClass; // inherited from NSObject
static new(): TestClass; // inherited from NSObject
echoWithParam(param: string): string;
}
This shows that NS is able to pick up the Swift code.
All you need to do now is add tns-platform-declarations then in the references.d.ts file, add a line that points to the objc!nsswiftsupport.d.ts file. Then you'll get intellisense in your TS code.
Something like this:
/// <reference path="./typings/objc!nsswiftsupport.d.ts" />
Hope this helps!
I was able to solve the problem by inspecting the differences between the templates created with tns-cli and vue init. The difference is that the vue init template ships with an outdated version of the nativescript platform. You can just simply change
"tns-ios": {
"version": "6.0.1"
}
to version 6.4.0 (which the version the tns-cli template comes with) and then the process will work as described in the documentation.

XlsLib integration in IOS Application

I'm trying to integrate xlslib in my app. After compiling and installing lib, I have added this in my code. Then I got the error shown below:
format_t::format_t(CGlobalRecords& gRecords, const u16string& fmtstr) :
formatstr(fmtstr),
index(0),
m_usage_counter(0),
m_GlobalRecords(gRecords)
{
}
Errors:
format.cpp:125:52: Reference to 'u16string' is ambiguous
Out-of-line definition of 'format_t' does not match any declaration in
xlslib_core::format_t
while in format.h file, declaration as below
format_t(CGlobalRecords& gRecords, const u16string& fmtstr);
Can any one help to solve this issue?
Why didn't you post a bug report on the SourceForge page? In any case, the xlslib project has been updated and now offers the DHxlslibIOS library that you can incorporate as is into your project. You can download a zipped package here with the latest 2.4.0b1 source, or pull it from SVN. The framework is in the DHxls directory.

Adding Symfony Yaml To Silex

I am looking to add symfony's yaml component to Silex however I am having issues with adding the 5.3 version. Adding the none namespaced version works fine but I would rather have the namespaced version from https://github.com/symfony/Yaml. This is my service provider:
public function register(Application $app)
{
if (isset($app['classPath'])) {
$app['autoloader']->registerNamespace('Symfony\Component\Yaml', $app['classPath']);
}
}
But when I do this is code:
use Symfony\Component\Yaml\Yaml;
Yaml::load(__DIR__ . '/../configuration/application.yml');
I receive the error of:
Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in
/mnt/hgfs/silex/web/index.php on line 20
Full Correct Answer:
gregoire made a comment about registering the Symfony namespace, not the Symfony\Comonent\Yaml so I basically recreated the directory structure for the namespace and registed the root of the to the Symfony namespace and that works great.
Now that silex is using composer, I am just using composer to include it.

Resources