Skip to content

Add no-op function to runtime checks code generation #430

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

Merged
merged 2 commits into from
Apr 14, 2023
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
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ const functionMap = {
console.log('debugger', ...args)
// eslint-disable-next-line no-debugger
debugger
}
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
noop: () => { }
}

/**
Expand Down
12 changes: 12 additions & 0 deletions unit-test/script-overload-snapshots/config/3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
"fn": {
"type": "function",
"functionName": "debug"
},
"noop": {
"type": "function",
"functionName": "noop"
},
"navigator.noop": {
"type": "function",
"functionName": "noop"
},
"nonexistent": {
"type": "function",
"functionName": "nonexistent"
}
}
18 changes: 16 additions & 2 deletions unit-test/script-overload-snapshots/out/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,25 @@
// eslint-disable-next-line no-debugger
debugger
};
let _ddg_s = () => { };
let _ddg_b = parentScope?.navigator ? parentScope.navigator : Object.bind(null);
let _ddg_t = () => { };
let _ddg_a = constructProxy(_ddg_b, {
noop: _ddg_t
});
let navigator = _ddg_a;
let _ddg_u = undefined;
const window = constructProxy(parentScope, {
fn: _ddg_r
fn: _ddg_r,
noop: _ddg_s,
navigator: _ddg_a,
nonexistent: _ddg_u
});
const globalThis = constructProxy(parentScope, {
fn: _ddg_r
fn: _ddg_r,
noop: _ddg_s,
navigator: _ddg_a,
nonexistent: _ddg_u
});
console.log(1)
})(globalThis)