Enable @typescript-eslint/no-redundant-type-constituents rule#15794
Enable @typescript-eslint/no-redundant-type-constituents rule#15794nicolo-ribaudo merged 5 commits intobabel:mainfrom
@typescript-eslint/no-redundant-type-constituents rule#15794Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54905/ |
| mapSections.push({ | ||
| offset: { line: offset, column: 0 }, | ||
| map: result.map || { | ||
| map: (result.map as EncodedSourceMap) || { |
There was a problem hiding this comment.
This cast is unfortunate because the EncodedSourceMap in trace-mapping
export interface SourceMapV3 {
file?: string | null;
names: string[];
sourceRoot?: string;
sources: (string | null)[];
sourcesContent?: (string | null)[];
version: 3;
}
export interface EncodedSourceMap extends SourceMapV3 {
mappings: string;
}is slightly different to the one in gen-mapping.
export interface SourceMapV3 {
file?: string | null;
names: readonly string[];
sourceRoot?: string;
sources: readonly (string | null)[];
sourcesContent?: readonly (string | null)[];
version: 3;
}
export interface EncodedSourceMap extends SourceMapV3 {
mappings: string;
}|
|
||
| // The absolute path of the file being compiled. | ||
| filename: string | void; | ||
| declare filename: string | void; |
There was a problem hiding this comment.
We shouldn't use declare here, since the constructor then sets these property (and we do not want to walk the prototype checking if they are already there)
There was a problem hiding this comment.
I mark them as declare because currently class properties are transpiled to initialization assignments in constructor as we are targeting Node.js 6: https://unpkg.com/@babel/core@7.22.9/lib/transformation/plugin-pass.js, this change will get rid of such extra assignments.
But since we will ship native class properties in Babel 8, I am happy to revert that.
| if (typeof value === "function") { | ||
| const factory = maybeAsync( | ||
| value, | ||
| value as (api: API, options: {}, dirname: string) => unknown, |
There was a problem hiding this comment.
I wish I could get rid of the typing cast here, the typeof check here can not rule out {} completely as it could be Function object.
Suggestions are welcome.
There was a problem hiding this comment.
@ehoogeveen-medweb My bad. I was meant for object as I typed value as an union of object and a specific function:
but for some reason the typeof check does not rule out the object completely.
|
IIRC See also this comment about why |
0e20ec5 to
1487600
Compare
This PR is based on #15793, which also fixes some errors reported by theno-redundant-type-constituentsrule. Please review that PR first.Summary of changes:
APItype parameter to theUnloadedDescriptor. It also makes it easier to track preset descriptor vs. plugin descriptor, which ensures that we are not passing incorrect API set to the descriptor.any.