Skip to content

Typescript compilation error TS1046 #17

@vaggeliskls

Description

@vaggeliskls

When i try to compile and use this library with typescript a typescript error occurs.
Error:
node_modules/address/lib/address.d.ts:1:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

There is a definition problem on address.d.ts. The namespace have to be replaced with
declare namespace .
Working Code:

declare namespace address {
  function ip(interfaceName?: string): string

  function ipv6(interfaceName?: string): string 

  function mac(callback: (err: Error, addr: string) => void): void
  function mac(interfaceName: string, callback: (err: Error, addr: string) => void): void
  
  function dns(callback: (err: Error, servers: string[]) => void): void
  function dns(filePath: string, callback: (err: Error, servers: string[]) => void): void

  function address(callback: (err: Error, addr: { ip: string, ipv6: string, mac: string }) => void): void
  function address(interfaceName: string, callback: (err: Error, addr: { ip: string, ipv6: string, mac: string }) => void): void
}

export = address

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions