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

Updated definitions to resolve the TS1046 error. #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 {
  ~~~~~~~~~
```
@@ -25,7 +25,7 @@ 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