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
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Writable, WritableOptions } from 'stream';

namespace Speaker {
export namespace Speaker {
interface Options extends WritableOptions {
readonly channels?: number;
readonly bitDepth?: number;
Expand All @@ -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.

constructor(opts?: Speaker.Options);

/**
Expand Down Expand Up @@ -55,5 +55,3 @@ class Speaker extends Writable {
*/
public isSupported(format: number): boolean;
}

export = Speaker