Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Paging not working #3181

Open
EA12 opened this issue Dec 17, 2024 · 4 comments
Open

Async Paging not working #3181

EA12 opened this issue Dec 17, 2024 · 4 comments

Comments

@EA12
Copy link

EA12 commented Dec 17, 2024

Major Version

4.x

Minor Version Number

4.7.5

Target environment

SharePoint Framework

Additional environment details

This is my package.json:

{
"name": "measures-dk",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"@fluentui/react": "^8.106.4",
"@microsoft/sp-component-base": "1.18.2",
"@microsoft/sp-core-library": "1.18.2",
"@microsoft/sp-lodash-subset": "1.18.2",
"@microsoft/sp-office-ui-fabric-core": "1.18.2",
"@microsoft/sp-property-pane": "1.18.2",
"@microsoft/sp-webpart-base": "1.18.2",
"@pnp/sp": "^4.7.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"tslib": "2.3.1"
},
"devDependencies": {
"@microsoft/eslint-config-spfx": "1.18.2",
"@microsoft/eslint-plugin-spfx": "1.18.2",
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
"@microsoft/sp-build-web": "1.18.2",
"@microsoft/sp-module-interfaces": "1.18.2",
"@rushstack/eslint-config": "2.5.1",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"eslint": "8.7.0",
"eslint-plugin-react-hooks": "4.3.0",
"gulp": "4.0.2",
"typescript": "4.7.4"
}
}

And this is the Code-Line:

for await (const items of this._sp.web.lists.getByTitle("BigList").items.top(1000)) { console.log(items.length); }

Expected or Desired Behavior

Fetching data with the async iterator pattern as decribed here should work

Observed Behavior

Fetching SharePoint-Online List-Items with the async iterator pattern does not work.
Visual Code is showing this message:

Type 'IItems' is not an array type or a string type.ts(2495)
(method) _SPCollection<any[]>.top(top: number): IItems

Steps to Reproduce

Add a new SPFx-Webpart project with React
Install the latest pnp npm i @pnp/sp which is currently 4.7.0
Create some Code to fetch SharePoint-Online List-Items with the async iterator pattern as described in your specification.

@patrick-rodgers
Copy link
Member

Hmm, just tested and things appear to be working. Have you tried to run it and gotten an error or is this only something showing in vscode? Wondering if it's just a typing issue with something not loaded.

@EA12
Copy link
Author

EA12 commented Dec 17, 2024

Getting the same with gulp build:

[17:57:15] Error - [tsc] src/webparts/project/services/SPServices.ts(417,39): error TS2495: Type 'IItems' is not an array type or a string type.

@EA12
Copy link
Author

EA12 commented Dec 17, 2024

On the other hand, I have a project with 4.5.0 where the pattern works. You may did some changes in 4.7.0?

@bcameron1231
Copy link
Collaborator

Hi. We seem to have an issue with imports that we're looking into.

Can you import all of the pnpjs modules import "@pnp/sp/presets/all";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants