Currently in the midst of an Angular upgrade from version 8 to 9, I encountered a particular issue where I am faced with the TypeScript error TS2339 stating that the property 'get' does not exist on the type 'unknown'

Greetings! I am currently in the process of migrating an Angular application from version 8 to 9. As I tackle and resolve various errors, there is one particular issue that spans across multiple lines of code.

ERROR in angularApp/app/my-trades/my-trades.component.ts:2045:34 - error TS2339: Property 'get' does not exist on type 'unknown'.

This is where the error manifests:

private paginate() {


        this.route.queryParamMap.pipe(
            map(params => params.get('page'))) // here it underlines  get
            .subscribe(page => {
                if (page) {
                    this.config.currentPage = Number(page);
                };
            });

    }

Here is my package.json configuration:


{
    "name": "project.vision",
    "version": "1.0.3",
    "scripts": {
        ...
    },
    "dependencies": {
        ...
    },
    "devDependencies": {
        ...
    },
    "browser": {
        "image-size": false
    },
    "peerDependencies": {
        ...
    }
}

Below are the imports in my code:

import { auditTime, debounceTime, filter } from 'rxjs/operators';
import { Component, OnInit, ChangeDetectorRef, ViewEncapsulation, OnDestroy, Injector, HostListener } from '@angular/core';
...
@Component({
    selector: 'my-trades-component',
    styleUrls: ['./my-trades.component.scss'],
    providers: [ContextService, Functions, UserContextProvider],
    templateUrl: 'my-trades.component.html',
    encapsulation: ViewEncapsulation.None,
})

Answer №1

It appears there may be a mistake in the code you shared, specifically an additional single quote just before the comment. This extra character could potentially lead to unexpected behavior. I recommend checking out this link for more information and also try accessing the params variable like this:

    this.route.queryParamMap.pipe(
        map(params: ParamMap => params.get('page')))

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The input field in iOS is shielded by the keyboard on Ionic 5

For months now, I've been struggling with the same issue and I just can't seem to find a solution. The problem arises in an application where there are multiple forms; when a user focuses on an input field, the keyboard covers it up completely ma ...

What is the best way to transform a JavaScript object into an array?

Here is the information I have: {product_quantity: {quantity: 13, code: "AAA", warehouse: "1000",}} The product_quantity field is part of a JSON object in a MongoDB database. I am looking to convert it into this format: {"produ ...

Encountering the error "The method .apply is not a function

Can someone explain why I am encountering the following issue: ERROR TypeError: _this.user_data.apply is not a function When attempting to populate user_data with data from a mapped JSON file user_data: any; this.testService.getTestWithObservable() .m ...

The code written inside the <script> tag seems to be malfunctioning when placed in the component.html file within VScode while working with

I'm facing an issue where the script tag for jQuery included in index.html is not being executed within the component.html. There are no errors detected when inspected. Additionally, I have used another script for a toast message box. <script sr ...

Encountering a problem while attempting to compile an Angular 8 application using the "ng build" command

Error Log Below: An error occurs while the application is running with ng-serve, but ng build throws a different error. Generating ES5 bundles for differential loading... Browserslist: caniuse-lite is outdated. Please run the following command npm u ...

Customizing the appearance of a form control in response to its value in Angular's Reactive

I have a unique query regarding formatting text related to formControl in an application where the formControls are created using FormBuilder and arrays of formControls. This inquiry involves retrieving the current value of a formControl and altering the ...

What is the most efficient way to remove all typed characters from fields when clicking on a different radio button? The majority of my fields share the same ngModel on a separate page

Is there a way to automatically clear all typed characters in form fields when switching between radio buttons with the same ngModel on different pages? I noticed that the characters I type in one field are retained when I switch to another radio button. ...

Bringing in Leaflet for Angular 2 and beyond

Hello there! I'm currently diving into the world of Angular 2 and wanting to figure out how to integrate Leafletjs with it. My goal is to set up Leafletjs without having to directly include JS and CSS in my index.html file. Additionally, I want to ens ...

Is it possible to modify the default behavior of a sensitive region within a button?

I created a calculator application in React and overall, it's working fine, however... I've noticed that when I hold a click longer, it only registers as a click if the mouse was pressed down and released on the button itself. Although I unders ...

Observing the Transformation When Employing *ngIf or *ngSwitchCase in Angular 2

Can someone lend a hand? I've run into an issue where my custom JavaScript function is not working after using *ngIf or *ngSwitchCase to change the view. Any suggestions on how to resolve this would be greatly appreciated. ...

What sets apart the browser's debugger from Angular's setTimeout function?

I'm currently working on an angular application that is embedded within a larger application that I do not have access to. I am using a router to navigate between pages after a pop-up modal has been acknowledged (checkbox & button). It's crucial ...

What is the proper way to specify a generic type as a parameter in TypeScript?

I have devised a basic Form class using TypeScript: class Form<FormData> { protected data: FormData; constructor(data: FormData) { this.data = data; } } To ensure the form receives specific data upon instantiation, I included a ...

A step-by-step guide on integrating dynamic components in vue-class-component

After successfully using vue-class-component in my project, I decided to introduce a new component for production only: import store from '../store/Index' let storeTmp = process.env.NODE_ENV === 'production' ? store : null @Component({ ...

Mastering server requests in Angular 5

I have come across recommendations stating that server requests should be made via services and not components in order to ensure reusability of functions by other components. Ultimately, the server response is needed in the component. My query pertains t ...

Step-by-step guide on integrating jQuery npm module into TypeScript 1.8

Initially, I am struggling to articulate the correct question. It seems like there may be some confusion or overlap in my understanding of the TypeScript compiler, new ES2015 (ES6) module syntax, and module loaders. My current objective is to utilize ES20 ...

Access the system by authenticating with the Firestore database collection

My goal is to develop a function that retrieves information from my collection in order to log into my application. With the help of this service, I am able to fetch all the necessary data: getUsersLocal(): Observable<AdminUser[]> { const bo ...

how can I display the JSON description based on the corresponding ID using Ionic 3

I have a JSON file containing: [{ "id": "1", "title": "Abba Father (1)", "description": "Abba Abba Father." }, { "id": "2", "title": "Abba Father, Let me be (2)", "description": "Abba Father, Let me be (2) we are the clay." }, { ...

Leverage the child interface as a property interface containing a generic interface

I'm facing an issue while trying to incorporate typings in React. The concept is centered around having an enum (EBreakpoint) that correlates with each device we support. A proxy wrapper component accepts each device as a prop, and then processes the ...

Script execution is disabled on this system preventing the loading of content - ANGULAR V14

Every time I try to run my Angular project or any ng command, I keep encountering the following error message: ng : File C:\Users\achra\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this ...

I've noticed that tailwindcss is causing issues with some of the styles in my angular project

Recently, I integrated tailwindcss 2.0.4 into my angular 11.2.6 project. After completing the installation and adding necessary imports, the appearance of the page had changed. Take this button for instance: https://i.sstatic.net/vvYVN.png Prior to int ...