-
Notifications
You must be signed in to change notification settings - Fork 149
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
Updated definitions to resolve the TS1046 error. #148
base: master
Are you sure you want to change the base?
Conversation
Not sure if this is a result of recent TypeScript changes, since I've never used node-speaker with TypeScript before, but I'm getting this error message. I can confirm that my changes resolve that error and the library functions correctly. ``` node_modules/speaker/index.d.ts:3:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier. 3 namespace Speaker { ~~~~~~~~~ ```
@@ -25,7 +25,7 @@ namespace Speaker { | |||
* | |||
* @param opts options. | |||
*/ | |||
class Speaker extends Writable { | |||
export default class Speaker extends Writable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't accurately reflect how the JavaScript code is exported, could you instead only change namespace Speaker
to declare namespace Speaker
, and leave the export as export = Speaker
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the export is not going to work like that, the export =
syntax causes TS to error with:
Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier. ts(1046)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just do declare class Speaker extends Writable {
and then leave the export = Speaker
. That seems to keep things working as expected, while fixing the errors, though, not totally sure what the differences might be in the approaches.
Can confirm this fixes the issue of using this library with latest versions of Typescript. |
Not sure if this is a result of recent TypeScript changes, since I've never used node-speaker with TypeScript before, but I'm getting this error message. I can confirm that my changes resolve that error and the library functions correctly.