Skip to content

[BUG] Error - [tsc] node_modules/@lit/task/task.d.ts(165,5): error TS1005: ',' expected. #3402

Closed
@mr-layco

Description

@mr-layco

Describe the bug
I have followed the guide here to the letter to create an SPFX webpart using MGT.
Unfortunately whenever i try to gulp serve or build i get alot of the above errors in the terminal output.
As soon as i remove the imports

import { Providers, customElementHelper } from "@microsoft/mgt-element";  
import { SharePointProvider } from "@microsoft/mgt-sharepoint-provider";  
import { registerMgtPersonComponent } from "@microsoft/mgt-components";

and the associated code pertaining to those from my webpart.ts file the error goes away.

To Reproduce
Steps to reproduce the behavior:
Follow the guide here and then try to serve or build the project

Expected behavior
The webpart project would compile correctly and i would be able to use the toolkit as per the documentation

Environment (please complete the following information):

  • OS: Windows 10
  • Browser: Edge
  • Framework none
  • Context SharePoint
  • Version SPFX 1.20
  • Provider SharePoint Provider

Additional context
Here is a copy of my package.json file and webpart.ts file

I am new to SPFX development and TypeScript, so if i have missed something obvious please accept my apologies. I have had a look on the internet for any similar issues but unable to find anything that matches my issue specifically.

  "name": "mgt-test",
  "version": "0.0.1",
  "private": true,
  "engines": {
    "node": ">=18.17.1 <19.0.0"
  },
  "main": "lib/index.js",
  "scripts": {
    "build": "gulp bundle",
    "clean": "gulp clean",
    "test": "gulp test"
  },
  "dependencies": {
    "@microsoft/mgt-components": "^4.4.0",
    "@microsoft/mgt-element": "^4.4.0",
    "@microsoft/mgt-sharepoint-provider": "^4.4.0",
    "@microsoft/sp-component-base": "1.20.0",
    "@microsoft/sp-core-library": "1.20.0",
    "@microsoft/sp-lodash-subset": "1.20.0",
    "@microsoft/sp-office-ui-fabric-core": "1.20.0",
    "@microsoft/sp-property-pane": "1.20.0",
    "@microsoft/sp-webpart-base": "1.20.0",
    "tslib": "2.3.1"
  },
  "devDependencies": {
    "@fluentui/react": "^8.106.4",
    "@microsoft/eslint-config-spfx": "1.20.2",
    "@microsoft/eslint-plugin-spfx": "1.20.2",
    "@microsoft/rush-stack-compiler-4.7": "0.1.0",
    "@microsoft/sp-build-web": "1.20.2",
    "@microsoft/sp-module-interfaces": "1.20.2",
    "@rushstack/eslint-config": "4.0.1",
    "@types/webpack-env": "~1.15.2",
    "ajv": "^6.12.5",
    "eslint": "8.57.0",
    "gulp": "4.0.2",
    "typescript": "4.7.4"
  }
}
import { Version } from "@microsoft/sp-core-library";
import {
  type IPropertyPaneConfiguration,
  PropertyPaneTextField,
} from "@microsoft/sp-property-pane";
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";

import { Providers, customElementHelper } from "@microsoft/mgt-element";
import { SharePointProvider } from "@microsoft/mgt-sharepoint-provider";
import { registerMgtPersonComponent } from "@microsoft/mgt-components";

import styles from "./MgtTestWebPart.module.scss";
import * as strings from "MgtTestWebPartStrings";

export interface IMgtTestWebPartProps {
  description: string;
}

export default class MgtTestWebPart extends BaseClientSideWebPart<IMgtTestWebPartProps> {
  protected async onInit() {
    if (!Providers.globalProvider) {
      Providers.globalProvider = new SharePointProvider(this.context);
    }
    customElementHelper.withDisambiguation("contoso-hr-solution");
    registerMgtPersonComponent();
  }
  public render(): void {
    this.domElement.innerHTML = `
    <section class="${styles.mgtTest} ${
      !!this.context.sdks.microsoftTeams ? styles.teams : ""
    }">
      <mgt-contoso-hr-solution-person person-query="me" view="twolines"></mgt-person>
    </section>`;
  }

  protected get dataVersion(): Version {
    return Version.parse("1.0");
  }

  protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
    return {
      pages: [
        {
          header: {
            description: strings.PropertyPaneDescription,
          },
          groups: [
            {
              groupName: strings.BasicGroupName,
              groupFields: [
                PropertyPaneTextField("description", {
                  label: strings.DescriptionFieldLabel,
                }),
              ],
            },
          ],
        },
      ],
    };
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done ✔️

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions