-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginhas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Repro
const names = ['a', 'b'];
const record = names.reduce(
(accum, name) => ({
...accum,
[name]: true,
}),
{} as Record<string, boolean>
);
Expected Result
Typo! It should be Ah, this does fire a TS error, thanks - updated the sample.Record<string, boolean>
, but because we're using a cast, it's missed.
Also, u Using a cast is unnecessary because Array#reduce
can take in a type parameter indicating the default value & return type. The above code would be better written as:
const names = ['a', 'b'];
const record = names.reduce<Record<string, boolean>>(
(accum, name) => ({
...accum,
[name]: true,
}),
{}
);
Actual Result
No error.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
2.7.0 |
@typescript-eslint/parser |
2.7.0 |
TypeScript |
3.7.3 |
ESLint |
5.15.1 |
node |
12.4.0 |
npm |
6.9.0 |
sindresorhus
Metadata
Metadata
Assignees
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginhas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin