Questions tagged [typescript]

This tag is for questions specific to developing for SharePoint with TypeScript. It is not used for general JavaScript questions. TypeScript is a statically typed superset of JavaScript created by Microsoft that adds optional types, classes, interfaces, enums, generics, async/await, and many other features, and compiles to plain JavaScript.

Filter by
Sorted by
Tagged with
0 votes
1 answer
27 views

How to compile a package which depends on @microsoft/*

I'm trying to create a reusable SharePoint utility library. I want to use heft to build the library, because it will deal with scss typings, and both cjs/esm outputs. However, SharePoint's ...
Steve B's user avatar
  • 7,488
0 votes
2 answers
48 views

How can I upgrade the TypeScript version in SharePoint 2019 Project?

I'm trying to use [email protected] and Fluent8 in a new SharePoint 2019 project When running, it shows some TypeScript syntax errors like this: ... Starting subtask 'tslint'... Starting subtask '...
LanMegumi's user avatar
0 votes
1 answer
51 views

Pnpjs, How to surpress "Object is possibly 'undefined'" ts error on SharePoint context functions

For example I SP function, for example to format a date: const friendlyDate = new Date().format("dd.MM.yyyy"); console.log(friendlyDate); You can run in in Dev Tools on SharePoint page: ...
Gennady G's user avatar
  • 1,623
0 votes
1 answer
452 views

How to add @odata.nextLink in graph api request

I've a service to get all users from Azure AD. public getAllUsers(): Promise<Array<Person>> { return graph .users .select("displayName", "accountEnabled"...
Propool's user avatar
  • 37
0 votes
0 answers
14 views

What is listener and subcriber in pnpjs/logging?

I'm a newbie to SPFx, I have a task to create a custom logger that can record any exception and error that happen in a web part (like serilog on .NET). I'm following a guide but there is something ...
supnep's user avatar
  • 1
1 vote
0 answers
83 views

Trouble using PnPJS for SharePoint Term Store in SPFx

I'm developing a SharePoint Framework (SPFx) application and am trying to interact with the SharePoint Term Store using the Patterns and Practices JavaScript Core Library (PnPJS). I'm using a version ...
Mohammed El Saka's user avatar
0 votes
0 answers
47 views

Webpack - error when merging configuration

I'm having following urgent error when trying to execute npm run dev command: 'import("c:/Projects/myProject/node_modules/@types/webpack/index").Configuration' is not assignable to parameter ...
private7's user avatar
  • 123
1 vote
1 answer
190 views

SPFx extension is not loading term store properties

I have extension which uses the term store as navigation and on the other hand, I have dropdown list where it has the normal text (SiteA, SiteB, SiteC) with different SP site links on it (href). So, ...
striker92's user avatar
  • 101
1 vote
1 answer
377 views

Spfx extension Clear cache or hard refresh

I have four different extensions with different languages with texts on it, I use dropdown on top placeholder to switch between different sites. However, when I switch from English to Polish I still ...
striker92's user avatar
  • 101
1 vote
2 answers
78 views

How to disable a PeoplePicker Field in SPFx?

I have a PeoplePicker Field and a Dropdown with imported Items from a SharePoint List. The default status of PeoplePicker is disabled = {false}, so it is "not visible". I select an item in ...
LeberkäseWhatsappgruppe's user avatar
0 votes
2 answers
688 views

DefaultButton onClick action aborted without any error message

I'm working on a SharePoint Webpart and my DefaultButton has brocken. I load items to an office-ui-fabric Dropdown from a SharePoint List. It's working fine, I get the value of the selected options, ...
LeberkäseWhatsappgruppe's user avatar
0 votes
1 answer
37 views

SPFx: routing "history" does not exist on type 'Requireble<object>'

I making routing in my SPFx, trying to change url parametrs. import * as PropTypes from 'prop-types'; private EventListners(): void { const btnSearch = this.domElement.querySelector("#...
Ann's user avatar
  • 51
0 votes
1 answer
9k views

How to deal with lint warning "Unexpected any. Specify a different type."

How should I go about avoiding the use of "any" in my state interfaces, such as export interface ITestState{ listItems : any // this triggers a lint warning } when it's not exactly known ...
JJD's user avatar
  • 493
0 votes
1 answer
831 views

spfx-controls-react Dynamic form fieldOverrides

I am having trouble passing fieldOverrides parameter for DynamicForm. Currently i am trying <DynamicForm context={context} listId={listId} fieldOverrides = {"...
Amit Kumar's user avatar
0 votes
1 answer
38 views

What is the best way to shuffle the results that come back from a Graph query?

I have an SPFx web part for SPO which gets the members of a team. What's the best way to shuffle the 'result' data that comes back? EDIT: I have tried this: result = result.sort(() => Math.random() ...
Pete Whelan's user avatar
0 votes
1 answer
743 views

Trying to get all the members of an M365 group using SPFx

I am trying to use the code here in order to get all the members in an M365 group. ¨PnPJS Graph : how to list all members of a Group I am getting an error Uncaught (in promise) Error: There is no ...
Pete Whelan's user avatar
1 vote
0 answers
160 views

Create client instance for reuse

I was trying to set up an instance of client so I don't have to write this.context.msGraphClientFactory.getClient().then((client: MSGraphClient) every time I want to make a request. Something which ...
OLGJ's user avatar
  • 123
1 vote
1 answer
764 views

Building a react application with Microsoft graph and SharePoint

I’m starting a new job and been tasked with creating a react based application which will be built in SharePoint and retrieve data using Microsoft Graph. I am new to this and am struggling with ...
OLGJ's user avatar
  • 123
0 votes
1 answer
239 views

Changing title text in SharePoint top navigation bar using TypeScript/JSOM

I'm trying to change the title of the first item in the top navigation bar in a SharePoint 2019 modern site. The code is run in a TypeScript web part. My code below runs fine and no errors are ...
Papageno's user avatar
  • 343
0 votes
1 answer
356 views

npm install command error

Sample:(PS: You can find what I tested in the GitHub link below) https://github.com/pnp/sp-dev-fx-webparts/blob/master/samples/react-mgtEvents/src/webparts/mgtEvents/MgtEventsWebPart.ts Problem: Hello,...
Roberto Hajj's user avatar
0 votes
1 answer
743 views

Sort items inside my React.Js SPFx web part

I have a SharePoint list, and i want to order the items based on the "Featured" field, but things is not working, where if i define this ordering logic:- a.map(b => { if (b ===...
John John's user avatar
0 votes
1 answer
806 views

Function wait for a loop before returning value in javascript

My function return value of an array before pushing value into array. private async getPPickerid(ppvalue,AssignedToIdArr):Promise<any> { return new Promise<any>((resolve, reject) => { ...
abhishek23 Negi's user avatar
0 votes
1 answer
2k views

How to get the current Page title >> then filter list items based on it inside my SPFx web part

I have a custom list named CompanyNews which contain these fields: Title --> Free Text Topic ---> choice which allow multiple selections Where inside the custom list, we will be adding the ...
John John's user avatar
0 votes
1 answer
377 views

How to defer executing JavaScript file in SPFx solution

In a SPFx solution, I'm importing a JavaScript library like this: import './javascriptfile.js'; This JS file gets executed before the DOM is ready. If we are using a SCRIPT tag, we can use defer ...
Suresh C's user avatar
0 votes
1 answer
56 views

Metainformation about SharePoint structures for typescript/JavaScript?

Hi all I think it is easier if I try to explain with an example. So if I want to add a field using xml I need to populate the xml based on what data a field of an specific type can have. SharePoint ...
Ricardo Silva's user avatar
1 vote
0 answers
604 views

SPFx WebPart started giving TypeError: Cannot read property 'Content' of undefined

This webpart was working on a classic Publishing site. Recently, it started throwing this error message: Error details: Error: Error initializing application. Error: TypeError: Cannot read property '...
Aslan's user avatar
  • 532
0 votes
1 answer
2k views

"gulp package-solution" will raise this warning "- [package-solution] This is not a production build (--ship or --production).."

I am following the steps inside this link @ https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/serving-your-extension-from-sharepoint to deploy my SPFX extension of type ...
John John's user avatar
0 votes
2 answers
926 views

Graph Api call with filter query

How can I filter the API call dynamically passing through variable? I am getting value in this variable through another API call: var userid; this.props.context.msGraphClientFactory.getClient().then(...
abhishek23 Negi's user avatar
0 votes
1 answer
114 views

Why is temp array changing my state array? Sharepoint 2019 on premise, React, Typescript

I do not know why function setHours() that should work only on tempEvent is also changing my state this.state.events (it sets hours of my dates to 00:00:00. let tempEvent = this.state.events[i][&...
AnB's user avatar
  • 37
0 votes
1 answer
35 views

Create a webpart with typescript / sass

I created a webpart for a footer and I have to insert an image in the footer and I can't get it to display. I am using typescript and sass. It is my first webpart! <p class="${styles.subTitle}...
Martina Sofia Ojeda's user avatar
0 votes
2 answers
592 views

Passing variables in Query string in tsx file (react +typescript)

I am trying to pass plainid and id as a parameter in query string in URL. {planid = item.planId} { id =item.id} <td><a href="https://tasks.office.com/credentinfotech.com/en-GB/...
abhishek23 Negi's user avatar
0 votes
1 answer
251 views

Fetching the data through Graph API in the webpart using sharepoint framework

[I am trying to fetch my email messages through Graph API into the webpart in sharepoint framework] In the webpart Not getting the details of my emails through Graph API Error : Cannot read property ...
abhishek23 Negi's user avatar
1 vote
1 answer
344 views

Problem with creating an instance of a class in SPFX(TypeScript/React)

I am facing a problem with creating an instance of a class in SPFX. I am not sure what I should put in as a parameter. The compiler complains on whatever I put as a parameter. Here is my code: import {...
kelank's user avatar
  • 97
2 votes
2 answers
290 views

Not able to insert data into TaskList In sharepoint Spfx

Using SP-Pnp-Js Library, I am not able to insert data from a webpart into the sharepoint Tasklist. private SubmitWorkflowForm(): void { var TaskNameVal = document.getElementById('taskName')['value']; ...
abhishek23 Negi's user avatar
0 votes
2 answers
16k views

Promise is missing properties

When I try to create array, to put the results in the array, then I get the following error message: const allItems : any [] = sp.web.lists.getByTitle("Documents").items.get(); Type '...
sharepointkonsult's user avatar
0 votes
2 answers
81 views

When a document is deleted or published in a document library

I have a requirement to develop a solution based on SPFx, namely, when a document is deleted from a document library or a document is published (got main version) in a document library in SharePoint ...
sharepointkonsult's user avatar
0 votes
1 answer
133 views

Teams Tab is not able to load in Teams Desktop Application using Microsoft Teams Toolkit

My app is visible in ms team application when open in browser My application is not visible in MS team desktop application Please help to resolve my error in Team Desktop application
abhishek23 Negi's user avatar
0 votes
0 answers
237 views

Teams showing - Can't load the application on this page

I created a new application using SPFx in SharePoint online. I have sync the sppkg solution file to the Microsoft Teams. But when I am adding the application in the teams Tab its showing an error: ...
abhishek23 Negi's user avatar
0 votes
1 answer
1k views

VideoPlayer using React and Typescript

Being new to typescript , I have been struggling with its implementation lately using it on the webpart.tsx file With the help of the posts here , was able to get to the point where the video plays ...
Vivek's user avatar
  • 37
0 votes
2 answers
674 views

Running two REST APIs sequentially in SPFX webpart (SharePoint Online)

I'm new to typescript and spfx SharePoint online webpart development. I've got a requirement where I need to run a REST api and wait for its result before I run the next one. I am kind of lost. I'm ...
SPBogdan's user avatar
0 votes
1 answer
36 views

Is there an internal variable or something like it that indicates when all the Rest API calls in a SPFx webpart are done?

I have about 200+ Rest API calls in a SPFx webpart (TypeScript and JSON). Most of them are asynchronized. Everything is working fine. I just need to know when all the calls are done so I can save the ...
Lore.A's user avatar
  • 11
0 votes
1 answer
630 views

Get particular columns with SPFx?

Im developing some web parts with SPFx and one of the things I'm trying to do is get certain coluumns from a list to display them. I use the guide https://docs.microsoft.com/en-us/sharepoint/dev/spfx/...
Pete Whelan's user avatar
0 votes
2 answers
383 views

React webpart OnClick event fail to call a module function

I am working on a React spfx webpart. I inserted below code in my tsx file: <a href="#" className={ styles.button } onClick={ ()=> alert('greeting!') } > <span ...
Mark L's user avatar
  • 4,065
0 votes
1 answer
200 views

PnP Provisioning templates in PnP Js

XML-based PnP Provisioning templates are available to be consumed via SharePoint PnP PowerShell. Question: Is there something similar for provisioning lists via JavaScript/TypeScript via pre-created ...
Denis Molodtsov's user avatar
1 vote
1 answer
834 views

sp-pnp-js gives error when building TypeScript project

I've been asked to make changes to a TypeScript project and compile it to get a new JavaScript file. The JavaScript file is just to be referenced from a SharePoint site, so there's no SPFx involved ...
Papageno's user avatar
  • 343
1 vote
2 answers
14k views

How to filter the retrieved items using a pnp-js-core REST call to a SharePoint list

As I am new to Sharepoint framework , I am trying to filter the retrieved list items from sharepoint list. Please find below code: pnp.sp.web.currentUser.get().then(function(res){ var userEmail = ...
Nidhi Maheshwari's user avatar
0 votes
1 answer
92 views

How to pad a number with leading zeroes using No javascript framework version in SPFx webpart?

As I am new to Sharepoint Framework, I am trying to generate request ID for the request form using the pad function for adding leading laeding zeroes using No javascript framework version in SPFx ...
Nidhi Maheshwari's user avatar
1 vote
1 answer
4k views

Property 'selectedOptions','selectedIndex','options' does not exist on type 'HTMLElement'

I am working around with typescript in Sharepoint framework using No javascript approach. To get the dropdown text I am using the below code but it is not working: var dept = (<HTMLElement>...
Nidhi Maheshwari's user avatar
0 votes
1 answer
308 views

Not able to fetch data from particular list item of site content using React APP WEB-part

I am able to fetch the list which we see on the landing screen of the site-content. However, when I am trying to fetch data by finding a particular item by its title I get an error CANNOT FIND LIST '...
sunil b's user avatar
  • 101
1 vote
0 answers
121 views

SPFx define custom config folder for building solution

Is it possible, to somehow define which config folder gulp will take while bundling. Saying i will have a build script for each sppkg solutions gulp clean && gulp bundle --ship && gulp ...
Valerii Petrenko's user avatar