mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Type spawn's args as a ReadonlyArray of string (#25487)
At the moment, this snippet:
```ts
const spawnArgs: ReadonlyArray<string> = ['foo', 'bar'];
spawn('foobar', spawnArgs);
```
fails with:
```
Argument of type 'ReadonlyArray<string>' is not assignable to parameter of type 'string[] | undefined'.
Type 'ReadonlyArray<string>' is not assignable to type 'string[]'.
```
Looking at https://github.com/nodejs/node/blob/master/lib/child_process.js#L514-L535 and https://github.com/nodejs/node/blob/master/lib/internal/child_process.js#L286, it _looks_ like there is no mutation of the array. I am no expert so I'd be happy to be proven wrong, I just couldn't find sufficient evidence that a `ReadonlyArray` wouldn't be fine.
This is not a breaking change because passing a `string[]` is still valid.
This commit is contained in:
Vendored
+1
-1
@@ -2101,7 +2101,7 @@ declare module "child_process" {
|
||||
windowsHide?: boolean;
|
||||
}
|
||||
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -881,7 +881,7 @@ declare module "child_process" {
|
||||
unref(): void;
|
||||
}
|
||||
|
||||
export function spawn(command: string, args?: string[], options?: {
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: {
|
||||
cwd?: string;
|
||||
stdio?: any;
|
||||
custom?: any;
|
||||
|
||||
Vendored
+1
-1
@@ -1240,7 +1240,7 @@ declare module "child_process" {
|
||||
gid?: number;
|
||||
shell?: boolean | string;
|
||||
}
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -1787,7 +1787,7 @@ declare module "child_process" {
|
||||
gid?: number;
|
||||
shell?: boolean | string;
|
||||
}
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -1847,7 +1847,7 @@ declare module "child_process" {
|
||||
gid?: number;
|
||||
shell?: boolean | string;
|
||||
}
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -2091,7 +2091,7 @@ declare module "child_process" {
|
||||
windowsHide?: boolean;
|
||||
}
|
||||
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -2091,7 +2091,7 @@ declare module "child_process" {
|
||||
windowsHide?: boolean;
|
||||
}
|
||||
|
||||
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
|
||||
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
|
||||
|
||||
export interface ExecOptions {
|
||||
cwd?: string;
|
||||
|
||||
Reference in New Issue
Block a user