Can't use imported class as a return type in TypeScript - import

I can't use imported Command class as a return type even if it is possible to create Command instance like (let parser = new Command();)
My tsc version is,
$ src git:(master) ✗ tsc --version
Version 1.8.0-dev.20151222
Am I missing something?

That's because commander.IExportedCommand.Command is not a type but a variable. You can either use typeof Command or use the actual name of that type commander.ICommand.
function create(args: string[]): typeof Command;
// or
function create(args: string[]): commander.ICommand;

Related

How to make AOSP Module with Specified JDK Version?

As when I do complete compile ,some modules use jdk1.9 , some use jdk1.8(because the date 0 bug, it can not compile with jdk1.9).
So how can I specify the special JDK when complete compile for some special modules? how to config the special jdk version in Android.mk?
For AOSP 10: it is LOCAL_JAVA_LANGUAGE_VERSION in Android.mk.
Since:
build\soong\androidmk\cmd\androidmk\android.go:
"LOCAL_JAVA_LANGUAGE_VERSION": "java_version",
build\soong\java\java.go:
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext)
calls
func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path)
calls
func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaBuilderFlags
calls
func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaBuilderFlags
calls
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) string
Based on getJavaVersion's source code, if the parameter "javaVersion " is empty (guess when LOCAL_JAVA_LANGUAGE_VERSION is not set), it will return version based on Android version etc, if "javaVersion" is not empty then it is returned and put into the java build command line by its caller collectBuilderFlags.
In collectBuilderFlags, that parameter comes from j.properties.Java_version which should comes from "LOCAL_JAVA_LANGUAGE_VERSION" due to the above information from android.go.
Also per the source code of collectBuilderFlags, you can only use LOCAL_JAVA_LANGUAGE_VERSION to set the "-source" and "-target" parameter of javac. Every javac command invocation in AOSP10 is the javac from JDK9, i.e. prebuilts/jdk/jdk9/linux-x86/bin/javac

data-service Compiling and running versions greater than 0.18.1

I can't start the API starting from version 0.18.1. Example version 0.20.0 I get an error:
/home/ubuntu/data-service/node_modules/ts-node/src/index.ts:261
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts(15,34): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
src/index.ts(26,35): error TS2345: Argument of type '{ expose: string; header: boolean; }' is not assignable to parameter of type '{ expose?: string | undefined; header?: string | undefined; query?: string | undefined; }'.
Types of property 'header' are incompatible.
Type 'boolean' is not assignable to type 'string | undefined'.
I tried different versions in different variants. But the errors are almost the same.
what versions and what do you use for compilation? Maybe I am launching wrong?
There is one nuance that makes me roll back to jest#23.6.0
Because it is needed for ts-jest.
How correct?
We don't actually use ts-node to launch the app. One of the reasons we've stopped using it is that it sometimes produces cryptic errors even when the tsc compiles fine.
Try launching this way (requires ENV vars):
npm run build
node dist/index.js
It seems that you're using an old version of TS.
We use:
ts-node 7.0.1
typescript 3.2.2

Possible to change the package name when generating client code

I am generating the client scala code for an API using the Swagger Edtior. I pasted the json then did a Generate Client/Scala. It gives me a default root package of
io.swagger.client
I can't see any obvious way of specifying something different. Can this be done?
Step (1): Create a file config.json and add following lines and define package names:
{
"modelPackage" : "com.xyz.model",
"apiPackage" : "com.xyz.api"
}
Step (2): Now, pass the above file name along with codegen command with -c option:
$ java -jar swagger-codegen-cli.jar generate -i path/swagger.json -l java -o Code -c path/config.json
Now, it will generate your java packages like com.xyz… instead of default one io.swagger.client…
Run the following command to get information about the supported configuration options
java -jar swagger-codegen-cli.jar config-help -l scala
This will give you information about supported by this generator (Scala in this example):
CONFIG OPTIONS
sortParamsByRequiredFlag
Sort method arguments to place required parameters before optional parameters. (Default: true)
ensureUniqueParams
Whether to ensure parameter names are unique in an operation (rename parameters that are not). (Default: true)
modelPackage
package for generated models
apiPackage
package for generated api classes
Next, define a config.json file with the above parameters:
{
"modelPackage": "your package name",
"apiPackage": "your package name"
}
And supply config.json as input to swagger-codegen using the -c flag.

error in creating new hook method in PostgreSQL

I have written a plugin module for PostgreSQL for my academic requirements(version: PostgreSQL9.3.4) I am using hooks to influence planner behaviour in this plugin module. I am able to use join_search_hook, planner_hook successfully. But I wanted to create a new hook for a method which is not already having a hook defined.
I wanted to define a hook for
void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
method in costsize.c
I declared a hook in optimizer/paths.h
typedef void (*size_estimates_hook_type) (PlannerInfo *root, RelOptInfo *rels);
extern PGDLLIMPORT size_estimates_hook_type size_estimates_hook;
and initialized it at top of allpaths.c
size_estimates_hook_type size_estimates_hook = NULL;
I added this check in allpaths.c in a method to decide whether to invoke hooked method or not.
if (size_estimates_hook)
(*size_estimates_hook) (root, rel);
else
set_baserel_size_estimates(root, rel);
Now coming to plugin module code,
static join_search_hook_type prev_join_search = NULL;
static size_estimates_hook_type prev_size_estimates = NULL;
The first line compiles fine, but second line gives error
"error: unknown type name ‘size_estimates_hook_type’"
Am i missing some step in defining a new hook method?
note: Plugin is compiled using a dedicated Makefile.
Using the following makefile for compiling the plugin module solved the issue.
MODULES = module_name
ifdef USE_PGXS
PG_CONFIG = <path to /backend/bin/pg_config>
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/module_name
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

Doing git pull in Engine Yard

I am deploying my rails app to Engine Yard.
What i had so far:
1. created SSH hey
2. Install public key to Engine Yard app.
3. ssh deploy#my.server.ip.address
I was put at home/deploy, which is not a right place to perform git pull.
The reason I need to deploy in this way, is because my app is using nmatrix gem, which need to be installed manually using c++ compiler. The automatic bundler got an error while fetching that gem, and stopped.
Update:
I guess my question should be, how to install nmatrix to EngineYard. This is the error message I got from calling gem install nmatrix:
Building native extensions. This could take a while...
ERROR: Error installing nmatrix:
ERROR: Failed to build gem native extension.
/usr/bin/ruby21 extconf.rb
checking for main() in -llapack... no
checking for main() in -lcblas... yes
checking for main() in -latlas... no
checking for clapack.h... no
checking for cblas.h... yes
checking for cblas.h... yes
checking for clapack_dgetrf() in cblas.h,clapack.h... no
checking for clapack_dgetri() in cblas.h,clapack.h... no
checking for dgesvd_() in clapack.h... no
checking for cblas_dgemm() in cblas.h... yes
using C++ standard... c++0x
g++ reports version... Hardened
creating nmatrix_config.h
creating Makefile
make "DESTDIR="
compiling nmatrix.cpp
In file included from nmatrix.cpp:331:0:
ruby_nmatrix.c: In function ‘VALUE nm_mset(int, VALUE*, VALUE)’:
ruby_nmatrix.c:1378:108: warning: format ‘%u’ expects type ‘unsigned int’, but argument 4 has type ‘size_t’
ruby_nmatrix.c: In function ‘VALUE nm_xslice(int, VALUE*, void* (*)(const STORAGE*, SLICE*), void (*)(NMATRIX*), VALUE)’:
ruby_nmatrix.c:1556:91: warning: format ‘%u’ expects type ‘unsigned int’, but argument 4 has type ‘size_t’
ruby_nmatrix.c: In function ‘SLICE* get_slice(size_t, int, VALUE*, size_t*)’:
ruby_nmatrix.c:1903:104: warning: format ‘%u’ expects type ‘unsigned int’, but argument 3 has type ‘size_t’
ruby_nmatrix.c:1903:104: warning: format ‘%u’ expects type ‘unsigned int’, but argument 4 has type ‘size_t’
compiling ruby_constants.cpp
compiling data/data.cpp
compiling util/io.cpp
compiling math.cpp
In file included from math.cpp:140:0:
math/rot.h: In function ‘void nm::math::rot(int, DType*, int, DType*, int, CSDType, CSDType) [with DType = nm::Complex<float>, CSDType = float]’:
math/rot.h:123:40: error: ‘cblas_csrot’ was not declared in this scope
math/rot.h: In function ‘void nm::math::rot(int, DType*, int, DType*, int, CSDType, CSDType) [with DType = nm::Complex<double>, CSDType = double]’:
math/rot.h:128:40: error: ‘cblas_zdrot’ was not declared in this scope
In file included from math.cpp:141:0:
math/rotg.h: In function ‘void nm::math::rotg(DType*, DType*, DType*, DType*) [with DType = nm::Complex<float>]’:
math/rotg.h:99:125: error: ‘cblas_crotg’ was not declared in this scope
math/rotg.h: In function ‘void nm::math::rotg(DType*, DType*, DType*, DType*) [with DType = nm::Complex<double>]’:
math/rotg.h:104:125: error: ‘cblas_zrotg’ was not declared in this scope
make: *** [math.o] Error 1
Gem files will remain installed in /home/deploy/.gem/ruby/2.1.0/gems/nmatrix-0.0.9 for inspection.
Results logged to /home/deploy/.gem/ruby/2.1.0/gems/nmatrix-0.0.9/ext/nmatrix/gem_make.out
One of the prerequisite to install nmatrix is to have gcc > v4.7, but EngineYard is having v4.5.4 only. Anyone know how to upgrade gcc? I think I am running Gentoo.
The question actually should include what you want to git pull.
When you ssh in, you are put into /home/deploy which is your home directory.
The Git copy of your app is located in /data/APPNAME/shared/cache-copy/ on the App Master
You can have multiple apps on one instance and each one can have a different deploy key so you use a GIT_SSH wrapper
GIT_SSH=/data/APPNAME/shared/config/pulse-ssh-wrapper git pull
(in all the above commands remember to replace APPNAME with the name used for the app)
If you want to find the actual location for a bundled gem, you can look in
/data/APPNAME/shared/bundled_gems/ruby/2.0.0/gems (version will depend on Ruby ABI)
if your Gemfile uses a :git remember that only a single deploy key can be used for both the app clone and bundle phase, you cannot select different keys per gem.
Most likely the issue with installing the nmatrix gem is that the ATLAS libraries are not installed yet and those would be installed with the system's package manager (Portage for Gentoo and Apt-get for Ubuntu). You can add them via "Edit Unix Packages" on the UI, just select sci-libs/blas-atlas and sci-libs/lapack-atlas. Currently this will fail because the EC2 instances are Xeon processors and the libraries do not build on these yet.
http://sourceforge.net/p/math-atlas/support-requests/614/
https://bugzilla.kernel.org/show_bug.cgi?id=13794
You can see the CPU type on your Linux instance with "cat /proc/cpuinfo" and will see something like
model name :Intel(R) Xeon(R) CPU E5-2650 0 # 2.00GHz