Skip to content
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

Exporting function with property declaration causes invalid type emit #31918

Closed
AnyhowStep opened this issue Jun 15, 2019 · 5 comments
Closed

Comments

@AnyhowStep
Copy link
Contributor

TypeScript Version: 3.5.1

Search Terms:

function property declaration, emit, multiple

Code

export function foo () {

}
foo.x = 32;

export function bar () {

}
bar.x = 32;

Expected behavior:

Not have default exports

Actual behavior:

declare function foo(): void;
declare namespace foo {
    var x: number;
}
/*
A module cannot have multiple default exports.ts(2528)
__test-function.d.ts(10, 16): Another export default is here.
*/
export default foo;
declare function bar(): void;
declare namespace bar {
    var x: number;
}
/*
A module cannot have multiple default exports.ts(2528)
__test-function.d.ts(5, 16): The first export default is here.
*/
export default bar;

Playground Link:

Playground does not generate .d.ts files

Related Issues:

@AnyhowStep
Copy link
Contributor Author

Actually, even having just one will make it use export default, which isn't what I want at all =/

@AnyhowStep
Copy link
Contributor Author

The solution seems to be,

function foo () {

}
foo.x = 32;

function bar () {

}
bar.x = 32;

export {foo, bar}

@AnyhowStep
Copy link
Contributor Author

It seems like this does not happen with TS 3.3

@AnyhowStep AnyhowStep changed the title Multiple functions with property declarations causes invalid type emit Exporting function with property declaration causes invalid type emit Jun 15, 2019
@fatcerberus
Copy link

Related to, and possibly a duplicate of #31676, it looks like.

@AnyhowStep
Copy link
Contributor Author

Ah, yes, it is a duplicate of that. Thank you for finding it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants