Title: Error when trying to emit declarations for a module with a non exported base class · Issue #9865 · microsoft/TypeScript · GitHub
Open Graph Title: Error when trying to emit declarations for a module with a non exported base class · Issue #9865 · microsoft/TypeScript
X Title: Error when trying to emit declarations for a module with a non exported base class · Issue #9865 · microsoft/TypeScript
Description: TypeScript Version: 2.0.0 Code // file: animal.ts abstract class Animal { name: string; constructor(name: string) { this.name = name; } abstract shout(): string; } export class Snail extends Animal { shout(): string { return '...'; } } I...
Open Graph Description: TypeScript Version: 2.0.0 Code // file: animal.ts abstract class Animal { name: string; constructor(name: string) { this.name = name; } abstract shout(): string; } export class Snail extends Animal...
X Description: TypeScript Version: 2.0.0 Code // file: animal.ts abstract class Animal { name: string; constructor(name: string) { this.name = name; } abstract shout(): string; } export class Snail extends Animal...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9865
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error when trying to emit declarations for a module with a non exported base class","articleBody":"\u003c!-- BUGS: Please use this template. -->\n\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\n\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\n\n**TypeScript Version:** 2.0.0\n\n**Code**\n\n``` ts\n// file: animal.ts\nabstract class Animal {\n name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n abstract shout(): string;\n}\n\nexport class Snail extends Animal {\n shout(): string {\n return '...';\n }\n}\n```\n\nI'm trying to emit declarations files .d.ts with `tsc --declaration` in order to get such a following file:\n\n**Expected behavior:**\nFile animal.js well generated as well as file animal.d.ts:\n\n``` js\n// file: animal.d.ts\ndeclare abstract class Animal {\n name: string;\n constructor(name: string);\n abstract shout();\n}\n\nexport declare class Snail extends Animal {\n shout();\n}\n```\n\n**Actual behavior:**\nFile animal.js well generated **but** no file animal.d.ts. I got an error instead:\n`error TS4020: Extends clause of exported class 'Snail' has or is using private name 'Animal'.`\n\nIt is maybe a misunderstanding of mine, but in my mind, when a code compiles with tsc, it should also compile with the `--declaration` flag.\n\nFor information, here is my tsconfig.json:\n\n``` ts\n// file: tsconfig.json\n{\n \"compilerOptions\": {\n \"noImplicitAny\": true,\n \"strictNullChecks\": true,\n \"target\": \"es5\",\n \"module\": \"amd\",\n \"outDir\": \"./build\"\n },\n \"exclude\" : [\n \"./build\",\n \"./node_modules\"\n ]\n}\n```\n","author":{"url":"https://github.com/yahiko00","@type":"Person","name":"yahiko00"},"datePublished":"2016-07-21T10:18:02Z","url":"https://github.com/microsoft/TypeScript/issues/9865"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:836afa9e-15e3-9d22-efc6-0fbd5bff84ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFAC:31D532:771035:9DA1D1:6B01AAB7 |
| html-safe-nonce | 4f34b13fb91044f7fd95d5f942135c28d7fee974ea196e3c4370c591bc4a5d1a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkFDOjMxRDUzMjo3NzEwMzU6OURBMUQxOjZCMDFBQUI3IiwidmlzaXRvcl9pZCI6IjgzNjE0Mjg0MDUwNjkxMzA0MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6f2c952dc12bc6298abd5bdf1d70ed5ce892b56c7c64bee4d9c9d51a5f4c6ea4 |
| hovercard-subject-tag | issue:166785269 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/9865/issue_layout |
| twitter:image | https://opengraph.githubassets.com/147e894a3841c2ab0e96195b806e06492a96fedaa65f479ae16e6a0442179ab2/microsoft/TypeScript/issues/9865 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/147e894a3841c2ab0e96195b806e06492a96fedaa65f479ae16e6a0442179ab2/microsoft/TypeScript/issues/9865 |
| og:image:alt | TypeScript Version: 2.0.0 Code // file: animal.ts abstract class Animal { name: string; constructor(name: string) { this.name = name; } abstract shout(): string; } export class Snail extends Animal... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yahiko00 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width