e2b-dev / E2B

Secure open source cloud runtime for AI apps & AI agents
https://e2b.dev/docs
Apache License 2.0
7.02k stars 458 forks source link

chore(js-sdk): Fix TypeScript types #181

Closed Strajk closed 1 year ago

Strajk commented 1 year ago

image

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 74f6dc35a505cbe972978eaf46f67f3f378ad081

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | -------- | ----- | | @e2b/sdk | Patch | | e2b-docs | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments | Name | Status | Preview | Updated (UTC) | | :--- | :----- | :------ | :------ | | **e2b** | ⬜️ Ignored ([Inspect](https://vercel.com/e2b/e2b/3YPBMwtZn89RHsvek42T4JsXDgkN)) | [Visit Preview](https://e2b-git-fix-ts-types-e2b.vercel.app) | Oct 2, 2023 4:02pm | | **e2b-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/e2b/e2b-docs/3taJUaRofPqzZcUvKuAcx8x5KgdM)) | [Visit Preview](https://e2b-docs-git-fix-ts-types-e2b.vercel.app) | Oct 2, 2023 4:02pm |
Strajk commented 1 year ago

Snippet to explore TS behaviour

interface BaseOpts {
  cwd: string;
  apiKey: string;
}

class Base {
  constructor(readonly opts: BaseOpts) {
    // ...
  }
}

// ---

interface SubOpts extends BaseOpts {
  onStdErr: () => void;
}

class Sub extends Base {
  readonly filesystem: any;

  constructor(opts: SubOpts) {
    super(opts);
    this.filesystem = {}
  }

  doSth() {
    this.opts.onStdErr; // this.opts is BaseOpts
    (this.opts as SubOpts).onStdErr();
  }
}
Strajk commented 1 year ago

Snippet to explore TS behaviour

interface BaseOpts {
  cwd: string;
  apiKey: string;
}

class Base {
  constructor(readonly opts: BaseOpts) {
    // ...
  }
}

// ---

interface SubOpts extends BaseOpts {
  onStdErr: () => void;
}

class Sub extends Base {
  readonly filesystem: any;

  constructor(opts: SubOpts) {
    super(opts);
    this.filesystem = {}
  }

  doSth() {
    this.opts.onStdErr; // this.opts is BaseOpts
    (this.opts as SubOpts).onStdErr();
  }
}