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

Verify public interface #69

Closed
BenjaminGrayNp1 opened this issue Aug 8, 2023 · 1 comment · Fixed by #70
Closed

Verify public interface #69

BenjaminGrayNp1 opened this issue Aug 8, 2023 · 1 comment · Fixed by #70

Comments

@BenjaminGrayNp1
Copy link
Contributor

Hi again,

In trying to use the new release in https://github.com/jeanp413/open-remote-ssh, there are several TypeScript errors due to how it is currently consumed by that package. This is the relevant file.

src/ssh/sshConfig.ts:4:21 - error TS2614: Module '"ssh-config"' has no exported member 'Directive'. Did you mean to use 'import Directive from "ssh-config"' instead?

4 import SSHConfig, { Directive, Line, Section } from 'ssh-config';
                      ~~~~~~~~~

src/ssh/sshConfig.ts:4:32 - error TS2614: Module '"ssh-config"' has no exported member 'Line'. Did you mean to use 'import Line from "ssh-config"' instead?

4 import SSHConfig, { Directive, Line, Section } from 'ssh-config';
                                 ~~~~

src/ssh/sshConfig.ts:4:38 - error TS2614: Module '"ssh-config"' has no exported member 'Section'. Did you mean to use 'import Section from "ssh-config"' instead?

4 import SSHConfig, { Directive, Line, Section } from 'ssh-config';
                                       ~~~~~~~

src/ssh/sshConfig.ts:49:37 - error TS2749: 'SSHConfig' refers to a value, but is being used as a type here. Did you mean 'typeof SSHConfig'?

49 function normalizeSSHConfig(config: SSHConfig) {
                                       ~~~~~~~~~

src/ssh/sshConfig.ts:68:45 - error TS2749: 'SSHConfig' refers to a value, but is being used as a type here. Did you mean 'typeof SSHConfig'?

68     const includedConfigs = new Map<number, SSHConfig>();
                                               ~~~~~~~~~

src/ssh/sshConfig.ts:97:36 - error TS2749: 'SSHConfig' refers to a value, but is being used as a type here. Did you mean 'typeof SSHConfig'?

97     constructor(private sshConfig: SSHConfig) {
   

It looks like a couple of issues

  • It expects SSHConfig to be a class, whereas this package exports a 'customised data value' or something (whatever it is, TypeScript doesn't like using it as a type).
  • Directive, Line, and Section are not exported

To address this, I would consider making parse and stringify static methods on the SSHConfig, which can be exported directly. Also, as they are reachable through params and return values, the Line, Match, Section, Directive, Comment, FindOptions, and MatchOptions interfaces should be exported. MatchParams and ComputeContext specifically should not be exported, as they are for internal .compute logic.

@cyjake
Copy link
Owner

cyjake commented Aug 8, 2023

agree, the Object.assign(SSHConfig, { parse, stringify}) can be replaced with static methods

named exports of parse, stringify should be kept, as is the vanilla export default class SSHConfig {}

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 a pull request may close this issue.

2 participants