Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

no-redeclare: false positives for type definitions #443

Closed
OliverJAsh opened this issue Feb 7, 2018 · 1 comment · Fixed by #540
Closed

no-redeclare: false positives for type definitions #443

OliverJAsh opened this issue Feb 7, 2018 · 1 comment · Fixed by #540

Comments

@OliverJAsh
Copy link

OliverJAsh commented Feb 7, 2018

What version of TypeScript are you using?
2.6.1

What version of typescript-eslint-parser are you using?
12.0.0

What code were you trying to parse?

const Foo = 1;
// unexected error: 'Foo' is already defined. (no-redeclare)
type Foo = 1;

We've decided to disable this ESLint rule as TypeScript also provides similar functionality anyway, but logging this just for others/reference.

For context, this pattern is common when using unionize:

import { unionize, ofType } from 'unionize'

export const Action = unionize({
  ADD_TODO:                ofType<{ id: string; text: string }>(),
  SET_VISIBILITY_FILTER:   ofType<'SHOW_ALL' | 'SHOW_ACTIVE' | 'SHOW_COMPLETED'>(),
  TOGGLE_TODO:             ofType<{ id: string }>(),
});

export type Action = typeof Action._Union;
@JamesHenry
Copy link
Member

A custom rule will need to be created in the plugin to handle this. It would be fantastic if one of the people affected by this issue could contribute to it.

@platinumazure platinumazure changed the title no-declare false positives for type definitions no-redeclare false positives for type definitions Jun 10, 2018
@OliverJAsh OliverJAsh changed the title no-redeclare false positives for type definitions no-redeclare: false positives for type definitions Jun 11, 2018
mysticatea added a commit that referenced this issue Nov 8, 2018
mysticatea added a commit that referenced this issue Nov 13, 2018
* Update: add proper scope analysis (fixes #535)

* add computed-properties-in-type fixture

* add computed-properties-in-interface fixture

* add function-overload fixture

* add method-overload fixture

* add class-properties fixture

* add decorators fixture

* update visitor-keys

* add declare-global fixture

* fix typo

* add test for typeof in array destructuring

* add namespace fixture

* add declare-module fixture

* fix crash

* add declare-function.ts fixture

* add abstract-class fixture

* add typeof-in-call-signature fixture

* add test for #416

* add test for #435

* add test for #437

* add test for #443

* add test for #459

* add test for #466

* add test for #471

* add test for #487

* add test for #535

* add test for #536

* add test for #476

* fix test to use `expect()`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants