|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _types = require('../parser/tokenizer/types');
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | /**
|
|---|
| 6 | * Common method sharing code between CJS and ESM cases, since they're the same here.
|
|---|
| 7 | */
|
|---|
| 8 | function shouldElideDefaultExport(
|
|---|
| 9 | isTypeScriptTransformEnabled,
|
|---|
| 10 | keepUnusedImports,
|
|---|
| 11 | tokens,
|
|---|
| 12 | declarationInfo,
|
|---|
| 13 | ) {
|
|---|
| 14 | if (!isTypeScriptTransformEnabled || keepUnusedImports) {
|
|---|
| 15 | return false;
|
|---|
| 16 | }
|
|---|
| 17 | const exportToken = tokens.currentToken();
|
|---|
| 18 | if (exportToken.rhsEndIndex == null) {
|
|---|
| 19 | throw new Error("Expected non-null rhsEndIndex on export token.");
|
|---|
| 20 | }
|
|---|
| 21 | // The export must be of the form `export default a` or `export default a;`.
|
|---|
| 22 | const numTokens = exportToken.rhsEndIndex - tokens.currentIndex();
|
|---|
| 23 | if (
|
|---|
| 24 | numTokens !== 3 &&
|
|---|
| 25 | !(numTokens === 4 && tokens.matches1AtIndex(exportToken.rhsEndIndex - 1, _types.TokenType.semi))
|
|---|
| 26 | ) {
|
|---|
| 27 | return false;
|
|---|
| 28 | }
|
|---|
| 29 | const identifierToken = tokens.tokenAtRelativeIndex(2);
|
|---|
| 30 | if (identifierToken.type !== _types.TokenType.name) {
|
|---|
| 31 | return false;
|
|---|
| 32 | }
|
|---|
| 33 | const exportedName = tokens.identifierNameForToken(identifierToken);
|
|---|
| 34 | return (
|
|---|
| 35 | declarationInfo.typeDeclarations.has(exportedName) &&
|
|---|
| 36 | !declarationInfo.valueDeclarations.has(exportedName)
|
|---|
| 37 | );
|
|---|
| 38 | } exports.default = shouldElideDefaultExport;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.