Pnpjs: Two compile error when using node 15

Created on 25 Oct 2020  路  2Comments  路  Source: pnp/pnpjs

Hi
Two compile error when using node 15, please help, thanks

node_modules/node-sp-auth/node_modules/got/dist/source/types.d.ts:205:83 - error TS2709: Cannot use namespace 'PCancelable' as a type.    

205 export interface CancelableRequest<T extends Response | Response['body']> extends PCancelable<T>, GotEvents<CancelableRequest<T>> {   
                                                                                      ~~~~~~~~~~~

src/index.ts:61:5 - error TS2339: Property 'web' does not exist on type 'SPRest'.

61  sp.web.webinfos.get().then((lists: any) => {
tooling answered question

Most helpful comment

node_modules/node-sp-auth/node_modules/got/dist/source/types.d.ts:205:83 - error TS2709: Cannot use namespace 'PCancelable' as a type.    

205 export interface CancelableRequest<T extends Response | Response['body']> extends PCancelable<T>, GotEvents<CancelableRequest<T>> {   

Got and node-sp-auth libraries do not correlate with PnPjs directly.

Such TypeScript errors are common when local TS settings/version is different from the one used in the library. Should be forced to ignore in tsconfig.json by setting skipLibCheck:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}
src/index.ts:61:5 - error TS2339: Property 'web' does not exist on type 'SPRest'.

61  sp.web.webinfos.get().then((lists: any) => {

Seems that you imported @pnp/sp [-commonjs] only without importing web API methods, please check selective import docs article for details, also, in a Node application it's simpler to use presets:

import { sp } from '@pnp/sp-commonjs/presets/all';

All 2 comments

node_modules/node-sp-auth/node_modules/got/dist/source/types.d.ts:205:83 - error TS2709: Cannot use namespace 'PCancelable' as a type.    

205 export interface CancelableRequest<T extends Response | Response['body']> extends PCancelable<T>, GotEvents<CancelableRequest<T>> {   

Got and node-sp-auth libraries do not correlate with PnPjs directly.

Such TypeScript errors are common when local TS settings/version is different from the one used in the library. Should be forced to ignore in tsconfig.json by setting skipLibCheck:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}
src/index.ts:61:5 - error TS2339: Property 'web' does not exist on type 'SPRest'.

61  sp.web.webinfos.get().then((lists: any) => {

Seems that you imported @pnp/sp [-commonjs] only without importing web API methods, please check selective import docs article for details, also, in a Node application it's simpler to use presets:

import { sp } from '@pnp/sp-commonjs/presets/all';

Going to close this.

Was this page helpful?
0 / 5 - 0 ratings