Skip to content

Property assignment to static method of class breaks declaration emit #38553

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
TimvdLippe opened this issue May 13, 2020 · 0 comments · Fixed by #38920
Closed

Property assignment to static method of class breaks declaration emit #38553

TimvdLippe opened this issue May 13, 2020 · 0 comments · Fixed by #38920
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files

Comments

@TimvdLippe
Copy link
Contributor

TypeScript Version: 4.0.0-dev.20200512

Search Terms: jsdoc, declaration, static method

Code

clazz.js:

export class Clazz {
  static method() {}
}

Clazz.method.prop = 5;

tsconfig.json:

{
  "compilerOptions": {
    "outDir": "lib",
    "declaration": true,
    "allowJs": true,
    "checkJs": true
  },
  "files": [
    "clazz.js"
  ]
}

Expected behavior:
The emitted declaration file is:

export class Clazz {
    static method(): void;
}
export namespace Clazz {
    export namespace method {
        export const prop: number;
    }
}

Actual behavior:

export class Clazz {
}

Note that if the method is not static, it properly generates the declaration file.

Also, please don't ask me why this is in the DevTools codebase. I only found out that we did when TypeScript started complaining about missing methods even though they were defined. I then spend a long time trying to figure out what the issue was, until I discovered the property assignment. When I changed the property assignment to a normal variable declaration, TS was properly emitting the method again.

Playground Link:

Related Issues:

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
Projects
None yet
3 participants