MCPcopy Create free account
hub / github.com/babel/babel / checkImportPhase

Function checkImportPhase

packages/babel-parser/src/parser/statement.ts:2919–2936  ·  view source on GitHub ↗
(node: Undone<N.ImportDeclaration>)

Source from the content-addressed store, hash-verified

2917 }
2918
2919 checkImportPhase(node: Undone<N.ImportDeclaration>) {
2920 if (node.phase == null) {
2921 return;
2922 }
2923 const { specifiers } = node;
2924 const singleBindingType =
2925 specifiers.length === 1 ? specifiers[0].type : null;
2926
2927 if (node.phase === "source") {
2928 if (singleBindingType !== "ImportDefaultSpecifier") {
2929 this.raise(Errors.SourcePhaseImportRequiresDefault, node);
2930 }
2931 } else if (node.phase === "defer") {
2932 if (singleBindingType !== "ImportNamespaceSpecifier") {
2933 this.raise(Errors.DeferImportRequiresNamespace, node);
2934 }
2935 }
2936 }
2937
2938 isPotentialImportPhase(isExport: boolean): boolean {
2939 if (isExport) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected