Skip to content

In JS, any declaration with a non-primitive initializer should be a JS container #22637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sandersn opened this issue Mar 16, 2018 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@sandersn
Copy link
Member

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
// from clear-require
var clear = moduleId => 2
clear.all = () => 1

Expected behavior:
all is a property on clear, and has the type () => number.

Actual behavior:
Error: 'all' is not a property on 'clear'.

Maybe any top-level declaration with a non-primitive initialiser should create a container in Javascript, although that would be hard to verify in the binder.

@sandersn sandersn changed the title In JS, arrow functions should be JS containers In JS, any declaration with a non-primitive initializer should be a JS container Mar 16, 2018
@sandersn
Copy link
Member Author

Another example, this time from a call expression:

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
// from axios
function A(x) {
    this.x = x
}
function createInstance(defaultConfig) {
    return new A(defaultConfig.x);
}
var a = createInstance({ x: 1 })
a.all = function () { }

@DanielRosenwasser DanielRosenwasser added the checkJs Relates to checking JavaScript using TypeScript label Mar 16, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Mar 28, 2018

The first example is a bit weird given that this means something different here.

The second seems like a duplicate of #10868

@mhegazy mhegazy added Duplicate An existing issue was already created and removed checkJs Relates to checking JavaScript using TypeScript labels Mar 28, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants