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

variable is declared but never used with --noUnusedLocals and spread (React) #15802

Closed
iffy opened this issue May 12, 2017 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@iffy
Copy link

iffy commented May 12, 2017

TypeScript Version: 2.3.1

Code

// hello.tsx
import * as React from 'react';
export class SelectInput extends React.Component<any,any> {
  render() {
    let cls = 'hello';
    return (<select {...this.props} className={cls}>{this.props.children}</select>);
  }
}

package.json:

{
  "dependencies": {
    "@types/react": "^15.0.24",
    "react": "^15.5.4",
    "typescript": "2.3.1"
  }
}

Expected behavior:

I expect the compiler to think that cls was used.

Actual behavior:

The compiler emits this error:

$ tsc --jsx react --noUnusedLocals hello.tsx 
hello.tsx(5,9): error TS6133: 'cls' is declared but never used.
@iffy
Copy link
Author

iffy commented May 12, 2017

@mhegazy
Copy link
Contributor

mhegazy commented May 12, 2017

Duplicate of #15478, should be fixed in TS 2.3.3.

The fix should be in typescript@next already, give it a try and let us know if you are still running into issues.

@mhegazy mhegazy added the Duplicate An existing issue was already created label May 12, 2017
@mhegazy mhegazy closed this as completed May 12, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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