You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want a keyword undeclare on declared interface/class methods and var which works where it's referenced. It will benefit developers who wants stricter constraints.
Syntactic
It should be like these:
undeclarevarSymbol;// never needs Symbol// a chrome extension restricted by CSP will wants setTimeout only to accept valid functionsundeclarefunctionsetTimeout(handler: any,timeout?: any, ...args: any[]): number;// accept extra args which is not declared in `lib.dom.d.ts`declarefunctionsetTimeout(handler: (...args: any[])=>void,timeout: number, ...args: any[]): number;
And the declaration after undeclare should be strictly matched:
if a var/class/namespace/interface is undeclare-ed, then only remove one record with the given type
if a (member) function is undeclared, types of args and its returned value should be strictly matched.
Motivation
Many EcmaScript functions are generic for backward compatibility and usability, but developers may have their own programming standard, and only want limited usages. For example:
a CSP of script-src: 'self' limits setTimeout and refuses eval.
some APIs are deprecated and replaced by new ones.
a Chrome extension knows that it will has a complete chrome.tabs.Tab and tab.title is not string | undefined but string.
In my tests, I'm able to override definitions of member variables, so there has been a work-around for cases like tab.title (edit: it reported "All declarations of 'title' must have identical modifiers"), but I can not find any way to remove function definitions.
The text was updated successfully, but these errors were encountered:
Global declarations are all originating from declaration files. The library file (lib.*.d.ts) are overridable. use --noLib and specify your declaration file that does not define Symbol, setTimeout or any other APIs deemed unsafe, and pass that to the compiler instead.
The ability is important for me to remove built-in function declarations, which is a little different from #4183.
I need to operate with many DOM APIs so lib.dom.d.ts is needed, but setTimeout is there, too. Must I copy the whole lib.dom.d.ts and then modify just few lines?
I want a keyword
undeclare
on declaredinterface/class
methods andvar
which works where it's referenced. It will benefit developers who wants stricter constraints.Syntactic
It should be like these:
And the declaration after
undeclare
should be strictly matched:var
/class
/namespace
/interface
isundeclare
-ed, then only remove one record with the given typefunction
is undeclared, types of args and its returned value should be strictly matched.Motivation
Many EcmaScript functions are generic for backward compatibility and usability, but developers may have their own programming standard, and only want limited usages. For example:
script-src: 'self'
limitssetTimeout
and refuseseval
.deprecated
and replaced by new ones.chrome.tabs.Tab
andtab.title
is notstring | undefined
butstring
.In my tests,
I'm able to override definitions of member variables, so there has been a work-around for cases like(edit: it reported "All declarations of 'title' must have identical modifiers"), but I can not find any way to removetab.title
function
definitions.The text was updated successfully, but these errors were encountered: