Sp-dev-docs: Getting property overridden error for dataVersion()

Created on 11 Sep 2020  路  9Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [x] Bug

Describe the bug

I get this error
https://imgur.com/qv6u8Jh

Steps to reproduce

Load the basic React tutorial template, no more changes needed

Expected behavior

No error

Environment details (development & target environment)

Windows 10
SharePoint Online
Node.js v10
Chrome v79
VS Code | SPFx v1.10.0

tooling answered question

All 9 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Seeing this for me as well after upgrading VS Code to August 2020 (v 1.49)

I can get rid of this error by changing the Typescript version in VSCode in use for the project workspace(v3.3), instead of using VSCode's default 4.0.2 (introduced in VSCode August 2020 release).
You can change the typescript version at the bottom right of the editor sceeen - click on the version number next to Typescript, then at the top of the editor screen select your workspace's typescript version.

So to fix it we just need to set the ts version to what the spfx ts version is, which is v3.3?

So to fix it we just need to set the ts version to what the spfx ts version is, which is v3.3?

Yes.
The bigger question will be:
Is this an SPFX issue, Typescript 4 issue or VSCode intellisense issue.

Good thing all of those are Microsoft owned lol

This isn't really a SPFx issue... just two versions of TypeScript conflict. The solution above by @stchiew would be the best approach.

Using TS 4.X in VSCode provides a better authoring experience...

image

I'm opting to ignore the IDE errors re 'overridden as an accessor' since they are not compile errors.

That said, moving these accessor overrides into the constructor like so may be a workaround if the warnings really bother you (not tested):

constructor() {
    super();
    Object.defineProperty(this, "dataVersion", {
      get() {
        return Version.parse('1.0');
      }
    });
  }

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

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waldekmastykarz picture waldekmastykarz  路  3Comments

StfBauer picture StfBauer  路  3Comments

bengtmoss picture bengtmoss  路  3Comments

mikeparkie picture mikeparkie  路  3Comments

patrick-rodgers picture patrick-rodgers  路  3Comments