google / google/closure-compiler

OTI: Interface functions have no usable type

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

Description

Source:

``` js
/** @interface */
function X() {}

/** @param {function(this: X)} a */
function init(a) {}

init(X);
```

Error:

``` js
input0:7: WARNING - actual parameter 1 of init does not match formal parameter
found : function (this:X): ?
required: function (this:X): ?
init(X);
^
```

I can't find any type other than `?` that `X` is convertible to (not even `Function`).

Under NTI, it works fine, as `function(new: X)`, as I would expect

http://closure-compiler-debugger.appspot.com/#input0%3D%252F**%2520%2540interface%2520*%252F%250Afunction%2520X()%2520%257B%257D%250A%250A%252F**%2520%2540param%2520%257Bfunction(this%253A%2520X)%257D%2520a%2520*%252F%250Afunction%2520init(a)%2520%257B%257D%250A%250Ainit(X)%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26CHECK_TYPES%3D1%26MISSING_PROPERTIES%3D1

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.