(
node: Undone<N.ImportDeclaration | N.TSImportEqualsDeclaration>,
isExport: boolean,
)
| 2993 | * in the TS and Flow plugins, and for parsing `import defer`. |
| 2994 | */ |
| 2995 | parseMaybeImportPhase( |
| 2996 | node: Undone<N.ImportDeclaration | N.TSImportEqualsDeclaration>, |
| 2997 | isExport: boolean, |
| 2998 | ): N.Identifier | null { |
| 2999 | if (!this.isPotentialImportPhase(isExport)) { |
| 3000 | this.applyImportPhase( |
| 3001 | node as Undone<N.ImportDeclaration>, |
| 3002 | isExport, |
| 3003 | null, |
| 3004 | ); |
| 3005 | return null; |
| 3006 | } |
| 3007 | |
| 3008 | const phaseIdentifier = this.startNode<N.Identifier>(); |
| 3009 | const phaseIdentifierName = this.parseIdentifierName(true); |
| 3010 | |
| 3011 | const { type } = this.state; |
| 3012 | const isImportPhase = tokenIsKeywordOrIdentifier(type) |
| 3013 | ? // OK: import <phase> x from "foo"; |
| 3014 | // OK: import <phase> from from "foo"; |
| 3015 | // NO: import <phase> from "foo"; |
| 3016 | // NO: import <phase> from 'foo'; |
| 3017 | // With the module declarations proposals, we will need further disambiguation |
| 3018 | // for `import module from from;`. |
| 3019 | type !== tt._from || this.lookaheadCharCode() === charCodes.lowercaseF |
| 3020 | : // OK: import <phase> { x } from "foo"; |
| 3021 | // OK: import <phase> x from "foo"; |
| 3022 | // OK: import <phase> * as T from "foo"; |
| 3023 | // NO: import <phase> from "foo"; |
| 3024 | // OK: import <phase> "foo"; |
| 3025 | // The last one is invalid, we will continue parsing and throw |
| 3026 | // an error later |
| 3027 | type !== tt.comma; |
| 3028 | |
| 3029 | if (isImportPhase) { |
| 3030 | this.applyImportPhase( |
| 3031 | node as Undone<N.ImportDeclaration>, |
| 3032 | isExport, |
| 3033 | phaseIdentifierName, |
| 3034 | phaseIdentifier.start!, |
| 3035 | ); |
| 3036 | return null; |
| 3037 | } else { |
| 3038 | this.applyImportPhase( |
| 3039 | node as Undone<N.ImportDeclaration>, |
| 3040 | isExport, |
| 3041 | null, |
| 3042 | ); |
| 3043 | // `<phase>` is a default binding, return it to the main import declaration parser |
| 3044 | return this.createIdentifier(phaseIdentifier, phaseIdentifierName); |
| 3045 | } |
| 3046 | } |
| 3047 | |
| 3048 | isPrecedingIdImportPhase( |
| 3049 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
nothing calls this directly
no test coverage detected