Skip to content

regression from 3.7.5 - Custom elements doesn't allow constructor parameters #36965

@mityok

Description

@mityok

Having extra parameters in constructor of custom elements causes error in 3.8.2:

Argument of type 'typeof Foo' is not assignable to parameter of type 'CustomElementConstructor'.(2345)

works just fine in 3.7.5

TypeScript Version: 3.8-Beta

Search Terms:

Expected behavior:

Actual behavior:

Related Issues:

Code

class Foo extends HTMLElement {
  constructor(a:string) {
    super()
  }
}

window.customElements.define('custom-tag', Foo)

class Bar extends HTMLElement {
  constructor() {
    super()
  }
}

window.customElements.define('another-custom-tag', Bar)
Output
"use strict";
class Foo extends HTMLElement {
    constructor(a) {
        super();
    }
}
window.customElements.define('custom-tag', Foo);
class Bar extends HTMLElement {
    constructor() {
        super();
    }
}
window.customElements.define('another-custom-tag', Bar);
Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "useDefineForClassFields": false,
    "alwaysStrict": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "downlevelIteration": false,
    "noEmitHelpers": false,
    "noLib": false,
    "noStrictGenericChecks": false,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "esModuleInterop": true,
    "preserveConstEnums": false,
    "removeComments": false,
    "skipLibCheck": false,
    "checkJs": false,
    "allowJs": false,
    "declaration": true,
    "experimentalDecorators": false,
    "emitDecoratorMetadata": false,
    "target": "ES2017",
    "module": "ESNext"
  }
}

Playground Link: Provided

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions