vss-web-extension-sdk icon indicating copy to clipboard operation
vss-web-extension-sdk copied to clipboard

Typings in vss.d.ts conflict with TypeScript 3.1 dom library

Open vassilyl opened this issue 6 years ago • 9 comments

Error message: error TS2320: Interface 'SVGElement' cannot simultaneously extend types 'Element' and 'SVGElementInstance'.

Minimum repro contains just the recommended tsconfig.json and one-line main.ts. It compiles ok with TypeScript 2 but errors when trying to compile with TypeScript 3 (see log below). The issue can be resolved by deleting declaration of EventTarget interface from vss.d.ts:3065.

>npx typescript@2 -v
npx: installed 1 in 5.498s
Version 2.9.2

>npx typescript@2 -p .
npx: installed 1 in 11.489s

>npx typescript@3 -v
npx: installed 1 in 6.072s
Version 3.1.3

>npx typescript@3 -p .
npx: installed 1 in 5.928s
../../../Users/vassilyl/AppData/Roaming/npm-cache/_npx/18096/node_modules/typescript/lib/lib.dom.d.ts:12171:11 - error TS2320: Interface 'SVGElement' cannot simultaneously extend types 'Element' and 'SVGElementInstance'.
  Named property 'nodeType' of types 'Element' and 'SVGElementInstance' are not identical.

12171 interface SVGElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, SVGElementInstance, HTMLOrSVGElement, ElementCSSInlineStyle {
                ~~~~~~~~~~

vassilyl avatar Oct 12 '18 10:10 vassilyl

typescript -v = 3.1.3 my package.json:

    "@types/jquery": "^2.0.34",
    "@types/q": "0.0.32",
    "vss-web-extension-sdk": "^4.125.2"

Same problem here plus:

./../../AppData/Roaming/nvm/v8.2.0/node_modules/typescript/lib/lib.dom.d.ts:12171:11 - error TS2320: Interface 'SVGElement' cannot simultaneously extend types 'Element' and 'SVGElementInstance'.
  Named property 'nodeType' of types 'Element' and 'SVGElementInstance' are not identical.

12171 interface SVGElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, SVGElementInstance, HTMLOrSVGElement, ElementCSSInlineStyle {
                ~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:544:5 - error TS7010: 'removeChannel', which lacks return-type annotation, implicitly has an 'any' return type.

544     removeChannel(channel: IXDMChannel);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:833:5 - error TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type.

833     close();
        ~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:840:5 - error TS7010: 'setTitle', which lacks return-type annotation, implicitly has an 'any' return type.

840     setTitle(title: string);
        ~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:845:5 - error TS7010: 'updateOkButton', which lacks return-type annotation, implicitly has an 'any' return type.

845     updateOkButton(enabled: boolean);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:1167:5 - error TS7010: 'execute', which lacks return-type annotation, implicitly has an 'any' return type.

1167     execute?(actionContext: any);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:12266:30 - error TS7006: Parameter 'IGridColumn' implicitly has an 'any' type.

12266     getHeaderCellContents?: (IGridColumn) => JQuery;
                                   ~~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:35229:76 - error TS7006: Parameter 'args' implicitly has an 'any' type.

35229 export function attachResize(element: any, handler: (e: JQueryEventObject, args?) => void): void;

AlessandroDalMas avatar Oct 18 '18 07:10 AlessandroDalMas

Also hitting this issue when trying to update an Angular 5 project to Angular 7 which includes TypeScript 3.1. Any possibility of a fix? Would you accept a pull request to make the change @vassilyl suggests?

RobJellinghaus avatar Oct 31 '18 16:10 RobJellinghaus

Getting the same error here as well. I was thinking that this is related to typescript, not VSS. TypeScript: 3.2.2

thusithagh avatar Dec 19 '18 03:12 thusithagh

Getting this error as well in Typescript 3.0+ only when using vss-web-extension-sdk.

kavengagne avatar Dec 20 '18 05:12 kavengagne

Hi Team Any updates on the fix, getting this error only when using the vss-web-extension-sdk. I have installed TypeScript globally and updated the vss.d.ts to remove the duplicate interface to avoid this issue.

vCillusion avatar Feb 26 '19 10:02 vCillusion

I can confirm the same error(s) with TypeScript 3.3.

kalebpederson avatar Feb 26 '19 17:02 kalebpederson

I was able to fix the issue by making nodeType readonly (see https://github.com/kalebpederson/vss-web-extension-sdk/commit/fde8d2bc775273ec2f1af3b6ae992c5b7ea0d5ef) to match the definition in the TypeScript lib.dom bindings.

Version info:

  • "@types/jquery": "^2.0.34",
  • "@types/q": "0.0.32",
  • "typescript": "^3.3.3333"

I'll create a PR if there's interest.

kalebpederson avatar Mar 05 '19 20:03 kalebpederson

It's not an ideal solution, but adding this to the tsconfig.json:

"compilerOptions": {
  "skipLibCheck": true
}

Prevents the the vss.d.ts definition from creating conflicts with the base lib.dom.d.ts definition.

Nickardson avatar Sep 06 '19 01:09 Nickardson

It's not an ideal solution, but adding this to the tsconfig.json:

"compilerOptions": {
  "skipLibCheck": true
}

Prevents the the vss.d.ts definition from creating conflicts with the base lib.dom.d.ts definition.

It solves my problem. These two compilation errors annoy me. Thanks.

my tsconfig.json
{
  "compilerOptions": {
    "target": "es6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
    "module": "amd",                          /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "declaration": false,                     /* Generates corresponding '.d.ts' file. */
    "declarationMap": false,                  /* Generates a sourcemap for each corresponding '.d.ts' file. */
    "sourceMap": false,                       /* Generates corresponding '.map' file. */
    "removeComments": true,                   /* Do not emit comments to output. */
    "strictNullChecks": false,                /* Enable strict null checks. */
    "skipLibCheck": true,
    "moduleResolution": "node",               /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */                                       /* List of root folders whose combined content represents the structure of the project at runtime. */
    "typeRoots": ["node_modules/@types"],     /* List of folders to include type definitions from. */
    "types": ["vss-web-extension-sdk"],       /* Type declaration files to be included in compilation. */
    "esModuleInterop": false,                 /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "inlineSourceMap": false,                 /* Emit a single file with source maps instead of having a separate file. */
    "inlineSources": false,                   /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
    "experimentalDecorators": true,           /* Enables experimental support for ES7 decorators. */
  },
  "exclude": [
      "node_modules"
  ]
}
bash error message:
$ tsc
../../Program Files/nodejs/node_global/node_modules/typescript/lib/lib.dom.d.ts:13171:11 - error TS2320: Interface 'SVGElement' 
cannot simultaneously extend types 'Element' and 'SVGElementInstance'.
  Named property 'nodeType' of types 'Element' and 'SVGElementInstance' are not identical.

13171 interface SVGElement extends Element, DocumentAndElementEventHandlers, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrSVGElement, SVGElementInstance {
                ~~~~~~~~~~

node_modules/vss-web-extension-sdk/typings/vss.d.ts:33080:5 - error TS2416: Property 'getHash' in type 'HostNavigationService' is not assignable to the same property in base type 'IHostNavigationService'.
  Type '() => import("D:/Works/boards-extensions/node_modules/vss-web-extension-sdk/node_modules/@types/q/index").Promise<string>' is not assignable to type '() => Q.Promise<string>'.
    Call signature return types 'Promise<string>' and 'Promise<string>' are incompatible.
      The types of 'then(...).spread' are incompatible between these types.
        Types of parameters 'onFulfill' and 'onFulfill' are incompatible.
          Type 'Q.IWhenable<U>' is not assignable to type 'import("D:/Works/boards-extensions/node_modules/vss-web-extension-sdk/node_modules/@types/q/index").IWhenable<U>'.
            Type 'PromiseLike<U>' is not assignable to type 'IWhenable<U>'.
              Type 'PromiseLike<U>' is not assignable to type 'IPromise<U>'.
                Types of property 'then' are incompatible.
                  Types of parameters 'onrejected' and 'onReject' are incompatible.
                    Type 'IWhenable<U>' is not assignable to type 'U | PromiseLike<U>'.
                      Type 'IPromise<U>' is not assignable to type 'U | PromiseLike<U>'.
                        Type 'IPromise<U>' is not assignable to type 'PromiseLike<U>'.
                          Types of property 'then' are incompatible.
                            Types of parameters 'onFulfill' and 'onfulfilled' are incompatible.
                              Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IWhenable<TResult2>'.
                                Type 'TResult1' is not assignable to type 'IWhenable<TResult2>'.
                                  Type 'TResult1' is not assignable to type 'IPromise<TResult2>'.

33080     getHash(): Q.Promise<string>;
          ~~~~~~~


Found 2 errors.

VAllens avatar Nov 25 '19 09:11 VAllens