remove useless globals

pull/7786/head
Yuichiro Yamashita 4 years ago
parent 3878915d1d
commit 29080a0704

@ -16,14 +16,17 @@ const SPECIALS = ['global', 'globalThis', 'InternalError', 'process', 'undefined
const get_url = (name) => `https://raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.${name}.d.ts`;
const extract_name = (split) => split.match(/^[a-zA-Z0-9_$]+/)[0];
const extract_functions_and_references = (data) => {
const extract_functions_and_references = (name, data) => {
const functions = [];
const references = [];
data.split('\n').forEach(line => {
const trimmed = line.trim();
const split = trimmed.replace(/[\s+]/, ' ').split(' ');
if (split[0] === 'declare') functions.push(extract_name(split[2]));
else if (trimmed.startsWith('/// <reference')) {
if (split[0] === 'declare') {
// MEMO: ignore `declare type xxx` statement in lib.es5.d.ts.
// Because all of these are TypeScript types. (not exists in runtime.)
if (name !== 'es5' || split[1] !== 'type') functions.push(extract_name(split[2]));
} else if (trimmed.startsWith('/// <reference')) {
const matched = trimmed.match(/ lib="(.+)"/);
const reference = matched && matched[1];
if (reference) references.push(reference);
@ -50,7 +53,7 @@ const get_functions = async (name) => {
if (fetched_names.has(name)) return res;
fetched_names.add(name);
const body = await do_get(get_url(name));
const { functions, references } = extract_functions_and_references(body);
const { functions, references } = extract_functions_and_references(name, body);
res.push(...functions);
const chile_functions = await Promise.all(references.map(get_functions));
chile_functions.forEach(i => res.push(...i));

@ -1,6 +1,6 @@
/** ----------------------------------------------------------------------
This file is automatically generated by `scripts/globals-extractor.mjs`.
Generated At: 2022-08-14T15:28:31.556Z
Generated At: 2022-08-14T16:40:42.472Z
---------------------------------------------------------------------- */
export default new Set([
@ -75,7 +75,6 @@ export default new Set([
'ChannelMergerNode',
'ChannelSplitterNode',
'CharacterData',
'ClassDecorator',
'ClientRect',
'Clipboard',
'ClipboardEvent',
@ -294,7 +293,6 @@ export default new Set([
'MessageChannel',
'MessageEvent',
'MessagePort',
'MethodDecorator',
'MimeType',
'MimeTypeArray',
'MouseEvent',
@ -319,7 +317,6 @@ export default new Set([
'OverconstrainedError',
'PageTransitionEvent',
'PannerNode',
'ParameterDecorator',
'Path2D',
'PaymentAddress',
'PaymentMethodChangeEvent',
@ -350,10 +347,7 @@ export default new Set([
'ProcessingInstruction',
'ProgressEvent',
'Promise',
'PromiseConstructorLike',
'PromiseRejectionEvent',
'PropertyDecorator',
'PropertyKey',
'Proxy',
'PublicKeyCredential',
'PushManager',

Loading…
Cancel
Save