Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/diff/ts_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct TsTypeDiff {

impl TsTypeDiff {
pub fn diff(old: &TsTypeDef, new: &TsTypeDef) -> Option<Self> {
if old.repr == new.repr {
if old == new {
return None;
}

Expand Down Expand Up @@ -58,17 +58,9 @@ pub struct TsTypeParamDiff {

impl TsTypeParamDiff {
pub fn diff(old: &TsTypeParamDef, new: &TsTypeParamDef) -> Option<Self> {
let constraint_changed = match (&old.constraint, &new.constraint) {
(Some(old_c), Some(new_c)) => old_c.repr != new_c.repr,
(None, None) => false,
_ => true,
};
let constraint_changed = old.constraint != new.constraint;

let default_changed = match (&old.default, &new.default) {
(Some(old_d), Some(new_d)) => old_d.repr != new_d.repr,
(None, None) => false,
_ => true,
};
let default_changed = old.default != new.default;

if !constraint_changed && !default_changed {
return None;
Expand Down
99 changes: 99 additions & 0 deletions tests/diff_specs/function_return_type_generic_change.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# old/mod.ts
export function doc(): Promise<Record<string, Array<DocNode>>> { return {} as any; }

# new/mod.ts
export function doc(): Promise<Record<string, Document>> { return {} as any; }

# output.json
{
"modifiedModules": {
"file:///mod.ts": {
"modified": [
{
"name": "doc",
"declarations": {
"modified": [
{
"kind": "function",
"defChanges": {
"type": "function",
"returnTypeChange": {
"old": {
"repr": "Promise",
"kind": "typeRef",
"value": {
"typeParams": [
{
"repr": "Record",
"kind": "typeRef",
"value": {
"typeParams": [
{
"repr": "string",
"kind": "keyword",
"value": "string"
},
{
"repr": "Array",
"kind": "typeRef",
"value": {
"typeParams": [
{
"repr": "DocNode",
"kind": "typeRef",
"value": {
"typeName": "DocNode"
}
}
],
"typeName": "Array"
}
}
],
"typeName": "Record"
}
}
],
"typeName": "Promise"
}
},
"new": {
"repr": "Promise",
"kind": "typeRef",
"value": {
"typeParams": [
{
"repr": "Record",
"kind": "typeRef",
"value": {
"typeParams": [
{
"repr": "string",
"kind": "keyword",
"value": "string"
},
{
"repr": "Document",
"kind": "typeRef",
"value": {
"typeName": "Document"
}
}
],
"typeName": "Record"
}
}
],
"typeName": "Promise"
}
}
}
}
}
]
}
}
]
}
}
}
Loading