Categories
Mastering Development

Angular 10: Path Mapping shows error in VSCode when import

So I updated a project that was in Angular 8.2 (a project template) to version 10 and followed the instructions from https://update.angular.io/ and everything was ok, but when implemented Path Mapping the pain started, I’m getting this error everywhere: Cannot find module ‘@environments/environment’ or its corresponding type declarations.ts(2307) And this error applies to @environments and […]

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

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

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
Development

How to attach to nodemon process with WebStorm and TypeScript setting

I use debugger “attach to node.js/chrome”. My WebStorm debugger configuration. Host: localhost port: 9229 attach to: Chrome or node.js > 6.3 started with –inspect I am using TypeScript. My tsconfig.json file. { “compilerOptions”: { /* Basic Options */ “target”: “es6”, /* Specify ECMAScript target version: ‘ES3’ (default), ‘ES5’, ‘ES2015’, ‘ES2016’, ‘ES2017’, ‘ES2018’, ‘ES2019’ or ‘ESNEXT’. […]

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

create numbered, ordered list of section header elements from html using xPath

I want to parse some HTML to create a nested navigation (ordered list for a table of contents) based on the section headings elements (H1,H2,H3,H4,H5,H6) using XPath. For exampe, if I have a structure like this: <h2>Header 1.</h2> <h2>Header 2.</h2> <h3>SubHeader 2.1</h3> <h4>SubHeader 2.1.1</h4> <h2>Header 3.</h2> <h3>SubHeader 3.1</h3> <h3>SubHeader 3.2</h3> I would like xPath to […]

Categories
Development

Crafty help- text will not stop wrapping in Javascript

I have spent hours reading and trying solutions to other people’s wrapping problems and nothing is working. I am using Crafty to build a game and want to display one line of instructions but no matter how I style the text it keeps wrapping at every space. If I take the spaces out, the whole […]

Categories
Development

How to stop TypeScript error ‘Type A has no properties in common with Type B’ when Type B “extends” Type A in some way

(edited Title to make more general) I’m working in a codebase which uses React class components and Typescript everywhere, and I’m trying to implement react-dropzone (a lightweight, simple but effective file-drop component) using the class-based method. The Hooks implementation is cleaner and simpler but I’d prefer to avoid so as to preserve the paradigm maintained […]

Categories
Development

ng build cannot find module

I am trying to locally test 3 node modules by updating the locations they are being pulled from in their package.json files. The modules are sdk, ng-widget-lib, and frontend. ng-widget-lib depends on sdk and frontend depends on ng-widget-lib. I build sdk locally with babel. I’m running verdaccio as a local npm registry. I update ng-widget/package.json […]