Repository: TypeScript
Issue: random emit declaration
Labels: Bug,Fix Available,Rescheduled

<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

<!--
Please try to reproduce the issue with the latest published version. It may have already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
-->
**TypeScript Version:**  3.7.x-dev.201xxxxx

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**

**Code**

https://github.com/bluelovers/ws-yarn-workspaces/blob/master/packages/%40yarn-tool/npm-package-arg-util/lib/parseArgvPkgName.ts

```ts
import { npa, getSemverFromNpaResult} from '../index';
import { stripScope } from './stripScope';
import { IParsePackageName, IResult } from './types';

/**
 * @deprecated
 */
export function parseArgvPkgName(input: string)
{
	const result = npa(input)

	if (result)
	{
		return {
			input,
			namespace: result.scope,
			name: stripScope(result.name),
			version: getSemverFromNpaResult(result),
			result,
		}
	}
}

export function parsePackageName(packageName: string): IParsePackageName
{
	const result = npa(packageName)

	const subname = stripScope(result.name);

	let semver = getSemverFromNpaResult(result);

	if (!semver?.length)
	{
		semver = void 0;
	}

	return {
		type: result.type,
		name: result.name,
		scope: result.scope,
		subname,
		semver,
		result,
	}
}

```

**Expected behavior:**

emit .d.ts always same

**Actual behavior:**

random emit one of code

```ts
/// <reference types="npm-package-arg" />
import { IParsePackageName } from './types';
/**
 * @deprecated
 */
export declare function parseArgvPkgName(input: string): {
    input: string;
    namespace: string;
    name: string;
    version: string;
    result: import("npm-package-arg").FileResult | import("npm-package-arg").HostedGitResult | import("npm-package-arg").URLResult | import("npm-package-arg").AliasResult | import("npm-package-arg").RegistryResult;
};
export declare function parsePackageName(packageName: string): IParsePackageName;
```

or

```ts
import { IParsePackageName, IResult } from './types';
/**
 * @deprecated
 */
export declare function parseArgvPkgName(input: string): {
    input: string;
    namespace: string;
    name: string;
    version: string;
    result: IResult;
};
export declare function parsePackageName(packageName: string): IParsePackageName;
```

**Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->

**Related Issues:** <!-- Did you find other bugs that looked similar? -->