Categories
Mastering Development

typescript .d.ts file not recognized by typescript but vsc

Update: it isnt a typescript, but ts-node "issue" i answered to myself so if ure still interested in the "issue" – read further 🙂 sorry for the confusion maybe I have a TOTALLY wrong idea of the index.d.ts file.. but my idea was, that i can declare types within it and they are then "globally […]

Categories
Mastering Development

Webpack – import const from .d.ts file not working – Can’t resolve ‘@nuvolo/servicenow-types/server/GlideRecord’

I’m doing this: import { GlideRecord } from "@nuvolo/servicenow-types/server/GlideRecord"; I have a file node_modules/@nuvolo/servicenow-types/server/GlideRecord.d.ts It contains: … type GlideRecordConstructor = { new <T>(table: string): GlideRecord<T> }; type GlideRecord<T> = GlideRecordBase<T> & T; declare const GlideRecord: GlideRecordConstructor; export { GlideRecord }; If I run tsc it works, no errors Webpack says: Module not found: Error: Can’t […]

Categories
Mastering Development

Unable to load preload script – Electron.js Ubuntu 18.04.4

I’m trying to understand how to effectively load the proload.js file in electron: Version "electron": "^9.1.2", Version "electron-builder": "^22.8.0", In background.js I put webPreferences: { nodeIntegration: false, contextIsolation: true, //preload: path.join(app.getAppPath(), "preload.js"), preload: path.join(__dirname, "./preload.js"), }, preload.js and background.js are in the same folder: src folder. this is my preload.js : const { contextBridge, ipcRenderer […]

Categories
Mastering Development

Typescript + Electron + ThreeJS Import Module converts to require

I am building a 3D multiplatform electron app bundled around photoshop with vscode, electron, typescript,electron packager,npm, threejs on windows. Unfortunately, Typescript works a little against me. Whenever I compile to js it replaces import {x} from "./y" with an unnecessary require(y) and some export stuff above it. This is the index.html: <!DOCTYPE html> <html> <head> […]

Categories
Mastering Development

cannot run compiled typescript prog using module resolution

I’m trying to compule the following typscript file import { magic } from ‘lib/magic’; magic(); The filestructure is: ./src/ main.ts lib/ a/magic.ts b/magic.ts Inside tsconfig.json I map lib/magic to the right file as follows { "compilerOptions": { "target": "esnext", "module": "commonjs", "outDir": "./dist", "baseUrl": ".", "paths": { "lib/*": [ "src/lib/a/*" ] } }, "include": [ […]

Categories
Mastering Development

getAsJsonArray(String) is undefined for the type JsonObject

Map<String, String> contactInfo = new HashMap<>(); String response = get_global_search_response_for_contacts_by_email(restClient,BaseUrl,BasicAutorization, email); if (response.contains(email)) { logger.info("A contact with the specified email address has been found. Removing it to continue the testing…") JsonObject jObject = convertStringToJsonObject(response); //adding values of keys in List from objects JsonArray jarray = jObject.getAsJsonArray("items"); for (int i = 0; i < jarray.size(); i++) […]

Categories
Mastering Development

Issue trying to setup jest: application code compiles fine but test code doesn’t

I am trying to migrate to jest and I am facing typescript issues… I have 3 tsconfig files: tsconfig.json (base config) tsconfig.lib.json (application config) tsconfig.jest-spec.json (jest-dedicated test config) Please note that there are also karma/jasmine dedicated tsconfig files but those are irrelevant. I have separated the jest tests from the karma ones. tsconfig.json { "compileOnSave": […]

Categories
Mastering Development

Unexpected token “export” using babel in docker container with docker-compose and typescript monorepo

I have been struggling with the following issue over the last couple days and can’t seem to track it down. I have a typescript monorepo with a shared package that I am trying to develop in docker using docker-compose. I can run them all directly from my local machine with yarn and everything boots up […]

Categories
Mastering Development

Must I fix all TSLint errors before Angular production build?

I am able to run my Angular v8 app in development mode even there are TSlint TS errors (just showed few at below). However, when I try to build for production, it failed with npm ERR! code ELIFECYCLE npm ERR! errno 2. I have a number of TSlint TS errors, is there a way to […]

Categories
Mastering Development

Cannot read property ‘fromJSON’ of undefined while testing in Jest

while running jest i get the following error.I dont know why am i getting this error. TypeError: Cannot read property ‘fromJSON’ of undefined at Object. (node_modules/@grpc/proto-loader/node_modules/protobufjs/ext/descriptor/index.js:3:66) at Object. (node_modules/@grpc/proto-loader/build/src/index.js:23:20) Below is the tsconfig.json { “compilerOptions”: { “target”: “esnext”, “module”: “commonjs”, “outDir”: “dist”, “sourceMap”: true, “moduleResolution”: “node”, “declaration”: true, “experimentalDecorators”: true, “allowSyntheticDefaultImports”: true, /* Allow default […]