⬅️ Back to Table of Contents
📄 createParserServices.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
5 |
📦 Imports |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/typescript-estree/src/createParserServices.ts
📦 Imports
Name |
Source |
ASTMaps |
./convert |
ParserServices |
./parser-options |
Functions
createParserServices(astMaps: ASTMaps, program: ts.Program | null): ParserServices
Code
export function createParserServices(
astMaps: ASTMaps,
program: ts.Program | null,
): ParserServices {
if (!program) {
return {
emitDecoratorMetadata: undefined,
experimentalDecorators: undefined,
isolatedDeclarations: undefined,
program,
// we always return the node maps because
// (a) they don't require type info and
// (b) they can be useful when using some of TS's internal non-type-aware AST utils
...astMaps,
};
}
const checker = program.getTypeChecker();
const compilerOptions = program.getCompilerOptions();
return {
program,
// not set in the config is the same as off
emitDecoratorMetadata: compilerOptions.emitDecoratorMetadata ?? false,
experimentalDecorators: compilerOptions.experimentalDecorators ?? false,
isolatedDeclarations: compilerOptions.isolatedDeclarations ?? false,
...astMaps,
getSymbolAtLocation: node =>
checker.getSymbolAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node)),
getTypeAtLocation: node =>
checker.getTypeAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node)),
};
}
- Parameters:
astMaps: ASTMaps
program: ts.Program | null
- Return Type:
ParserServices
- Calls:
program.getTypeChecker
program.getCompilerOptions
checker.getSymbolAtLocation
astMaps.esTreeNodeToTSNodeMap.get
checker.getTypeAtLocation
- Internal Comments:
// we always return the node maps because
// (a) they don't require type info and
// (b) they can be useful when using some of TS's internal non-type-aware AST utils
// not set in the config is the same as off (x2)
getSymbolAtLocation(node: TSESTree.Node): any
Code
node =>
checker.getSymbolAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node))
- Parameters:
node: TSESTree.Node
- Return Type:
any
- Calls:
checker.getSymbolAtLocation
getTypeAtLocation(node: TSESTree.Node): any
Code
node =>
checker.getTypeAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node))
- Parameters:
node: TSESTree.Node
- Return Type:
any
- Calls:
checker.getTypeAtLocation
getSymbolAtLocation(node: TSESTree.Node): any
Code
node =>
checker.getSymbolAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node))
- Parameters:
node: TSESTree.Node
- Return Type:
any
- Calls:
checker.getSymbolAtLocation
getTypeAtLocation(node: TSESTree.Node): any
Code
node =>
checker.getTypeAtLocation(astMaps.esTreeNodeToTSNodeMap.get(node))
- Parameters:
node: TSESTree.Node
- Return Type:
any
- Calls:
checker.getTypeAtLocation