Skip to content

Conversation

@mat-sz
Copy link

@mat-sz mat-sz commented Jul 25, 2020

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 {
  ~~~~~~~~~

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 {
  ~~~~~~~~~
```
* @param opts options.
*/
class Speaker extends Writable {
export default class Speaker extends Writable {
Copy link
Collaborator

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?

Copy link
Author

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)

Copy link

@MasterOdin MasterOdin Aug 24, 2020

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.

@MasterOdin
Copy link

Can confirm this fixes the issue of using this library with latest versions of Typescript.

mildsunrise added a commit to mildsunrise/node-speaker that referenced this pull request Sep 8, 2020
Mesteery pushed a commit to Mesteery/node-speaker that referenced this pull request Apr 24, 2022
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

Successfully merging this pull request may close these issues.

3 participants