Skip to content

ModernTaxonomyPicker docs reference missing import '@pnp/sp/taxonomy' (PnPjs v4) #2064

@ArneMeersman

Description

@ArneMeersman

Category

[ ] Enhancement
[X] Bug
[ ] Question

Version

@pnp/spfx-controls-react: 3.22.0
@pnp/sp: 4.16.0
SPFx: 1.21.1
TypeScript: 5.3
Node: 22

Expected / Desired Behavior / Question

ModernTaxonomyPicker documentation/examples should either:

  1. Use a valid import for taxonomy term types
  2. Provide a local interface for selected term objects if PnPjs v4 doesn’t have those types.

Expected: import { ITermInfo } from "@pnp/sp/taxonomy"; should resolve or docs should not reference this path.

https://pnp.github.io/sp-dev-fx-controls-react/controls/ModernTaxonomyPicker/

Observed Behavior

The docs show:
import { ITermInfo, ITermSetInfo, ITermStoreInfo } from "@pnp/sp/taxonomy";

In v4 this subpath does not exist; build fails with:
TS2307: Cannot find module '@pnp/sp/taxonomy' or its corresponding type declarations.

No taxonomy types are published in node_modules/@pnp/sp/ (no taxonomy folder).

Steps to Reproduce

  1. Create an SPFx web part (v1.21.1)
  2. Install:
    npm install @pnp/sp@4.16.0 @pnp/spfx-controls-react@3.22.0
  3. Add import for ModernTaxonomyPicker
    import { ITermInfo } from "@pnp/sp/taxonomy";

Workaround

Define a declaration:

declare module "@pnp/sp/taxonomy" {
  export interface ITermInfoLabel {
    name: string;
    isDefault: boolean;
    languageTag: string;
  }
  export interface ITermInfoAvailability {
    setId: string;
    isAvailable: boolean;
  }
  export interface ITermInfoProperty {
    key: string;
    value: string;
  }
  export interface ITermInfoLocalProperty extends ITermInfoProperty {}
  export interface ITermInfoDescription {
    languageTag: string;
    description: string;
  }
  export interface ITermInfo {
    id: string;
    labels: ITermInfoLabel[];
    name?: string;
    path?: string;
    childrenCount?: number;
    createdDateTime?: string;
    lastModifiedDateTime?: string;
    isDeprecated?: boolean;
    isAvailableForTagging?: ITermInfoAvailability[];
    properties?: ITermInfoProperty[];
    localProperties?: ITermInfoLocalProperty[];
    descriptions?: ITermInfoDescription[];
    customSortOrder?: string;
    topicRequested?: boolean;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions