这是indexloc提供的服务,不要输入任何密码
Skip to content

type issue with node: style imports #1367

@theoephraim

Description

@theoephraim

Very odd issue related to using a node: style import and using typeof of something imported.
In this case its from child_process, but I suspect it would happen for other built-in modules too.

import { execSync } from 'node:child_process'; // DOES NOT WORK
// import { execSync } from 'child_process';       // WORKS

export function execHelper(
  command: string,
  opts?: Parameters<typeof execSync>[1] // <- this `typeof execSync` causes the issue
) {
  // ... some extra logic
  return execSync(command, opts);
}

Repro here - https://stackblitz.com/edit/child-process-ts-issue?file=README.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions