Skip to content

error TS6133 ... "is declared but its value is never read." #24249

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
dgofman-equinix opened this issue May 18, 2018 · 6 comments
Closed

error TS6133 ... "is declared but its value is never read." #24249

dgofman-equinix opened this issue May 18, 2018 · 6 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@dgofman-equinix
Copy link

I am using D3 and all callback functions should receiving 3 parameters.
"ValueFn<GElement, Datum, void>"

I defined my event listeners as

on("mouseover", (d: any, index: number, elems: SVGGElement[]): void => {
   d3.select(elems[index]);
}) 

When I compiling to JS file and running via LINT/JSHINT no errors, however by enabling in tsconfig.json
"noUnusedParameters": true

I am getting errors: "error TS6133: 'd' is declared but its value is never read."

"d" is first argument you cannot avoid it. So, why TS compiler so crazy and cannot recognize it?

@ghost ghost added the Question An issue which isn't directly actionable in code label May 18, 2018
@ghost
Copy link

ghost commented May 18, 2018

Prefix the unused parameter with an underscore, as in _d.

@dgofman-equinix
Copy link
Author

dgofman-equinix commented May 18, 2018

Why do we need that? It's kind of strange all my express functions will contains different parameters:

route.get("/foo1", (_req: Request, _res: Response, next: NextFunction) => {
   next();
}
route.get("/foo2", (_req: Request, res: Response, next: NextFunction) => {
   res.send("HELLO WORLD!");
   next();
}
route.get("/foo3", (req: Request, res: Response, next: NextFunction) => {
   res.send(req.params.helloworld);
   next();
}

@MartinJohns
Copy link
Contributor

MartinJohns commented May 19, 2018

@dgofman-equinix You enable a feature that will error on unused parameters, then complain that it errors about unused parameters? If you don't like this feature, then don't enable it. The _-prefix is a way to opt-out of this feature by being explicitly saying "I'm aware this is not used, ignore it".

@RyanCavanaugh
Copy link
Member

It's --noUnusedParameters, not --noUnusedNonleadingParameters. Lots of options available to you and it's not a bug that we literally do the thing the flag is called.

@RyanCavanaugh
Copy link
Member

Prior discussion at #9458

@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
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants