pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
740 stars 300 forks source link

Documentation references non-existent `ITermInfo` type #3081

Open JakeStanger opened 3 days ago

JakeStanger commented 3 days ago

Major Version

4.x

Minor Version Number

2.0

Target environment

SharePoint Framework

Additional environment details

SPFx 1.19, TypeScript 4.7, NodeJS 18.

I'm happy to pick the fix for this up once agreed which route to go.

Expected or Desired Behavior

The taxonomy documentation page should only reference types which exist in the solution. To resolve this, one of the following needs to occur:

Observed Behavior

The taxonomy documentation page makes several references to ITermInfo, a type which existed in v3 but appears to have been removed in v4 when the code was ported from the sp to graph package.

There may be other types in the taxonomy package which suffer the same issue, but I have not investigated this.

Steps to Reproduce

This does not work (example copied from docs):

import { graphfi } from "@pnp/graph";
import "@pnp/graph/taxonomy";
import { ITermInfo } from "@pnp/graph/taxonomy"; // tsc error

const graph = graphfi(...);

// list all the terms that are direct children of this set
const infos: ITermInfo[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").children();

This does, assuming you have the Graph types package installed:

import { graphfi } from "@pnp/graph";
import "@pnp/graph/taxonomy";
import { TermStore } from '@microsoft/microsoft-graph-types';

const graph = graphfi(...);

// list all the terms that are direct children of this set
const infos: TermStore.Term[] = await graph.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72").sets.getById("338666a8-1111-2222-3333-f72471314e72").children();
juliemturner commented 11 hours ago

I'm sure the documentation just didn't get updated as we were really struggling with time towards the release date we were targeting. Please feel free to update it if you like we'll try to get to it when we can.