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
Enable @typescript-eslint/no-redundant-type-constituents
rule
#15794
Enable @typescript-eslint/no-redundant-type-constituents
rule
#15794
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54905/ |
@@ -40,7 +41,7 @@ export default async function ({ | |||
|
|||
mapSections.push({ | |||
offset: { line: offset, column: 0 }, | |||
map: result.map || { | |||
map: (result.map as EncodedSourceMap) || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jridgewell Maybe you want to align them
|
||
// The absolute path of the file being compiled. | ||
filename: string | void; | ||
declare filename: string | void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehoogeveen-medweb My bad. I was meant for object
as I typed value
as an union of object
and a specific function:
value: object | ((api: API, options: Options, dirname: string) => unknown); |
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-constituents
rule. Please review that PR first.Summary of changes:
API
type 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
.