Open zuhairtaha opened 1 year ago
Can you expand on why you think the value should be there? The value of the enum field in the externs should never matter to Closure Compiler - the compiler doesn't do anything with it.
I'm converting chrome types to closure compiler externs using tsickle.
There are some enums like chrome.declarativeNetRequest.RuleActionType.BLOCK
which should be a string, but the issue is I'm getting empty string at the compiled code
But what piece of the toolchain would be using that string? Closure Compiler doesn't, and by definition the externs are not present at runtime.
Here is an use case
After generating externs for chrome types the RuleActionType
enum will be
/** @enum {string} */
chrome.declarativeNetRequest.RuleActionType = {
BLOCK: '',
REDIRECT: '',
ALLOW: '',
UPGRADE_SCHEME: '',
MODIFY_HEADERS: '',
ALLOW_ALL_REQUESTS: '',
};
Then I run closure compiler to compile this javascript code
void chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.MODIFY_HEADERS,
responseHeaders: [
{
header: "Access-Control-Allow-Origin",
operation: chrome.declarativeNetRequest.HeaderOperation.SET,
value: "*"
}
]
},
condition: {
urlFilter: "<all_urls>",
resourceTypes: [chrome.declarativeNetRequest.ResourceType.MAIN_FRAME]
}
}
],
removeRuleIds: [1]
});
The issue is that closure compiler will replace chrome.declarativeNetRequest.RuleActionType.MODIFY_HEADERS
with an empty string
You need to make sure closure compiler understands that the externs file is in fact an externs file, either by putting @.***" on top of it or by explicitly passing it as an externs file on the command line.
Closure Compiler should then leave references to these external symbols as they were in the original source.
Message ID: @.***>
If we have this enum
The generated extern is
It should be