⬅️ Back to Table of Contents
📄 parser-types.ts
📊 Analysis Summary
Metric |
Count |
📐 Interfaces |
5 |
📑 Type Aliases |
2 |
🎯 Enums |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/ast-spec/tests/util/parsers/parser-types.ts
Interfaces
SuccessSnapshotPaths
Interface Code
interface SuccessSnapshotPaths {
readonly ast: SnapshotPathFn;
readonly tokens: SnapshotPathFn;
}
Properties
Name |
Type |
Optional |
Description |
ast |
SnapshotPathFn |
✗ |
|
tokens |
SnapshotPathFn |
✗ |
|
ASTFixtureConfig
Interface Code
export interface ASTFixtureConfig {
/**
* Prevents the parser from throwing an error if it receives an invalid AST from TypeScript.
* This case only usually occurs when attempting to lint invalid code.
*/
readonly allowInvalidAST?: boolean;
/**
* Specifies that we expect that babel doesn't yet support the code in this fixture, so we expect that it will error.
* This should not be used if we expect babel to throw for this feature due to a valid parser error!
*
* The value should be a description of why there isn't support - for example a github issue URL.
*/
readonly expectBabelToNotSupport?: string;
}
Properties
Name |
Type |
Optional |
Description |
allowInvalidAST |
boolean |
✓ |
|
expectBabelToNotSupport |
string |
✓ |
|
Fixture
Interface Code
export interface Fixture {
readonly absolute: string;
readonly babelParsed: ParserResponse;
readonly config: ASTFixtureConfig;
readonly contents: string;
readonly errorLabel: ErrorLabel;
readonly ext: string;
readonly isBabelError: boolean;
readonly isError: boolean;
readonly isJSX: boolean;
readonly isTSESTreeError: boolean;
readonly name: string;
readonly relative: string;
readonly segments: string[];
readonly TSESTreeParsed: ParserResponse;
readonly snapshotFiles: {
readonly error: {
readonly alignment: SnapshotPathFn;
readonly babel: SnapshotPathFn;
readonly tsestree: SnapshotPathFn;
};
readonly success: {
readonly alignment: SuccessSnapshotPaths;
readonly babel: SuccessSnapshotPaths;
readonly tsestree: SuccessSnapshotPaths;
};
};
readonly snapshotPath: string;
readonly vitestSnapshotHeader: string;
}
Properties
Name |
Type |
Optional |
Description |
absolute |
string |
✗ |
|
babelParsed |
ParserResponse |
✗ |
|
config |
ASTFixtureConfig |
✗ |
|
contents |
string |
✗ |
|
errorLabel |
ErrorLabel |
✗ |
|
ext |
string |
✗ |
|
isBabelError |
boolean |
✗ |
|
isError |
boolean |
✗ |
|
isJSX |
boolean |
✗ |
|
isTSESTreeError |
boolean |
✗ |
|
name |
string |
✗ |
|
relative |
string |
✗ |
|
segments |
string[] |
✗ |
|
TSESTreeParsed |
ParserResponse |
✗ |
|
snapshotFiles |
`{ |
|
|
readonly error: { |
|
|
|
readonly alignment: SnapshotPathFn; |
|
|
|
readonly babel: SnapshotPathFn; |
|
|
|
readonly tsestree: SnapshotPathFn; |
|
|
|
}; |
|
|
|
readonly success: { |
|
|
|
readonly alignment: SuccessSnapshotPaths; |
|
|
|
readonly babel: SuccessSnapshotPaths; |
|
|
|
readonly tsestree: SuccessSnapshotPaths; |
|
|
|
}; |
|
|
|
}` |
✗ |
|
|
snapshotPath |
string |
✗ |
|
vitestSnapshotHeader |
string |
✗ |
|
ParserResponseSuccess
Interface Code
export interface ParserResponseSuccess {
readonly ast: unknown;
// this exists for the error alignment test snapshots
readonly error: 'NO ERROR';
readonly tokens: unknown;
readonly type: ParserResponseType.NoError;
}
Properties
Name |
Type |
Optional |
Description |
ast |
unknown |
✗ |
|
error |
'NO ERROR' |
✗ |
|
tokens |
unknown |
✗ |
|
type |
ParserResponseType.NoError |
✗ |
|
ParserResponseError
Interface Code
export interface ParserResponseError {
readonly error: unknown;
readonly type: ParserResponseType.Error;
}
Properties
Name |
Type |
Optional |
Description |
error |
unknown |
✗ |
|
type |
ParserResponseType.Error |
✗ |
|
Type Aliases
SnapshotPathFn
type SnapshotPathFn = (i: number) => string;
ParserResponse
type ParserResponse = ParserResponseError | ParserResponseSuccess;
Enums
enum ErrorLabel
Enum Code
export enum ErrorLabel {
Babel = "Babel errored but TSESTree didn't",
Both = 'Both errored',
None = 'No errors',
TSESTree = "TSESTree errored but Babel didn't",
}
Members
Name |
Value |
Description |
Babel |
Babel errored but TSESTree didn't |
|
Both |
Both errored |
|
None |
No errors |
|
TSESTree |
TSESTree errored but Babel didn't |
|
enum ParserResponseType
Enum Code
export enum ParserResponseType {
Error = 'Error',
NoError = 'NoError',
}
Members
Name |
Value |
Description |
Error |
Error |
|
NoError |
NoError |
|