Skip to content

Official coding practice is not used yourself in declaration files #13882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
falsandtru opened this issue Feb 4, 2017 · 1 comment
Closed
Labels
Duplicate An existing issue was already created

Comments

@falsandtru
Copy link
Contributor

Don't write overloads that differ by type in only one argument position:

/* WRONG */
interface Moment {
utcOffset(): number;
utcOffset(b: number): Moment;
utcOffset(b: string): Moment;
}
Do use union types whenver possible:

/* OK */
interface Moment {
utcOffset(): number;
utcOffset(b: number|string): Moment;
}

https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/declaration%20files/Do's%20and%20Don'ts.md#use-union-types

TypeScript Version: master

Code

https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L330-L340

Expected behavior:

    match(regexp: string | RegExp): RegExpMatchArray | null;

Actual behavior:

    /**
      * Matches a string with a regular expression, and returns an array containing the results of that search.
      * @param regexp A variable name or string literal containing the regular expression pattern and flags.
      */
    match(regexp: string): RegExpMatchArray | null;

    /**
      * Matches a string with a regular expression, and returns an array containing the results of that search.
      * @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
      */
    match(regexp: RegExp): RegExpMatchArray | null;
@DanielRosenwasser DanielRosenwasser added Help Wanted You can do this Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript and removed Help Wanted You can do this Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Feb 6, 2017
@DanielRosenwasser
Copy link
Member

Duplicate of #5766. PR out at #13738 😄

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Feb 6, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants