unable to gulp serve code from tutorial #2
Category
- [X ] Question
Expected or Desired Behavior
the following code is expected to build without errors as per lab #2
private _getMockListData(): Promise<ISPLists>{
return MockHttpClient.get(this.context.pageContext.web.absoluteUrl).then(() => {
const listData: ISPLists = {
value:
[
**{Title: 'Mock List One', Id: '1'},
{Title: 'Mock List Two', Id: '2'},
{Title: 'Mock List Three', Id: '3'}**
]
};
return listData;
}) as Promise<ISPLists>;
}
Observed Behavior


=> As you can see, the ISPLists variable can not be assigned as shown. this code is exactly as used in the lab #2 in the sequence of 6 labs this being SharePoint Framework Tutorial 2 - HelloWorld, Talking to SharePoint lab.
The question is: am I missing an import of some type other than the import:
import MockHttpClient from './MockHttpClient';
// LCR Function to mimick data from a sharepoint list
import {ISPList } from './HolaMundoWebPart';
for the defined class:
`export default class MockHttpClient {
private static _items: ISPList[] = [{Title: 'Mock List', Id: '1'}];
public static get(resultUrl: string, options?: any): Promise<ISPList[]>{
return new Promise<ISPList[]>((resolve) => {
resolve(MockHttpClient._items);
});
}
}`
Thank your for your patience for newbee questions.
Thanks for your contribution! Sharing is caring.
I rechecked the code against the video and cleared a couple of typos but the result is still a bad gulp build for the code as shown.
I couldn't get the code as shown in the images to work. however, I reworked the code in the functions and variable declarations until I got the project to build with the gulp serve command and the web part loaded correctly int the local workbench.
I would like to know, however, what is wrong with the code as copied from the lab 2 example. it works on the video but it sure as hell doesn't work when copied to a project on my box (windows 10).
Similar issues TS2306
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues