-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
refactor: Split analyzer/types/mod.rs
#1091
Conversation
|
Thank you for the PR! Files to checkThese are files which is affected by the current PR, but not reflected. If there's no file below this message, please ignore this message. You can run
|
use super::NormalizeTypeOpts; | ||
use crate::{analyzer::Analyzer, VResult}; | ||
|
||
macro_rules! never { |
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.
first, extract never macro
} | ||
|
||
#[inline] | ||
fn enum_variant(span: Span, def: ArcCow<Enum>, name: JsWord) -> Type { |
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.
second, extract feature what generate EnumVariant type
} | ||
for elem in normalized_types.iter() { | ||
if let Type::EnumVariant(ref ev) = elem.normalize() { | ||
match &ev.name { |
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.
3rd, change if let
to match
expression
self.flat_intersection_type(span, normalized_types) | ||
} | ||
|
||
fn flat_intersection_type(&mut self, span: Span, mut normalized_types: Vec<Type>) -> VResult<Option<Type>> { |
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.
4th, I split function what flatten intersection type
if let TypeElement::Property(prev) = prev { | ||
if prev.key.type_eq(&p.key) { | ||
let prev_type = prev.type_ann.clone().map(|v| *v).unwrap_or(Type::any(span, Default::default())); | ||
let other = p.type_ann.clone().map(|v| *v).unwrap_or(Type::any(span, Default::default())); |
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.
6th, change method unwrap_or_else
to unwrap_or
let prev_type = prev
.type_ann
.clone()
.map(|v| *v)
.unwrap_or_else(|| Type::any(span,KeywordTypeMetadata { ..Default::default() }));
to
this
analyzer/types/mod.rs
analyzer/types/mod.rs
analyzer/types/mod.rs
analyzer/types/mod.rs
Description:
Separate file about normalize intersection type
and
some code edit
I will show changeset at code review
BREAKING CHANGE:
Related issue (if exists):