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

Angular9 application app selector html not loading with prod build

I have migrated my angular application from angular8 to 9. package.json { “name”: “visur”, “version”: “1.4.7-alpha.3”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e” }, “private”: true, “dependencies”: { “@angular-devkit/build-webpack”: “^0.901.7”, “@angular/animations”: “~9.1.2”, “@angular/cdk”: “^9.0.0”, “@angular/common”: “~9.1.2”, “@angular/core”: “~9.1.2”, “@angular/flex-layout”: “9.0.0-beta.31”, “@angular/forms”: “~9.1.2”, “@angular/http”: […]

Categories
Mastering Development

Angular9 application app selector html not loading with prod build

I have migrated my angular application from angular8 to 9. package.json { “name”: “visur”, “version”: “1.4.7-alpha.3”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e” }, “private”: true, “dependencies”: { “@angular-devkit/build-webpack”: “^0.901.7”, “@angular/animations”: “~9.1.2”, “@angular/cdk”: “^9.0.0”, “@angular/common”: “~9.1.2”, “@angular/core”: “~9.1.2”, “@angular/flex-layout”: “9.0.0-beta.31”, “@angular/forms”: “~9.1.2”, “@angular/http”: […]

Categories
Mastering Development

Angular9 application app selector html not loading with prod build

I have migrated my angular application from angular8 to 9. package.json { “name”: “visur”, “version”: “1.4.7-alpha.3”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e” }, “private”: true, “dependencies”: { “@angular-devkit/build-webpack”: “^0.901.7”, “@angular/animations”: “~9.1.2”, “@angular/cdk”: “^9.0.0”, “@angular/common”: “~9.1.2”, “@angular/core”: “~9.1.2”, “@angular/flex-layout”: “9.0.0-beta.31”, “@angular/forms”: “~9.1.2”, “@angular/http”: […]

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

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

Error: Set the ‘experimentalDecorators’ option in your ‘tsconfig’ or ‘jsconfig’ to remove this warning

I’m trying to get a basic decorator example to work in TypeScript without any luck. I’m constantly seeing the error message: Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option in your ‘tsconfig’ or ‘jsconfig’ to remove this warning. My tsconfig.json looks as follows […]