diff --git a/types/sharepoint/index.d.ts b/types/sharepoint/index.d.ts index a95c31063b..bf6ffdf95c 100644 --- a/types/sharepoint/index.d.ts +++ b/types/sharepoint/index.d.ts @@ -3546,7 +3546,7 @@ declare namespace SP { newMode } /** Represents a list on a SharePoint Web site. */ - class List extends SP.SecurableObject { + class List extends SP.SecurableObject { /** Gets item by id. */ getItemById(id: number): SP.ListItem; /** Gets a value that specifies whether the list supports content types. */ @@ -3758,20 +3758,20 @@ declare namespace SP { /** Sends the list to the site recycle bin. */ recycle(): SP.GuidResult; /** Returns collection of list items based on the specified CAML query. */ - getItems(query: SP.CamlQuery): SP.ListItemCollection; + getItems(query: SP.CamlQuery): SP.ListItemCollection; /** Creates a new list item in the list. */ addItem(parameters: SP.ListItemCreationInformation): SP.ListItem; } /** Represents a collection of SP.List objects */ class ListCollection extends SP.ClientObjectCollection { /** Gets the list at the specified index in the collection. */ - itemAt(index: number): SP.List; + itemAt(index: number): SP.List; /** Gets the list at the specified index in the collection. */ - get_item(index: number): SP.List; + get_item(index: number): SP.List; /** Returns the list with the specified title from the collection. */ - getByTitle(title: string): SP.List; + getByTitle(title: string): SP.List; /** Returns the list with the specified list identifier. */ - getById(id: string | SP.Guid): SP.List; + getById(id: string | SP.Guid): SP.List; /** Creates a new list or a document library. */ add(parameters: SP.ListCreationInformation): SP.List; /** Gets a list that is the default location for wiki pages. */ @@ -3838,12 +3838,12 @@ declare namespace SP { textField, } /** Represents an item or row in a list. */ - class ListItem extends SP.SecurableObject { - get_fieldValues(): any; + class ListItem extends SP.SecurableObject { + get_fieldValues(): T; /** Gets the specified field value for the list item. Field value is returned as string, but it can be casted to a specific field value type, e.g. SP.LookupFieldValue, etc. */ - get_item(fieldInternalName: string): any; + get_item(fieldInternalName: K): T[K]; /** Sets the specified field value for the list item. Consider using parseAndSetFieldValue instead. */ - set_item(fieldInternalName: string, value: any): void; + set_item(fieldInternalName: K, value: T[K]): void; /** Gets collection of objects that represent attachments for the list item. */ get_attachmentFiles(): SP.AttachmentCollection; /** Gets the content type of the item. */ @@ -3886,10 +3886,10 @@ declare namespace SP { /** Validates form values specified for the list item. Errors are returned through hasException and errorMessage properties of the ListItemFormUpdateValue objects */ validateUpdateListItem(formValues: SP.ListItemFormUpdateValue[], bNewDocumentUpdate: boolean): SP.ListItemFormUpdateValue[]; } - class ListItemCollection extends SP.ClientObjectCollection { - itemAt(index: number): SP.ListItem; - get_item(index: number): SP.ListItem; - getById(id: number | string): SP.ListItem; + class ListItemCollection extends SP.ClientObjectCollection> { + itemAt(index: number): SP.ListItem; + get_item(index: number): SP.ListItem; + getById(id: number | string): SP.ListItem; get_listItemCollectionPosition(): SP.ListItemCollectionPosition; } class ListItemCollectionPosition extends SP.ClientValueObject { diff --git a/types/sharepoint/sharepoint-tests.ts b/types/sharepoint/sharepoint-tests.ts index be8174a681..56d01b0d0d 100644 --- a/types/sharepoint/sharepoint-tests.ts +++ b/types/sharepoint/sharepoint-tests.ts @@ -370,11 +370,16 @@ function deleteFolder(resultpanel: HTMLElement) { } } +interface Announcements { + Title: string; + Body: string; +} + // List item tasks function readItems(resultpanel: HTMLElement) { const clientContext = SP.ClientContext.get_current(); const oWebsite = clientContext.get_web(); - const oList = oWebsite.get_lists().getByTitle("Announcements"); + const oList = oWebsite.get_lists().getByTitle("Announcements"); const camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml( '' +