MCPcopy Index your code
hub / github.com/nodejs/node / parseImportOrExportSpecifier

Function parseImportOrExportSpecifier

test/fixtures/snapshot/typescript.js:37216–37295  ·  view source on GitHub ↗
(kind)

Source from the content-addressed store, hash-verified

37214 return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */);
37215 }
37216 function parseImportOrExportSpecifier(kind) {
37217 var pos = getNodePos();
37218 // ImportSpecifier:
37219 // BindingIdentifier
37220 // IdentifierName as BindingIdentifier
37221 // ExportSpecifier:
37222 // IdentifierName
37223 // IdentifierName as IdentifierName
37224 var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
37225 var checkIdentifierStart = scanner.getTokenPos();
37226 var checkIdentifierEnd = scanner.getTextPos();
37227 var isTypeOnly = false;
37228 var propertyName;
37229 var canParseAsKeyword = true;
37230 var name = parseIdentifierName();
37231 if (name.escapedText === "type") {
37232 // If the first token of an import specifier is 'type', there are a lot of possibilities,
37233 // especially if we see 'as' afterwards:
37234 //
37235 // import { type } from "mod"; - isTypeOnly: false, name: type
37236 // import { type as } from "mod"; - isTypeOnly: true, name: as
37237 // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type
37238 // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as
37239 if (token() === 127 /* SyntaxKind.AsKeyword */) {
37240 // { type as ...? }
37241 var firstAs = parseIdentifierName();
37242 if (token() === 127 /* SyntaxKind.AsKeyword */) {
37243 // { type as as ...? }
37244 var secondAs = parseIdentifierName();
37245 if (ts.tokenIsIdentifierOrKeyword(token())) {
37246 // { type as as something }
37247 isTypeOnly = true;
37248 propertyName = firstAs;
37249 name = parseNameWithKeywordCheck();
37250 canParseAsKeyword = false;
37251 }
37252 else {
37253 // { type as as }
37254 propertyName = name;
37255 name = secondAs;
37256 canParseAsKeyword = false;
37257 }
37258 }
37259 else if (ts.tokenIsIdentifierOrKeyword(token())) {
37260 // { type as something }
37261 propertyName = name;
37262 canParseAsKeyword = false;
37263 name = parseNameWithKeywordCheck();
37264 }
37265 else {
37266 // { type as }
37267 isTypeOnly = true;
37268 name = firstAs;
37269 }
37270 }
37271 else if (ts.tokenIsIdentifierOrKeyword(token())) {
37272 // { type something ...? }
37273 isTypeOnly = true;

Callers 2

parseExportSpecifierFunction · 0.85
parseImportSpecifierFunction · 0.85

Calls 8

getNodePosFunction · 0.85
parseIdentifierNameFunction · 0.85
parseExpectedFunction · 0.85
parseErrorAtFunction · 0.85
finishNodeFunction · 0.85
tokenFunction · 0.70
isIdentifierFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…