Vue import failing - import

I've created a vue application scaffolded from the vue cli. Almost everything is reacting as expected with my app except for an issue with import.
The following works fine:
import Vuex from 'vuex';
but, this throws errors:
import { VuetronVue, VuetronVuex } from 'vuetron';
vue.use(VuetronVue);
Linting error:
"export 'VuetronVue' was not found in 'vuetron'
and Console error:
Uncaught TypeError: Cannot read property 'install' of undefined
Changing the code to:
import vuetron from 'vuetron'
vue.use(vuetron.VuetronVue);
resolves the issue...
This original code was taken directly from the Vuetron documentation. Does anyone have a suggestion as to why the ES6 notation would cause an issue?

This seems to be because
vuetron/packages/vuetron-plugins/index.js
only exports the default object:
import VuetronVue from './vuetron-vue';
import VuetronVuex from './vuetron-vuex';
export default {
VuetronVue,
VuetronVuex
};
For named imports as stated in the docs you would need a named export.

Related

Tanka - VS Code - "Unexpected type string" while getting namespace from spec file

I'm trying out Tanka for k8s configs generation. Also, I'm using VS Code extension by Grafana Labs.
I've problems in VS Code with referencing Tanka configuration as described here. I'm using configuration to retrieve namespace, like so:
local k = import 'k.libsonnet';
local tk = import 'tk';
{
namespace: k.core.v1.namespace.new(tk.env.spec.namespace),
}
Initially, I was receiving an error: RUNTIME ERROR: Undefined external variable: tanka.dev/environment. I supposed that Tanka wants path to my environment, and so added it to VS Code settings:
{
"jsonnet.languageServer.extVars": {
"tanka.dev/environment": "environments/default"
}
}
Now I'm receiving another error in the k.core.v1.namespace.new(tk.env.spec.namespace) expression:
RUNTIME ERROR: Unexpected type string, expected number
<path to repo>/environments/default/main.jsonnet:7:38-49
<path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:51:35-39 thunk from <function <anonymous>>
<path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:33:42-46 object <anonymous>
Field "name"
Field "metadata"
Field "namespace"
During manifestation
The error is quite confusing to me. What and where expects number?
both namespace and name are strings in my spec.json
according to the same configuration docs they should be strings
on line 33 of namespace.libsonnet there is a function withName which expects name argument of type d.T.string
tk works fine from the CLI
I suppose that I've set wrong tanka.dev/environment, but I can't find docs that say what should be set there.
Also, just to check if it helps, I tried setting "jsonnet.languageServer.tankaMode": true in VS Code settings to no avail.
Please, help me to resolve the error and if possible explain what's going on here.

Unable to call Notebook when using scala code in Databricks

I am into a situation where I am able to successfully run the below snippet in azure Databricks from a separate CMD.
%run ./HSCModule
But running into issues when including that piece of code with other scala code which is importing below packages and getting following error.
import java.io.{File, FileInputStream}
import java.text.SimpleDateFormat
import java.util{Calendar, Properties}
import org.apache.spark.SparkException
import org.apache.spark.sql.SparkSession
import scala.collection.JavaConverters._
import scala.util._
ERROR = :168: error: ';' expected but '.' found. %run
./HSCModule
FYI - I have also used dbutils.notebook.run and still facing same issues.
You can't mix the magic commands, like, %run, %pip, etc. with the Scala/Python code in the same cell. Documentation says:
%run must be in a cell by itself, because it runs the entire notebook inline.
So you need to put this magic command into a separate cell.

Deno: unable to import a library which contains relative imports

I'm trying to write some code that uses Deno and rdflib. And failing miserably.
Here's my test program:
// #deno-types="https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts"
import { Namespace } from 'https://dev.jspm.io/npm:rdflib#2.2.7/lib/index'
when I ask deno to cache the remote packages, it fails:
$ deno --unstable cache rdflib.ts
Check file:///home/ian/projects/personal/deno-experiments/rdflib.ts
error: TS2502 [ERROR]: 'thisArg' is referenced directly or indirectly in its own type annotation.
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.es5.d.ts:350:22
TS2614 [ERROR]: Module '"https://dev.jspm.io/npm:rdflib#2.2.7/lib/query"' has no exported member 'Query'. Did you mean to use 'import Query from "https://dev.jspm.io/npm:rdflib#2.2.7/lib/query"' instead?
import { Query } from './query';
~~~~~
at https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts:16:10
TS2614 [ERROR]: Module '"https://dev.jspm.io/npm:rdflib#2.2.7/lib/updates-via"' has no exported member 'UpdatesSocket'. Did you mean to use 'import UpdatesSocket from "https://dev.jspm.io/npm:rdflib#2.2.7/lib/updates-via"' instead?
import { UpdatesSocket } from './updates-via';
~~~~~~~~~~~~~
at https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts:26:10
TS2614 [ERROR]: Module '"https://dev.jspm.io/npm:rdflib#2.2.7/lib/updates-via"' has no exported member 'UpdatesVia'. Did you mean to use 'import UpdatesVia from "https://dev.jspm.io/npm:rdflib#2.2.7/lib/updates-via"' instead?
import { UpdatesVia } from './updates-via';
~~~~~~~~~~
at https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts:27:10
TS2749 [ERROR]: 'Store' refers to a value, but is being used as a type here. Did you mean 'typeof Store'?
at https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts:32:32
... many more lines ...
TS2614 [ERROR]: Module '"https://dev.jspm.io/npm:rdflib#2.2.7/lib/utils/termValue"' has no exported member 'termValue'. Did you mean to use 'import termValue from "https://dev.jspm.io/npm:rdflib#2.2.7/lib/utils/termValue"' instead?
export { termValue } from './utils/termValue';
~~~~~~~~~
at https://dev.jspm.io/npm:rdflib#2.2.7/lib/index.d.ts:40:10
Found 44 errors.
As far as I can tell, the problem is with lines in the remote code that do relative imports. Do such relative imports not work with Deno, or am I missing some vital step, or is my approach doomed?
Version info:
$ deno --version
deno 1.12.2 (release, x86_64-unknown-linux-gnu)
v8 9.2.230.14
typescript 4.3.5
The problem is not that they are relative specifiers, but that they are not fully qualified. From section 6.6 in the manual:
Can I use TypeScript not written for Deno?
Maybe. That is the best answer, we are afraid. For lots of reasons, Deno has chosen to have fully qualified module specifiers. In part this is because it treats TypeScript as a first class language. Also, Deno uses explicit module resolution, with no magic. This is effectively the same way browsers themselves work, though they don't obviously support TypeScript directly. If the TypeScript modules use imports that don't have these design decisions in mind, they may not work under Deno.
Also, in recent versions of Deno (starting with 1.5), we have started to use a Rust library to do transformations of TypeScript to JavaScript in certain scenarios. Because of this, there are certain situations in TypeScript where type information is required, and therefore those are not supported under Deno. If you are using tsc as stand-alone, the setting to use is "isolatedModules" and setting it to true to help ensure that your code can be properly handled by Deno.
One of the ways to deal with the extension and the lack of Node.js non-standard resolution logic is to use import maps which would allow you to specify "packages" of bare specifiers which then Deno could resolve and load.

Jest stranspiles code differently then ts-node

I can't make my code work when running the project normally and running in Jest.
Running the project requires this kind of imports for dayjs:
import * as dayjs from 'dayjs';
import * as utc from 'dayjs/plugin/utc';
import * as customParseFormat from 'dayjs/plugin/customParseFormat';
npm run dev (nodemon --exec ./node_modules/.bin/ts-node ./src/app.ts): No issues
Jest: TypeError: t is not a function
Running the Jest tests requires this kind of imports for dayjs:
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import customParseFormat from 'dayjs/plugin/customParseFormat';
npm run dev (nodemon --exec ./node_modules/.bin/ts-node ./src/app.ts):
dayjs.extend(utc);
^
TypeError: Cannot read property 'extend' of undefined`
Jest: Success!
So now it is impossible for me to write Tests. Why is it transpiled differntly?
In my case,
tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true
}
}
solved it.
I switched to ts-jest and it solved my problem. I was assuming that I could write JS tests to test the TS code but I suppose that is not possible.

How to extend an ember-cli addon?

In my ember-cli app i have installed an addon called 'ember-cli-selectize'. Looking at the directory structure i can see that its files are located at /node_modules/ember-cli-selectize'. Now i want to create a custom component that extends this addon. How do i import/require it? I've tried these and none seems to work:
var EmberSelectize = require('/ember-cli-selectize/app/components/ember-selectize');
import EmberSelectize from 'components/ember-selectize';
import EmberSelectize from 'node_modules/ember-cli-selectize/addon/components/ember-selectize';
import EmberSelectize from 'ember-cli-selectize/addon/components/ember-selectize';
i always get this 'Could not find module' error no matter what. I need to somehow import/require it to do something like
import EmberSelectize from 'wherever/it/is';
export default EmberSelectize.extend({
//my own customizations
})
You were close with:
import EmberSelectize from 'components/ember-selectize';
Addons namespace themselves - in this case, ember-cli-selectize. So, just add the namespace to your import:
import EmberSelectizeComponent from 'ember-cli-selectize/components/ember-selectize';
then you can extend:
export default EmberSelectizeComponent.extend({ });