{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/dtslint/issues/76","repository_url":"https://api.github.com/repos/Microsoft/dtslint","labels_url":"https://api.github.com/repos/Microsoft/dtslint/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/dtslint/issues/76/comments","events_url":"https://api.github.com/repos/Microsoft/dtslint/issues/76/events","html_url":"https://github.com/Microsoft/dtslint/issues/76","id":261020915,"number":76,"title":"no-unnecessary-generics shouldn't error on return types","user":{"login":"cyrilgandon","id":2806672,"avatar_url":"https://avatars3.githubusercontent.com/u/2806672?v=4","gravatar_id":"","url":"https://api.github.com/users/cyrilgandon","html_url":"https://github.com/cyrilgandon","followers_url":"https://api.github.com/users/cyrilgandon/followers","following_url":"https://api.github.com/users/cyrilgandon/following{/other_user}","gists_url":"https://api.github.com/users/cyrilgandon/gists{/gist_id}","starred_url":"https://api.github.com/users/cyrilgandon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyrilgandon/subscriptions","organizations_url":"https://api.github.com/users/cyrilgandon/orgs","repos_url":"https://api.github.com/users/cyrilgandon/repos","events_url":"https://api.github.com/users/cyrilgandon/events{/privacy}","received_events_url":"https://api.github.com/users/cyrilgandon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-27T15:35:59Z","updated_at":"2017-10-24T15:46:34Z","closed_at":null,"author_association":"NONE","body":"- __TypeScript version__: 2.5.2\r\n- __Running TSLint via__: Visual Studio Code\r\n\r\n#### TypeScript code being linted\r\n\r\nhttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/69acc07b23b9ef174732a352fc732c363149db15/types/angular/index.d.ts#L1040\r\n\r\n```ts\r\ninterface IDeferred<T> {\r\n    resolve(value?: T | IPromise<T>): void;\r\n    reject(reason?: any): void;\r\n    notify(state?: any): void;\r\n    promise: IPromise<T>;\r\n}\r\n\r\ninterface IQService {\r\n    defer<T>(): IDeferred<T>; // error on this line\r\n}\r\n```\r\n\r\nwith `tslint.json` configuration:\r\n\r\n```json\r\n\"no-unnecessary-generics\": true\r\n```\r\n\r\n#### Actual behavior\r\nError:\r\n\r\n>Type parameter is only used once\r\n\r\n#### Expected behavior\r\n\r\nNo error, the return type is an important information.\r\n\r\nGiven the docs:\r\n>Bad:\r\n>function parse<T>(): T;\r\n>const x = parse<number>();\r\n\r\n>Good:\r\n>function parse(): {};\r\n>const x = parse() as number;\r\n\r\nMeans that instead of doing\r\n\r\n    const deferred = $q.defer<string>();\r\n\r\nWe should doing\r\n\r\n    const deferred = $q.defer() as IDeferred<string>;\r\n    // or\r\n    const deferred = <IDeferred<string>>$q.defer();\r\n\r\nI find the first syntax better than the 2 others. Is this still the official position?\r\nNote that if we change from `defer<T>(): IDeferred<T>;` to `defer(): IDeferred<{}>;`, a lot of typescript builds are going to fail. This is the same linting error we found for HttpPromise.\r\n\r\nShould we disable the rule for angular, or is the rule make sense on return types?"},"comment":{"url":"https://api.github.com/repos/Microsoft/dtslint/issues/comments/339036373","html_url":"https://github.com/Microsoft/dtslint/issues/76#issuecomment-339036373","issue_url":"https://api.github.com/repos/Microsoft/dtslint/issues/76","id":339036373,"user":{"login":"andy-ms","id":19274678,"avatar_url":"https://avatars3.githubusercontent.com/u/19274678?v=4","gravatar_id":"","url":"https://api.github.com/users/andy-ms","html_url":"https://github.com/andy-ms","followers_url":"https://api.github.com/users/andy-ms/followers","following_url":"https://api.github.com/users/andy-ms/following{/other_user}","gists_url":"https://api.github.com/users/andy-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-ms/subscriptions","organizations_url":"https://api.github.com/users/andy-ms/orgs","repos_url":"https://api.github.com/users/andy-ms/repos","events_url":"https://api.github.com/users/andy-ms/events{/privacy}","received_events_url":"https://api.github.com/users/andy-ms/received_events","type":"User","site_admin":false},"created_at":"2017-10-24T15:46:34Z","updated_at":"2017-10-24T15:46:34Z","author_association":"CONTRIBUTOR","body":"> Is this still the official position?\r\nI believe so. For new packages on DefinitelyTyped we recommend against doing casts using the type argument syntax.\r\nI'll leave this issue open in case anyone else wants to provide feedback."}}
{"actor":{"display_login":"andy-ms"}}