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

Attaching property to exported function creates invalid definition file #29206

Closed
SimenB opened this issue Dec 30, 2018 · 6 comments · Fixed by #29242
Closed

Attaching property to exported function creates invalid definition file #29206

SimenB opened this issue Dec 30, 2018 · 6 comments · Fixed by #29242
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@SimenB
Copy link

SimenB commented Dec 30, 2018

TypeScript Version: 3.3.0-dev.20181229

Search Terms:
default export function property namespace

Code

export default function someFunc() {
    return 'hello!';
}

someFunc.someProp = 'yo';

Expected behavior:
The declaration file should be valid

Actual behavior:

packages/proj-1/build/index.d.ts:2:26 - error TS1005: ';' expected.

2 export default namespace someFunc {
                           ~~~~~~~~

packages/proj-1/build/index.d.ts:2:35 - error TS1005: ';' expected.

2 export default namespace someFunc {

Playground Link: Cannot be reproduced in the playground as the issue is in the d.ts file, not the JS. However, I've setup a repository: https://github.com/SimenB/tsc-b-auch

Related Issues: None found

@SimenB
Copy link
Author

SimenB commented Dec 30, 2018

Note that the file is generated successfully, it's only when trying to consume it things fall apart

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Help Wanted You can do this Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Domain: Declaration Emit The issue relates to the emission of d.ts files labels Dec 31, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.4.0 milestone Dec 31, 2018
@DanielRosenwasser
Copy link
Member

Haven't tried this, but you can probably get around this by writing

function someFunc() {
    return 'hello!';
}

someFunc.someProp = 'yo';

export default someFunc;

@SimenB
Copy link
Author

SimenB commented Jan 1, 2019

Yeah, that works! Thanks 🙂

@DanielRosenwasser
Copy link
Member

Thanks @Kingwl!

@Diokuz
Copy link

Diokuz commented Apr 26, 2019

Have the same issue.
@DanielRosenwasser Is this by design?

yarn tsc --version
Version 3.4.5

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 26, 2019

This is scheduled for 3.5.0. You can npm install typescript@next and if you're still seeing issues, open up a new issue.

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants