microsoft / microsoft/TypeScript

random emit declaration

Open
#40,092 2 comments 0 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Aug 17, 2020.

Bug Domain: Declaration Emit Rescheduled
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:

Code

https://github.com/bluelovers/ws-yarn-workspaces/blob/master/packages/%40yarn-tool/npm-package-arg-util/lib/parseArgvPkgName.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

/// <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

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:

Related Issues:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.