Skip to content
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

List of syntactic definition file errors we could detect #9027

Closed
RyanCavanaugh opened this issue Jun 8, 2016 · 7 comments
Closed

List of syntactic definition file errors we could detect #9027

RyanCavanaugh opened this issue Jun 8, 2016 · 7 comments
Assignees
Labels
Community Tooling This might be better handled by tooling from the community instead of built into TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Jun 8, 2016

Signatures that differ only by a single parameter type

declare function fn2(x: number): void;
// Error, write one signature taking string|number
declare function fn2(x: string): void;

Signatures that differ only by omitting by a parameter

declare function fn6(): void;
// Error, write one signature with one optional parameter
declare function fn6(s: string): void;

Use of the non-primitive names anywhere

(except in a interface Number { declaration)

declare var var1: Number; // Error, use 'number'

Optional parameters in callback positions:

declare function fn5(callback: (key: string, value?: number) => void): void;
@RyanCavanaugh RyanCavanaugh added the @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped label Jun 8, 2016
@DanielRosenwasser DanielRosenwasser added the Community Tooling This might be better handled by tooling from the community instead of built into TypeScript label Jun 8, 2016
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.0 milestone Jun 8, 2016
@dead-claudia
Copy link

Just an opinion, but this sounds more like a linter error than a syntax error. Not saying it's a bad idea to warn, but I would disagree about it being something that should be completely rejected.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 17, 2016

@isiahmeadows the intention here is to implement these as tslint rules and suggest them for definition authors, and may be run them on definitelytyped CI.

@dead-claudia
Copy link

@mhegazy Oh. Okay. I get what you mean.

@RyanCavanaugh
Copy link
Member Author

RyanCavanaugh commented Jun 30, 2016

Non-consecutive function overloads in the same block

interface Foo {
  x(): void;
  y(): void;
  x(s: string): number; // <-- error, all 'x' signatures should be adjacent
}

@mhegazy mhegazy modified the milestones: TypeScript 2.0, TypeScript 2.0.1 Jul 5, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Aug 16, 2016

@rakatyal can we mark this as completed?

@mhegazy mhegazy modified the milestones: Community, TypeScript 2.0.1 Aug 16, 2016
@rakatyal
Copy link

@mhegazy: There are a couple of Open PRs on the tslint repo regarding this. One of them has been merged. Also we decided to wait to implement the primitive names till this gets in.
So let's keep it open for now.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 24, 2017

These should all be addressed now in https://github.com/Microsoft/dtslint

@mhegazy mhegazy closed this as completed Apr 24, 2017
@mhegazy mhegazy removed this from the Community milestone Apr 26, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Tooling This might be better handled by tooling from the community instead of built into TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

5 participants