first
This commit is contained in:
2474
node_modules/@babel/parser/lib/plugins/flow/index.js
generated
vendored
Normal file
2474
node_modules/@babel/parser/lib/plugins/flow/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@babel/parser/lib/plugins/flow/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/parser/lib/plugins/flow/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
node_modules/@babel/parser/lib/plugins/flow/scope.js
generated
vendored
Normal file
44
node_modules/@babel/parser/lib/plugins/flow/scope.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _scope = require("../../util/scope");
|
||||
var _scopeflags = require("../../util/scopeflags");
|
||||
class FlowScope extends _scope.Scope {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this.declareFunctions = new Set();
|
||||
}
|
||||
}
|
||||
class FlowScopeHandler extends _scope.default {
|
||||
createScope(flags) {
|
||||
return new FlowScope(flags);
|
||||
}
|
||||
declareName(name, bindingType, loc) {
|
||||
const scope = this.currentScope();
|
||||
if (bindingType & _scopeflags.BindingFlag.FLAG_FLOW_DECLARE_FN) {
|
||||
this.checkRedeclarationInScope(scope, name, bindingType, loc);
|
||||
this.maybeExportDefined(scope, name);
|
||||
scope.declareFunctions.add(name);
|
||||
return;
|
||||
}
|
||||
super.declareName(name, bindingType, loc);
|
||||
}
|
||||
isRedeclaredInScope(scope, name, bindingType) {
|
||||
if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
|
||||
if (bindingType & _scopeflags.BindingFlag.FLAG_FLOW_DECLARE_FN) {
|
||||
return !scope.declareFunctions.has(name) && (scope.lexical.has(name) || scope.functions.has(name));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
checkLocalExport(id) {
|
||||
if (!this.scopeStack[0].declareFunctions.has(id.name)) {
|
||||
super.checkLocalExport(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = FlowScopeHandler;
|
||||
|
||||
//# sourceMappingURL=scope.js.map
|
1
node_modules/@babel/parser/lib/plugins/flow/scope.js.map
generated
vendored
Normal file
1
node_modules/@babel/parser/lib/plugins/flow/scope.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"names":["_scope","require","_scopeflags","FlowScope","Scope","constructor","args","declareFunctions","Set","FlowScopeHandler","ScopeHandler","createScope","flags","declareName","name","bindingType","loc","scope","currentScope","BindingFlag","FLAG_FLOW_DECLARE_FN","checkRedeclarationInScope","maybeExportDefined","add","isRedeclaredInScope","has","lexical","functions","checkLocalExport","id","scopeStack","exports","default"],"sources":["../../../src/plugins/flow/scope.ts"],"sourcesContent":["import type { Position } from \"../../util/location\";\nimport ScopeHandler, { Scope } from \"../../util/scope\";\nimport {\n BindingFlag,\n type ScopeFlag,\n type BindingTypes,\n} from \"../../util/scopeflags\";\nimport type * as N from \"../../types\";\n\n// Reference implementation: https://github.com/facebook/flow/blob/23aeb2a2ef6eb4241ce178fde5d8f17c5f747fb5/src/typing/env.ml#L536-L584\nclass FlowScope extends Scope {\n // declare function foo(): type;\n declareFunctions: Set<string> = new Set();\n}\n\nexport default class FlowScopeHandler extends ScopeHandler<FlowScope> {\n createScope(flags: ScopeFlag): FlowScope {\n return new FlowScope(flags);\n }\n\n declareName(name: string, bindingType: BindingTypes, loc: Position) {\n const scope = this.currentScope();\n if (bindingType & BindingFlag.FLAG_FLOW_DECLARE_FN) {\n this.checkRedeclarationInScope(scope, name, bindingType, loc);\n this.maybeExportDefined(scope, name);\n scope.declareFunctions.add(name);\n return;\n }\n\n super.declareName(name, bindingType, loc);\n }\n\n isRedeclaredInScope(\n scope: FlowScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (super.isRedeclaredInScope(scope, name, bindingType)) return true;\n\n if (bindingType & BindingFlag.FLAG_FLOW_DECLARE_FN) {\n return (\n !scope.declareFunctions.has(name) &&\n (scope.lexical.has(name) || scope.functions.has(name))\n );\n }\n\n return false;\n }\n\n checkLocalExport(id: N.Identifier) {\n if (!this.scopeStack[0].declareFunctions.has(id.name)) {\n super.checkLocalExport(id);\n }\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAQA,MAAME,SAAS,SAASC,YAAK,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,KAE5BC,gBAAgB,GAAgB,IAAIC,GAAG,CAAC,CAAC;EAAA;AAC3C;AAEe,MAAMC,gBAAgB,SAASC,cAAY,CAAY;EACpEC,WAAWA,CAACC,KAAgB,EAAa;IACvC,OAAO,IAAIT,SAAS,CAACS,KAAK,CAAC;EAC7B;EAEAC,WAAWA,CAACC,IAAY,EAAEC,WAAyB,EAAEC,GAAa,EAAE;IAClE,MAAMC,KAAK,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;IACjC,IAAIH,WAAW,GAAGI,uBAAW,CAACC,oBAAoB,EAAE;MAClD,IAAI,CAACC,yBAAyB,CAACJ,KAAK,EAAEH,IAAI,EAAEC,WAAW,EAAEC,GAAG,CAAC;MAC7D,IAAI,CAACM,kBAAkB,CAACL,KAAK,EAAEH,IAAI,CAAC;MACpCG,KAAK,CAACV,gBAAgB,CAACgB,GAAG,CAACT,IAAI,CAAC;MAChC;IACF;IAEA,KAAK,CAACD,WAAW,CAACC,IAAI,EAAEC,WAAW,EAAEC,GAAG,CAAC;EAC3C;EAEAQ,mBAAmBA,CACjBP,KAAgB,EAChBH,IAAY,EACZC,WAAyB,EAChB;IACT,IAAI,KAAK,CAACS,mBAAmB,CAACP,KAAK,EAAEH,IAAI,EAAEC,WAAW,CAAC,EAAE,OAAO,IAAI;IAEpE,IAAIA,WAAW,GAAGI,uBAAW,CAACC,oBAAoB,EAAE;MAClD,OACE,CAACH,KAAK,CAACV,gBAAgB,CAACkB,GAAG,CAACX,IAAI,CAA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