npm relies on external package to import dependencies

Discussão em 'Angular' iniciado por Thomas E, Fevereiro 27, 2025.

  1. Thomas E

    Thomas E Guest

    We make a custom library, basically a wrapper around Angular Material.

    We use that library in our project, but sometimes I still want to use component from Angular Material directly.

    But now, I import MatTable, but when running ng serve, it seems that it expected my custom library to export MatTable.

    ✘ [ERROR] TS-993004: Unable to import component MatTable.
    The symbol is not exported from /Users/thomasengels/project-backup/inbo-component-library/node_modules/@angular/material/table/index.d.ts (module '@angular/material/table'). [plugin angular-compiler]

    src/app/tellers/tellers-table/tellers-table.component.ts:30:13:
    30 │ export class TellersTableComponent {
    ╵ ~~~~~~~~~~~~~~~~~~~~~


    This is the component the error speaks about

    import {Component, inject} from '@angular/core';
    import {MatFormField} from "@angular/material/form-field";
    import {MatTableDataSource, MatTableModule} from "@angular/material/table";
    import {MatSort} from "@angular/material/sort";
    import {MatInput} from "@angular/material/input";
    import {TellersService} from "../tellers.service";

    export interface Teller {
    name: string;
    contactDetails: string;
    address: string;
    active: boolean;
    regions: string[];
    comments: string[];
    createdOn: Date;
    }

    @Component({
    selector: 'app-tellers-table',
    imports: [
    MatFormField,
    MatTableModule,
    MatSort,
    MatInput,
    ],
    standalone: true,
    templateUrl: './tellers-table.component.html',
    styleUrl: './tellers-table.component.scss'
    })
    export class TellersTableComponent {
    displayedColumns: string[] = ['name', 'contactDetails', 'address', 'active', 'regions', 'comments', 'createdOn'];
    dataSource: MatTableDataSource<Teller>;

    tellersService = inject(TellersService);

    constructor() {
    this.tellersService.getTellers().subscribe(tellers => this.dataSource = new MatTableDataSource(tellers))
    }
    }

    Continue reading...

Compartilhe esta Página