google / google/closure-compiler

Extending Generic Classes in ES6 - No Errors/Warnings

Open
#822 7 comments 0 reactions 0 assignees View on GitHub
ES6
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

I'm not sure if I have the [JSCompiler Debugger](https://closure-compiler-debugger.appspot.com/#input0%3D%252F**%2520%2540template%2520T%2520*%252F%250Aclass%2520Foo%2520%257B%250A%2520%2520%252F**%2520%2540param%2520%257BT%257D%2520value%2520*%252F%250A%2520%2520constructor%28value%29%2520%257B%257D%250A%257D%250A%250A%252F**%2520%2540extends%2520%257BFoo.%253Cstring%253E%257D%2520*%252F%250Aclass%2520Doo%2520extends%2520Foo%2520%257B%250A%2520%2520constructor%28%29%2520%257B%250A%2520%2520%2520%2520%252F%252Fsuper%28%2522Hello%2522%29%250A%2520%2520%2520%2520super%28100%29%250A%2520%2520%257D%250A%257D%250A%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26CHECK_TYPES%3D1%26LANG_IN_IS_ES6%3D1%26MISSING_PROPERTIES%3D1%26PRETTY_PRINT%3D1%26TRANSPILE%3D1) setup correct but the following code doesn't result in any errors or warnings...

```
/** @template T */
class Foo {
/** @param {T} value */
constructor(value) {}
}

/** @extends {Foo.} */
class Doo extends Foo {
constructor() {
super(100) // no error or warning for this?
}
}
```

As far as I know, TypeScript supports generics so maybe that will be one solution. I imagine the code looking something like this...

```
class Foo {
constructor(value:T) {}
}

class Doo extends Foo {
constructor() {
super("Hello")
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.