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 […]

Categories
Mastering Development

d3.js + Angular 7, not working after building, but its working on dev-server

I have an angular 7.2.0 project where i am using d3.js v5.9.7 . the charts are working fine on my local dev server (ng serve) but after bulding and uploading it (ng build –prod) the charts wont render and i get the following error: i dont know where the “QT” comes from. But it seems […]

Categories
Mastering Development

TypeScript not finding variable declared in type declaration if I import a file

I made a very simple library which contains a .d.ts (source) which has the following structure (I omit the details because the file works fine, it likely is a config issue in my project): // Some helper types and interfaces type TranslationFunction = /* … */; export { TranslationFunction }; Then, I do npm i […]

Categories
Mastering Development

Mocked `fs.createFileSync` and `fs.unlinkSync` are not getting called

I have a function that does a lot of things, but among them is that it copies a file to a special directory, does something with it (calls something to interact with that file without using the fs module), and then deletes the copied file once finished. import { copyFileSync, unlinkSync } from ‘fs’; myOtherFunction(path: […]

Categories
Mastering Development

Basic Setup for Typescript Types – Cannot find name ‘angular’

My team is working on an older AngularJS project that we have recently upgraded to .Net Core 3.1 while the project works fine without it we would like to start upgrading our scripts to use TypeScript. None of us have actually used Typescript before and I’m sure we have something very basic messed up in […]

Categories
Development

Vue Typecript @Component throwing compile error. with vue-class-component

I am getting a Module parse failed: Unexpected character ‘@’ error when compiling my Vue application. It’s just a Hello World! App, utilizing Webpack4, Vue, and Typescript. I am using vue-class-component and vue-property-decorator I have followed almost every setup I could find and still cannot resolve this. Everything compiles and works fine if I use […]

Categories
Development

Building angular library at ng serve

I am struggling with my angular library development. First of all, I am building an angular 8 library (curent cli version 9) and I want to live see my library code changes while I am serving the demo app in which I am using this library. Current behavior: When I am making changes on library […]

Categories
Development

Why is this React Typescript app throwing errors?

I just created a new React app using npx create-react-app my-app –template typescript and it was working fine until I changed my component to from a stateless one to a stateful one. The error: JSX element type ‘App’ is not a constructor function for JSX elements. TS2605 3 | import App from “./App”; 4 | […]

Categories
Development

Export is not defined when using Vue with TypeScript

I’m using TypeScript for my new Vue project and I’m having trouble with setting it up. FYI, I’m not using webpack. I’m using “plain” TypeScript with Vue. I’m using ASP.NET Core for the Back-End development. After starting, I always get the following error message printed out in the console ReferenceError: exports is not defined, App.js:2:1 […]