Categories
Mastering Development

TypeError: Duplicate declaration, Module build failed Error in Typescript Project

Good Day, I have code something like below In A.ts file: declare class LayerManager { //code constructor(factory: Factory); //code } let self: LayerManager; function LayerManager(factory: Factory) { //code self = this; //code } export default LayerManager; In B.ts file: import LayerManager from ‘../layer-manager/index’; //Code this.layer = new LayerManager(this.factory); //<—In order to have construct Signature I […]

Categories
Mastering Development

TypeScript – error TS5023: Unknown compiler option ‘-r’

I’m working on Windows environment and trying to run a forked node.js + typescript project. This is my package.json : { "name": "my-task", "version": "1.0.0", "private": true, "main": "dist/main.js", "scripts": { "start": "tsc-watch –onSuccess ‘node -r source-map-support/register .’", "test": "jest", "lint": "eslint –cache ‘{src,test}/**/*.ts’" }, "dependencies": { "@types/express": "^4.17.7", "@types/node": "^12.12.53", "express": "^4.17.1", "get-port": "^5.1.1", […]

Categories
Linux Mastering Development

Can’t filter file extensions when the list is in a variable [duplicate]

I guess this is a relative simple question, but I can’t find the way to access the variable content when doing a git diff, so it lists all the files with specific extension. // This works fine git diff –name-only –cached –diff-filter=d *.{sln,csproj,vbproj,vcxprojfilters,proj,projitems,shproj,xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct,json,json5,webmanifest,yml,yaml,md,htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue,cmd,bat,sh,Makefile,cs,csx,cake,vb,vbx,cs,csx,cake,cs,csx,cake,vb,vb} MyProyect/Service/App/AppGridService.cs // but this does not work // this is the variable […]

Categories
Mastering Development

Property ‘toBeInTheDocument’ does not exist on type ‘Matchers

Trying to setup testing for a components library. I’ve tried many example and all similar threads on this with no luck. My setupTests.ts file is correctly being loaded (proven with a console.log), and the library seems to be available as if I add import { toBeInTheDocument } from ‘@testing-library/jest-dom/matchers’ and log toBeInTheDocument it is present. […]

Categories
Mastering Development

Cannot manage to get Jest working with reactjs

I’m getting the following errors when trying to run npm run test. npm : FAIL src/App.test.js At line:1 char:1 + npm run test + ~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (FAIL src/App.test.js:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError ÔùÅ Test suite failed to run Cannot find module ‘react’ from ‘iconBase.js’ However, Jest was able to find: […]

Categories
Mastering Development

Grabbing result from a picker view for use in other view controller

Hello fellow programmers, I am having some trouble figuring out passing data between view controllers. my initial view controller(SelectCarViewController) consists of two pickers(year and make/model) I have a Label that displays the year once selected and a label that displays the make/model once selected. Once the two are filled in an invisible button(search parts) will […]

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

How to test react navigation authentication flow?

I’m developing a React Native application. I’m doing something like what’s explained here to implement the authentication flow. So, I created an AppContainer that looks like this: import {createAppContainer, createSwitchNavigator, createStackNavigator} from “react-navigation”; import AuthLoadingScreen from “../screens/auth/auth-loading-screen”; const AppStack = createStackNavigator({ Home: {screen: HomeScreen} }); const AuthStack = createStackNavigator({ SignIn: {screen: SignInScreen} }); const AppContainer […]

Categories
Development

Babel-node ignores or misbehaves when I add ignore option to babel.config.js

am using the command npx babel-node –ignore=’ ‘ –extensions=’.ts,.tsx,.js,.jsx,.es6,.es’ test.js to compile the script named test.js . test.js imports import template from ‘lodash-es/template’; and I would like it to be compiled too. Adding ignore or include or exclude options regex at babel.config.js doesn’t work. How do i add an inline –ignore option ({ ignore: [/node_modules\/(?!lodash-es)/] […]