-
Notifications
You must be signed in to change notification settings - Fork 1k
SOLUTION: SPFx 1.5.0 wrong typings in package.json causing lots of problems #2093
Copy link
Copy link
Closed
Labels
area:spfxCategory: SharePoint Framework (not extensions related)Category: SharePoint Framework (not extensions related)status:fixedIssue was fixed in current or prior release.Issue was fixed in current or prior release.status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Metadata
Metadata
Assignees
Labels
area:spfxCategory: SharePoint Framework (not extensions related)Category: SharePoint Framework (not extensions related)status:fixedIssue was fixed in current or prior release.Issue was fixed in current or prior release.status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
I had some problems with MSGraphClient and AadHttpClient in 1.5.0, which after some digging seems to be caused by incorrect typings references in each and every one of the
@microsoft/sp-xxx/package.jsonfiles.it says
"typings": "dist/index-internal.d.ts",..but it should probably be
"typings": "lib/index.d.ts",Fixing this fixed my problems and made my ts-code compile again 🥇
Category
Expected or Desired Behavior
Since it has
main: "lib/index.js"in package.json, one would expect that the typings would be the same as the actual used code files, and not from the dist folders.Observed Behavior
Typescript typings missing a shitload of stuff when developing your thingy.
Steps to Reproduce
for example,
import {AadHttpClient} from '@microsoft/sp-http';and then try to do
const ahc = new AadHttpClient(scope, endpointand it will incorrectly say "no 2 param constructor".
the typings in
sp-http/dist/index-internal.d.tsmisses this and says/* Excluded from this release type: __constructor */on line 42.this causes the error, but if you apply my suggested fix to use
lib/index.d.tsinstead, it will correctly viasp-http/lib/index.d.ts, reference the constructor on line 32 insp-http/lib/AadHttpClient/AAdHttpClient.d.tsconstructor(serviceScope: ServiceScope, resourceEndpoint: string);Submission Guidelines
So, you could just silently fix this in the npm packages maybe? ❤️
Thanks for your contribution! Sharing is caring.