Remove ts4.3 typesVersions (#65664)

* Remove ts4.3 typesVersions

Only present in two packages: har-format and @babel/traverse.

* remove types field from package.json
This commit is contained in:
Nathan Shively-Sanders
2023-06-01 16:15:10 -07:00
committed by GitHub
parent 53cfd11f91
commit 5c28602b0d
10 changed files with 0 additions and 2996 deletions

View File

@@ -2,9 +2,5 @@
"private": true,
"dependencies": {
"@babel/types": "^7.20.7"
},
"types": "index",
"typesVersions": {
"<=4.3": { "*": ["ts4.3/*"] }
}
}

View File

@@ -1,466 +0,0 @@
import traverse, { Binding, Hub, NodePath, TraverseOptions, Visitor, visitors } from '@babel/traverse';
import * as t from '@babel/types';
// Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
const MyVisitor: Visitor = {
Identifier: {
enter(path) {
path.type; // $ExpectType "Identifier"
const x: NodePath<t.Identifier> = path;
console.log('Entered!');
},
exit(path) {
path.type; // $ExpectType "Identifier"
const x: NodePath<t.Identifier> = path;
console.log('Exited!');
},
},
};
const MyVisitor2: Visitor = {
Identifier(path) {
path.type; // $ExpectType "Identifier"
path.parentPath; // $ExpectType NodePath<Node>
console.log('Visiting: ' + path.node.name);
},
ArrayExpression(path) {
path.get('elements'); // $ExpectType NodePath<SpreadElement | Expression | null>[]
},
Program(path) {
path.parentPath; // $ExpectType null
},
};
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse
declare const ast: t.Node;
traverse(ast, {
enter(path) {
let actualType = path.type;
const expectedType: t.Node['type'] = actualType;
actualType = ast.type;
const node = path.node;
if (t.isIdentifier(node) && node.name === 'n') {
node.name = 'x';
}
},
});
// Examples from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#writing-your-first-babel-plugin
const v1: Visitor = {
BinaryExpression(path) {
path.type; // $ExpectType "BinaryExpression"
if (t.isIdentifier(path.node.left)) {
// ...
}
// $ExpectType [NodePath<BinaryExpression>]
path.replaceWith(t.binaryExpression('**', path.node.left, t.numericLiteral(2)));
path.parentPath.replaceWith(
t.expressionStatement(t.stringLiteral("Anyway the wind blows, doesn't really matter to me, to me.")),
);
// $ExpectType [NodePath<BinaryExpression>]
path.replaceInline(t.binaryExpression('**', path.node.left, t.numericLiteral(2)));
// $ExpectType [NodePath<Node>]
path.replaceWithSourceString('3 * 4') as [NodePath];
// $ExpectType [NodePath<BinaryExpression>, NodePath<ExpressionStatement>]
path.replaceInline([
t.binaryExpression('**', path.node.left, t.numericLiteral(2)),
t.expressionStatement(t.stringLiteral("Anyway the wind blows, doesn't really matter to me, to me.")),
] as const);
path.parentPath.remove();
},
Identifier(path) {
path.type; // $ExpectType "Identifier"
if (path.isReferencedIdentifier()) {
// ...
}
if (t.isQualifiedTypeIdentifier(path.node)) {
// ...
}
},
ReturnStatement(path) {
path.type; // $ExpectType "ReturnStatement"
// $ExpectType [NodePath<ExpressionStatement>, NodePath<ExpressionStatement>, NodePath<ExpressionStatement>]
path.replaceWithMultiple([
t.expressionStatement(t.stringLiteral('Is this the real life?')),
t.expressionStatement(t.stringLiteral('Is this just fantasy?')),
t.expressionStatement(t.stringLiteral('(Enjoy singing the rest of the song in your head)')),
] as const);
},
FunctionDeclaration(path, state) {
path.type; // $ExpectType "FunctionDeclaration"
path.replaceWithSourceString(`function add(a, b) {
return a + b;
}`);
// $ExpectType [NodePath<ExpressionStatement>]
path.get('body').unshiftContainer('body', t.expressionStatement(t.stringLiteral('Start of function')));
// $ExpectType [NodePath<ExpressionStatement>]
path.get('body').pushContainer('body', t.expressionStatement(t.stringLiteral('End of function')));
// $ExpectType [NodePath<ExpressionStatement>]
path.insertBefore(t.expressionStatement(t.stringLiteral("Because I'm easy come, easy go.")));
// $ExpectType [NodePath<ExpressionStatement>]
path.insertAfter(t.expressionStatement(t.stringLiteral('A little high, little low.')));
path.remove();
if (path.scope.hasBinding('n')) {
// ...
}
if (path.scope.hasOwnBinding('n')) {
// ...
}
const id1 = path.scope.generateUidIdentifier('uid');
id1.type;
id1.name;
const id2 = path.scope.generateUidIdentifier('uid');
id2.type;
id2.name;
const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id!);
path.remove();
path.scope.parent.push({ id });
path.scope.parent.push({ id, init: t.stringLiteral('foo'), kind: 'const' });
path.scope.rename('n', 'x');
path.scope.rename('n');
path.scope.crawl();
// @ts-expect-error
path.pushContainer('returnType', t.stringLiteral('hello'));
// @ts-expect-error
path.unshiftContainer('returnType', t.stringLiteral('hello'));
},
ExportDefaultDeclaration(path) {
path.type; // $ExpectType "ExportDefaultDeclaration"
{
const [stringPath, booleanPath] = path.replaceWithMultiple([
t.stringLiteral('hello'),
t.booleanLiteral(false),
]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
{
const [stringPath, booleanPath] = path.replaceWithMultiple<[t.StringLiteral, t.BooleanLiteral]>([
t.stringLiteral('hello'),
t.booleanLiteral(false),
]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
{
const [newPath] = path.insertBefore(t.stringLiteral('hello'));
// $ExpectType NodePath<StringLiteral>
newPath;
}
{
const [newPath] = path.insertAfter(t.stringLiteral('hello'));
// $ExpectType NodePath<StringLiteral>
newPath;
}
},
SequenceExpression(path) {
path.type; // $ExpectType "SequenceExpression"
{
const [newPath] = path.unshiftContainer('expressions', t.stringLiteral('hello'));
// $ExpectType NodePath<StringLiteral>
newPath;
}
{
const [newPath] = path.pushContainer('expressions', t.stringLiteral('hello'));
// $ExpectType NodePath<StringLiteral>
newPath;
}
{
const [stringPath, booleanPath] = path.unshiftContainer('expressions', [
t.stringLiteral('hello'),
t.booleanLiteral(false),
]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
{
const [stringPath, booleanPath] = path.pushContainer('expressions', [
t.stringLiteral('hello'),
t.booleanLiteral(false),
]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
{
const [stringPath, booleanPath] = path.unshiftContainer<
t.SequenceExpression,
'expressions',
[t.StringLiteral, t.BooleanLiteral]
>('expressions', [t.stringLiteral('hello'), t.booleanLiteral(false)]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
{
const [stringPath, booleanPath] = path.pushContainer<
t.SequenceExpression,
'expressions',
[t.StringLiteral, t.BooleanLiteral]
>('expressions', [t.stringLiteral('hello'), t.booleanLiteral(false)]);
// $ExpectType NodePath<StringLiteral>
stringPath;
// $ExpectType NodePath<BooleanLiteral>
booleanPath;
}
},
};
// Binding.kind
const BindingKindTest: Visitor = {
Identifier(path) {
path.type; // $ExpectType "Identifier"
const kind = path.scope.getBinding('str')!.kind;
kind === 'module';
kind === 'const';
kind === 'let';
kind === 'var';
// @ts-expect-error
kind === 'anythingElse';
},
};
interface SomeVisitorState {
someState: string;
}
const VisitorStateTest: TraverseOptions<SomeVisitorState> = {
enter(path, state) {
let actualType = path.type;
const expectedType: t.Node['type'] = actualType;
actualType = ast.type;
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
exit(path, state) {
let actualType = path.type;
const expectedType: t.Node['type'] = actualType;
actualType = ast.type;
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
Identifier(path, state) {
path.type; // $ExpectType "Identifier"
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
FunctionDeclaration: {
enter(path, state) {
path.type; // $ExpectType "FunctionDeclaration"
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
exit(path, state) {
path.type; // $ExpectType "FunctionDeclaration"
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
},
};
traverse(ast, VisitorStateTest, undefined, { someState: 'test' });
const VisitorAliasTest: Visitor = {
Function() {},
Expression() {},
};
const hub = new Hub();
// $ExpectType string | undefined
hub.getCode();
declare const astExpression: t.Expression;
traverse.visitors; // $ExpectType typeof visitors
// $ExpectType Visitor<unknown>
visitors.merge([
{
Expression(path) {
let actualType = path.type;
const expectedType: t.Expression['type'] = actualType;
actualType = astExpression.type;
},
},
{
Expression(path) {
let actualType = path.type;
const expectedType: t.Expression['type'] = actualType;
actualType = astExpression.type;
},
},
]);
function testNullishPath(
optionalPath: NodePath<t.Node | null>,
nullPath: NodePath<null>,
undefinedPath: NodePath<undefined>,
unknownPath: NodePath<unknown>,
) {
nullPath.type; // $ExpectType undefined
undefinedPath.type; // $ExpectType undefined
unknownPath.type; // $ExpectAssignable t.Node['type'] | undefined
let actualType = optionalPath.type;
const expectedType: t.Node['type'] | undefined = actualType;
actualType = expectedType;
}
function testEnsureBlock(path: NodePath<t.ArrowFunctionExpression>) {
path.ensureBlock();
path.node.body; // $ExpectType BlockStatement
}
const optionsWithDenylist: TraverseOptions = {
denylist: ['TypeAnnotation'],
};
const optionsWithInvalidDenylist: TraverseOptions = {
// @ts-expect-error
denylist: ['SomeRandomType'],
};
const objectTypeAnnotation: NodePath<t.ObjectTypeAnnotation> = new NodePath<t.ObjectTypeAnnotation>(
null as any,
{} as any,
);
objectTypeAnnotation.get('indexers'); // $ExpectType NodePathResult<ObjectTypeIndexer[] | undefined>
// Test that NodePath can be narrowed from union to single type
const path: NodePath<t.ExportDefaultDeclaration | t.ExportNamedDeclaration> = new NodePath<t.ExportNamedDeclaration>(
null as any,
{} as any,
);
if (path.isExportNamedDeclaration()) {
path.type; // $ExpectType "ExportNamedDeclaration"
}
const nullPath: NodePath<t.Identifier | undefined> = new NodePath<t.Identifier | undefined>(null as any, {} as any);
nullPath.type; // $ExpectType "Identifier" | undefined
if (nullPath.hasNode()) {
nullPath.type; // $ExpectType "Identifier"
}
const file: t.File = {} as any;
const newPath = NodePath.get({
hub: {} as any,
parentPath: null,
parent: file,
container: file,
key: 'program',
}).setContext();
newPath; // $ExpectType NodePath<Program>
const program: t.Program = {} as any;
// $ExpectType NodePath<Statement>
NodePath.get({
hub: {} as any,
parentPath: null,
parent: program,
container: program,
listKey: 'body',
key: 0,
});
const binding = new Binding({
identifier: {} as any,
scope: {} as any,
path: {} as any,
kind: 'unknown',
});
binding.setValue('value');
binding.deopValue();
binding.clearValue();
binding.reassign(newPath.get('body')[0]);
binding.reference(newPath.get('body')[0]);
binding.dereference();
newPath.scope.checkBlockScopedCollisions(binding, 'local', 'name', {});
const booleanVar: boolean = true as boolean;
const identifier = newPath.getBindingIdentifiers();
identifier; // $ExpectType Record<string, Identifier>
const identifierFalse = newPath.getBindingIdentifiers(false);
identifierFalse; // $ExpectType Record<string, Identifier>
const identifierTrue = newPath.getBindingIdentifiers(true);
identifierTrue; // $ExpectType Record<string, Identifier[]>
const identifierBoolean = newPath.getBindingIdentifiers(booleanVar);
identifierBoolean; // $ExpectType Record<string, Identifier | Identifier[]>
const outerIdentifier = newPath.getOuterBindingIdentifiers();
outerIdentifier; // $ExpectType Record<string, Identifier>
const outerIdentifierFalse = newPath.getOuterBindingIdentifiers(false);
outerIdentifierFalse; // $ExpectType Record<string, Identifier>
const outerIdentifierTrue = newPath.getOuterBindingIdentifiers(true);
outerIdentifierTrue; // $ExpectType Record<string, Identifier[]>
const outerIdentifierBoolean = newPath.getOuterBindingIdentifiers(booleanVar);
outerIdentifierBoolean; // $ExpectType Record<string, Identifier | Identifier[]>
const identifierPath = newPath.getBindingIdentifierPaths();
identifierPath; // $ExpectType Record<string, NodePath<Identifier>>
const identifierPathFalse = newPath.getBindingIdentifierPaths(false);
identifierPathFalse; // $ExpectType Record<string, NodePath<Identifier>>
const identifierPathTrue = newPath.getBindingIdentifierPaths(true);
identifierPathTrue; // $ExpectType Record<string, NodePath<Identifier>[]>
const identifierPathBoolean = newPath.getBindingIdentifierPaths(booleanVar);
identifierPathBoolean; // $ExpectType Record<string, NodePath<Identifier> | NodePath<Identifier>[]>
const outerIdentifierPath = newPath.getOuterBindingIdentifierPaths();
outerIdentifierPath; // $ExpectType Record<string, NodePath<Identifier>>
const outerIdentifierPathFalse = newPath.getOuterBindingIdentifierPaths(false);
outerIdentifierPathFalse; // $ExpectType Record<string, NodePath<Identifier>>
const outerIdentifierPathTrue = newPath.getOuterBindingIdentifierPaths(true);
outerIdentifierPathTrue; // $ExpectType Record<string, NodePath<Identifier>[]>
const outerIdentifierPathBoolean = newPath.getOuterBindingIdentifierPaths(booleanVar);
outerIdentifierPathBoolean; // $ExpectType Record<string, NodePath<Identifier> | NodePath<Identifier>[]>

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@babel/*": [
"babel__*"
]
}
},
"files": [
"index.d.ts",
"babel__traverse-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -1,7 +0,0 @@
{
"private": true,
"types": "index",
"typesVersions": {
"<=4.3": { "*": ["ts4.3/*"] }
}
}

View File

@@ -1,853 +0,0 @@
/**
* HTTP Archive 1.2
*
* http://www.softwareishard.com/blog/har-12-spec
*/
export interface Har {
/** This object represents the root of exported data. */
log: Log;
}
/**
* This object (`log`) represents the root of exported data.
*
* http://www.softwareishard.com/blog/har-12-spec/#log
*/
export interface Log {
/**
* Version number of the format.
*
* _If empty, string "1.1" is assumed by default._
*/
version: string;
/** Name and version info of the log creator application. */
creator: Creator;
/** Name and version info of used browser. */
browser?: Browser | undefined;
/**
* List of all exported (tracked) pages.
*
* _Leave out this field if the application
* does not support grouping by pages._
*
* There is one `<page>` object for every exported web page and one
* `<entry>` object for every HTTP request.
* In case when an HTTP trace tool isn't able to group requests by a page,
* the `<pages>` object is empty and individual requests doesn't have a
* parent page.
*/
pages?: Page[] | undefined;
/** List of all exported (tracked) requests. */
entries: Entry[];
/** A comment provided by the user or the application. */
comment?: string | undefined;
}
/**
* Infos about application/browser used to export the log.
*
* `Creator` and `Browser` objects share the same structure.
*
* http://www.softwareishard.com/blog/har-12-spec/#creator
*/
export interface Creator {
/** Name of the application/browser used to export the log. */
name: string;
/** Version of the application/browser used to export the log. */
version: string;
/** A comment provided by the user or the application. */
comment?: string | undefined;
}
/**
* Infos about application/browser used to export the log.
*
* `Browser` and `Creator` objects share the same structure.
*
* http://www.softwareishard.com/blog/har-12-spec/#browser
*/
export interface Browser {
/** Name of the application/browser used to export the log. */
name: string;
/** Version of the application/browser used to export the log. */
version: string;
/** A comment provided by the user or the application. */
comment?: string | undefined;
}
/**
* This object represents list of exported pages.
*
* http://www.softwareishard.com/blog/har-12-spec/#pages
*/
export interface Page {
/**
* Date and time stamp for the beginning of the page load
*
* (ISO 8601 - `YYYY-MM-DDThh:mm:ss.sTZD`,
* e.g. `2009-07-24T19:20:30.45+01:00`).
*/
startedDateTime: string;
/**
* Unique identifier of a page within the `<log>` (HAR doc).
* Entries use it to refer the parent page.
*/
id: string;
/** Page title. */
title: string;
/** Detailed timing info about page load */
pageTimings: PageTiming;
/** A comment provided by the user or the application */
comment?: string | undefined;
/** _non-standard_ */
/** _non-standard_ */
_adult_site?: number | null | undefined;
/** _non-standard_ */
_aft?: number | null | undefined;
/** _non-standard_ */
_base_page_cdn?: string | null | undefined;
/** _non-standard_ */
_base_page_redirects?: number | null | undefined;
/** _non-standard_ */
_base_page_ttfb?: number | null | undefined;
/** _non-standard_ */
_browser_main_memory_kb?: number | null | undefined;
/** _non-standard_ */
_browser_name?: string | null | undefined;
/** _non-standard_ */
_browser_other_private_memory_kb?: number | null | undefined;
/** _non-standard_ */
_browser_process_count?: number | null | undefined;
/** _non-standard_ */
_browser_version?: string | null | undefined;
/** _non-standard_ */
_browser_working_set_kb?: number | null | undefined;
/** _non-standard_ */
_bytesIn?: number | null | undefined;
/** _non-standard_ */
_bytesInDoc?: number | null | undefined;
/** _non-standard_ */
_bytesOut?: number | null | undefined;
/** _non-standard_ */
_bytesOutDoc?: number | null | undefined;
/** _non-standard_ */
_cached?: number | null | undefined;
/** _non-standard_ */
_certificate_bytes?: number | null | undefined;
/** _non-standard_ */
_connections?: number | null | undefined;
/** _non-standard_ */
_date?: number | null | undefined;
/** _non-standard_ */
_docCPUms?: number | null | undefined;
/** _non-standard_ */
_docCPUpct?: number | null | undefined;
/** _non-standard_ */
_docTime?: number | null | undefined;
/** _non-standard_ */
_domContentLoadedEventEnd?: number | null | undefined;
/** _non-standard_ */
_domContentLoadedEventStart?: number | null | undefined;
/** _non-standard_ */
_domElements?: number | null | undefined;
/** _non-standard_ */
_domInteractive?: number | null | undefined;
/** _non-standard_ */
_domLoading?: number | null | undefined;
/** _non-standard_ */
_domTime?: number | null | undefined;
/** _non-standard_ */
_effectiveBps?: number | null | undefined;
/** _non-standard_ */
_effectiveBpsDoc?: number | null | undefined;
/** _non-standard_ */
_eventName?: string | null | undefined;
/** _non-standard_ */
_firstPaint?: number | null | undefined;
/** _non-standard_ */
_fixed_viewport?: number | null | undefined;
/** _non-standard_ */
_fullyLoaded?: number | null | undefined;
/** _non-standard_ */
_fullyLoadedCPUms?: number | null | undefined;
/** _non-standard_ */
_fullyLoadedCPUpct?: number | null | undefined;
/** _non-standard_ */
_gzip_savings?: number | null | undefined;
/** _non-standard_ */
_gzip_total?: number | null | undefined;
/** _non-standard_ */
_image_savings?: number | null | undefined;
/** _non-standard_ */
_image_total?: number | null | undefined;
/** _non-standard_ */
_isResponsive?: number | null | undefined;
/** _non-standard_ */
_lastVisualChange?: number | null | undefined;
/** _non-standard_ */
_loadEventEnd?: number | null | undefined;
/** _non-standard_ */
_loadEventStart?: number | null | undefined;
/** _non-standard_ */
_loadTime?: number | null | undefined;
/** _non-standard_ */
_minify_savings?: number | null | undefined;
/** _non-standard_ */
_minify_total?: number | null | undefined;
/** _non-standard_ */
_optimization_checked?: number | null | undefined;
/** _non-standard_ */
_pageSpeedVersion?: string | null | undefined;
/** _non-standard_ */
_render?: number | null | undefined;
/** _non-standard_ */
_requests?: number | null | undefined;
/** _non-standard_ */
_requestsDoc?: number | null | undefined;
/** _non-standard_ */
_requestsFull?: number | null | undefined;
/** _non-standard_ */
_responses_200?: number | null | undefined;
/** _non-standard_ */
_responses_404?: number | null | undefined;
/** _non-standard_ */
_responses_other?: number | null | undefined;
/** _non-standard_ */
_result?: number | null | undefined;
/** _non-standard_ */
_run?: number | null | undefined;
/** _non-standard_ */
_score_cache?: number | null | undefined;
/** _non-standard_ */
_score_cdn?: number | null | undefined;
/** _non-standard_ */
_score_combine?: number | null | undefined;
/** _non-standard_ */
_score_compress?: number | null | undefined;
/** _non-standard_ */
_score_cookies?: number | null | undefined;
/** _non-standard_ */
_score_etags?: number | null | undefined;
/** _non-standard_ */
_score_gzip?: number | null | undefined;
/** _non-standard_ */
'_score_keep-alive'?: number | null | undefined;
/** _non-standard_ */
_score_minify?: number | null | undefined;
/** _non-standard_ */
_score_progressive_jpeg?: number | null | undefined;
/** _non-standard_ */
_server_count?: number | null | undefined;
/** _non-standard_ */
_server_rtt?: number | null | undefined;
/** _non-standard_ */
_SpeedIndex?: number | null | undefined;
/** _non-standard_ */
_step?: number | null | undefined;
/** _non-standard_ */
_title?: string | null | undefined;
/** _non-standard_ */
_titleTime?: number | null | undefined;
/** _non-standard_ */
_TTFB?: number | null | undefined;
/** _non-standard_ */
_URL?: string | null | undefined;
/** _non-standard_ */
_visualComplete?: number | null | undefined;
}
/**
* This object describes timings for various events (states) fired during the
* page load.
*
* All times are specified in milliseconds.
*
* If a time info is not available appropriate field is set to `-1`.
*
* http://www.softwareishard.com/blog/har-12-spec/#pageTimings
*/
export interface PageTiming {
/**
* Content of the page loaded. Number of milliseconds since page load
* started (`page.startedDateTime`).
*
* Use `-1` if the timing does not apply to the current request.
*/
onContentLoad?: number | undefined;
/**
* Page is loaded (`onLoad` event fired). Number of milliseconds since
* page load started (`page.startedDateTime`).
*
* Use `-1` if the timing does not apply to the current request.
*/
onLoad?: number | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
_startRender?: number | null | undefined;
}
/**
* _non-standard_
*
* Data for Chunk as provided by e.g. WebPageTest
*/
export interface Chunk {
bytes: number;
ts: number;
}
/**
* This object represents an array with all exported HTTP requests. Sorting
* entries by `startedDateTime` (starting from the oldest) is preferred way how
* to export data since it can make importing faster.
* However the reader application should always make sure the array is sorted
* (if required for the import).
*
* http://www.softwareishard.com/blog/har-12-spec/#entries
*/
export interface Entry {
/**
* Reference to the parent page. Leave out this field if the application
* does not support grouping by pages.
*/
pageref?: string | undefined;
/**
* Date and time stamp of the request start
*
* (ISO 8601 - `YYYY-MM-DDThh:mm:ss.sTZD`).
*/
startedDateTime: string;
/**
* Total elapsed time of the request in milliseconds.
*
* This is the sum of all timings available in the timings object
* (i.e. not including `-1` values).
*/
time: number;
/** Detailed info about the request. */
request: Request;
/** Detailed info about the response. */
response: Response;
/** Info about cache usage. */
cache: Cache;
/** Detailed timing info about request/response round trip. */
timings: Timings;
/**
* IP address of the server that was connected
* (result of DNS resolution).
*/
serverIPAddress?: string | undefined;
/**
* Unique ID of the parent TCP/IP connection, can be the client or server
* port number.
*
* Note that a port number doesn't have to be unique identifier
* in cases where the port is shared for more connections.
*
* If the port isn't available for the application, any other unique
* connection ID can be used instead (e.g. connection index). Leave out
* this field if the application doesn't support this info.
*/
connection?: string | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
/** _non-standard_ */
_all_end?: number | string | null | undefined;
/** _non-standard_ */
_all_ms?: number | string | null | undefined;
/** _non-standard_ */
_all_start?: number | string | null | undefined;
/** _non-standard_ */
_bytesIn?: number | string | null | undefined;
/** _non-standard_ */
_bytesOut?: number | string | null | undefined;
/** _non-standard_ */
_cacheControl?: string | null | undefined;
/** _non-standard_ */
_cache_time?: number | string | null | undefined;
/** _non-standard_ */
_cdn_provider?: string | null | undefined;
/** _non-standard_ */
_certificate_bytes?: number | string | null | undefined;
/** _non-standard_ */
_chunks?: Chunk[] | null | undefined;
/** _non-standard_ */
_client_port?: number | string | null | undefined;
/** _non-standard_ */
_connect_end?: number | string | null | undefined;
/** _non-standard_ */
_connect_ms?: number | string | null | undefined;
/** _non-standard_ */
_connect_start?: number | string | null | undefined;
/** _non-standard_ */
_contentEncoding?: string | null | undefined;
/** _non-standard_ */
_contentType?: string | null | undefined;
/** _non-standard_ */
_dns_end?: number | string | null | undefined;
/** _non-standard_ */
_dns_ms?: number | string | null | undefined;
/** _non-standard_ */
_dns_start?: number | string | null | undefined;
/** _non-standard_ */
_download_end?: number | string | null | undefined;
/** _non-standard_ */
_download_ms?: number | string | null | undefined;
/** _non-standard_ */
_download_start?: number | string | null | undefined;
/** _non-standard_ */
_expires?: string | null | undefined;
/** _non-standard_ */
_full_url?: string | null | undefined;
/** _non-standard_ */
_gzip_save?: number | string | null | undefined;
/** _non-standard_ */
_gzip_total?: number | string | null | undefined;
/** _non-standard_ */
_host?: string | null | undefined;
/** _non-standard_ */
_http2_stream_dependency?: number | string | null | undefined;
/** _non-standard_ */
_http2_stream_exclusive?: number | string | null | undefined;
/** _non-standard_ */
_http2_stream_id?: number | string | null | undefined;
/** _non-standard_ */
_http2_stream_weight?: number | string | null | undefined;
/** _non-standard_ */
_image_save?: number | string | null | undefined;
/** _non-standard_ */
_image_total?: number | string | null | undefined;
/** _non-standard_ */
_index?: number | null | undefined;
/** _non-standard_ */
_initiator?: string | null | undefined;
/** _non-standard_ */
_initiator_column?: string | null | undefined;
/** _non-standard_ */
_initiator_detail?: string | null | undefined;
/** _non-standard_ */
_initiator_function?: string | null | undefined;
/** _non-standard_ */
_initiator_line?: string | null | undefined;
/** _non-standard_ */
_initiator_type?: string | null | undefined;
/** _non-standard_ */
_ip_addr?: string | null | undefined;
/** _non-standard_ */
_is_secure?: number | string | null | undefined;
/** _non-standard_ */
_jpeg_scan_count?: number | string | null | undefined;
/** _non-standard_ */
_load_end?: number | string | null | undefined;
/** _non-standard_ */
_load_ms?: number | string | null | undefined;
/** _non-standard_ */
_load_start?: number | string | null | undefined;
/** _non-standard_ */
_method?: string | null | undefined;
/** _non-standard_ */
_minify_save?: number | string | null | undefined;
/** _non-standard_ */
_minify_total?: number | string | null | undefined;
/** _non-standard_ */
_number?: number | null | undefined;
/** _non-standard_ */
_objectSize?: number | string | null | undefined;
/** _non-standard_ */
_objectSizeUncompressed?: number | string | null | undefined;
/** _non-standard_ */
_priority?: string | null | undefined;
/** _non-standard_ */
_protocol?: number | string | null | undefined;
/** _non-standard_ */
_request_id?: number | string | null | undefined;
/** _non-standard_ */
_responseCode?: number | string | null | undefined;
/** _non-standard_ */
_score_cache?: number | string | null | undefined;
/** _non-standard_ */
_score_cdn?: number | string | null | undefined;
/** _non-standard_ */
_score_combine?: number | string | null | undefined;
/** _non-standard_ */
_score_compress?: number | string | null | undefined;
/** _non-standard_ */
_score_cookies?: number | string | null | undefined;
/** _non-standard_ */
_score_etags?: number | string | null | undefined;
/** _non-standard_ */
_score_gzip?: number | string | null | undefined;
/** _non-standard_ */
'_score_keep-alive'?: number | string | null | undefined;
/** _non-standard_ */
_score_minify?: number | string | null | undefined;
/** _non-standard_ */
_score_progressive_jpeg?: number | null | undefined;
/** _non-standard_ */
_server_count?: number | string | null | undefined;
/** _non-standard_ */
_server_rtt?: number | string | null | undefined;
/** _non-standard_ */
_socket?: number | string | null | undefined;
/** _non-standard_ */
_ssl_end?: number | string | null | undefined;
/** _non-standard_ */
_ssl_ms?: number | string | null | undefined;
/** _non-standard_ */
_ssl_start?: number | string | null | undefined;
/** _non-standard_ */
_ttfb_end?: number | string | null | undefined;
/** _non-standard_ */
_ttfb_ms?: number | string | null | undefined;
/** _non-standard_ */
_ttfb_start?: number | string | null | undefined;
/** _non-standard_ */
_type?: number | string | null | undefined;
/** _non-standard_ */
_url?: string | null | undefined;
/** _non-standard_ */
_was_pushed?: number | string | null | undefined;
/** _non-standard_ */
_initialPriority?: string | null | undefined;
/** _non-standard_ */
_renderBlocking?: string | null | undefined;
/** _non-standard_ */
_isLCP?: boolean | null | undefined;
}
/**
* This object contains detailed info about performed request.
*
* http://www.softwareishard.com/blog/har-12-spec/#request
*/
export interface Request {
/** Request method (`GET`, `POST`, ...). */
method: string;
/** Absolute URL of the request (fragments are not included). */
url: string;
/** Request HTTP Version. */
httpVersion: string;
/** List of cookie objects. */
cookies: Cookie[];
/** List of header objects. */
headers: Header[];
/** List of query parameter objects. */
queryString: QueryString[];
/** Posted data info. */
postData?: PostData | undefined;
/**
* Total number of bytes from the start of the HTTP request message until
* (and including) the double CRLF before the body.
*
* Set to `-1` if the info is not available.
*/
headersSize: number;
/**
* Size of the request body (POST data payload) in bytes.
*
* Set to `-1` if the info is not available.
*/
bodySize: number;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object contains detailed info about the response.
*
* http://www.softwareishard.com/blog/har-12-spec/#response
*/
export interface Response {
/** Response status. */
status: number;
/** Response status description. */
statusText: string;
/** Response HTTP Version. */
httpVersion: string;
/** List of cookie objects. */
cookies: Cookie[];
/** List of header objects. */
headers: Header[];
/** Details about the response body. */
content: Content;
/** Redirection target URL from the Location response header. */
redirectURL: string;
/**
* Total number of bytes from the start of the HTTP response message until
* (and including) the double CRLF before the body.
*
* Set to `-1` if the info is not available.
*
* _The size of received response-headers is computed only from headers
* that are really received from the server. Additional headers appended by
* the browser are not included in this number, but they appear in the list
* of header objects._
*/
headersSize: number;
/**
* Size of the received response body in bytes.
*
* - Set to zero in case of responses coming from the cache (`304`).
* - Set to `-1` if the info is not available.
*/
bodySize: number;
/** A comment provided by the user or the application */
comment?: string | undefined;
/** _non-standard_ */
_transferSize?: number | null | undefined;
}
/**
* This object contains list of all cookies (used in `request` and `response`
* objects).
*
* http://www.softwareishard.com/blog/har-12-spec/#cookies
*/
export interface Cookie {
/** The name of the cookie. */
name: string;
/** The cookie value. */
value: string;
/** The path pertaining to the cookie. */
path?: string | undefined;
/** The host of the cookie. */
domain?: string | undefined;
/**
* Cookie expiration time.
* (ISO 8601 - `YYYY-MM-DDThh:mm:ss.sTZD`,
* e.g. `2009-07-24T19:20:30.123+02:00`).
*/
expires?: string | undefined;
/** Set to true if the cookie is HTTP only, false otherwise. */
httpOnly?: boolean | undefined;
/** True if the cookie was transmitted over ssl, false otherwise. */
secure?: boolean | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object represents a headers (used in `request` and `response` objects).
*
* http://www.softwareishard.com/blog/har-12-spec/#headers
*/
export interface Header {
name: string;
value: string;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object represents a parameter & value parsed from a query string,
* if any (embedded in `request` object).
*
* http://www.softwareishard.com/blog/har-12-spec/#queryString
*/
export interface QueryString {
name: string;
value: string;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object describes posted data, if any (embedded in `request` object).
*
* http://www.softwareishard.com/blog/har-12-spec/#postData
*/
export type PostData = PostDataCommon & (PostDataParams | PostDataText);
/**
* The common properties of PostData
*/
export interface PostDataCommon {
/** Mime type of posted data. */
mimeType: string;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* Post data with `params` specified.
*/
export interface PostDataParams {
/**
* List of posted parameters (in case of URL encoded parameters).
*/
params: Param[];
/**
* _`params` and `text` fields are mutually exclusive._
*/
text?: never | undefined;
}
/**
* Post data with `text` specified.
*/
export interface PostDataText {
/**
* Plain text posted data
*/
text: string;
/**
* _`params` and `text` fields are mutually exclusive._
*/
params?: never | undefined;
}
/**
* List of posted parameters, if any (embedded in `postData` object).
*
* http://www.softwareishard.com/blog/har-12-spec/#params
*/
export interface Param {
/** name of a posted parameter. */
name: string;
/** value of a posted parameter or content of a posted file */
value?: string | undefined;
/** name of a posted file. */
fileName?: string | undefined;
/** content type of a posted file. */
contentType?: string | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object describes details about response content
* (embedded in `response` object).
*
* http://www.softwareishard.com/blog/har-12-spec/#content
*/
export interface Content {
/**
* Length of the returned content in bytes.
*
* Should be equal to `response.bodySize` if there is no compression and
* bigger when the content has been compressed.
*/
size: number;
/**
* Number of bytes saved. Leave out this field if the information is not
* available.
*/
compression?: number | undefined;
/**
* MIME type of the response text (value of the Content-Type response
* header).
*
* The charset attribute of the MIME type is included (if available).
*/
mimeType: string;
/**
* Response body sent from the server or loaded from the browser cache.
*
* This field is populated with textual content only.
*
* The text field is either HTTP decoded text or a encoded (e.g. `base64`)
* representation of the response body.
*
* Leave out this field if the information is not available.
*/
text?: string | undefined;
/**
* Encoding used for response text field e.g `base64`.
*
* Leave out this field if the text field is HTTP decoded
* (decompressed & unchunked), than trans-coded from its original character
* set into UTF-8.
*/
encoding?: string | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This objects contains info about a request coming from browser cache.
*
* http://www.softwareishard.com/blog/har-12-spec/#cache
*/
export interface Cache {
/**
* State of a cache entry before the request.
*
* Leave out this field if the information is not available.
*/
beforeRequest?: CacheDetails | null | undefined;
/**
* State of a cache entry after the request.
*
* Leave out this field if the information is not available.
*/
afterRequest?: CacheDetails | null | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
export interface CacheDetails {
/**
* Expiration time of the cache entry.
*
* _(Format not documente but assumingly ISO 8601 -
* `YYYY-MM-DDThh:mm:ss.sTZD`)_
*/
expires?: string | undefined;
/**
* The last time the cache entry was opened.
*
* _(Format not documente but assumingly ISO 8601 -
* `YYYY-MM-DDThh:mm:ss.sTZD`)_
*/
lastAccess: string;
/** Etag */
eTag: string;
/** The number of times the cache entry has been opened. */
hitCount: number;
/** A comment provided by the user or the application */
comment?: string | undefined;
}
/**
* This object describes various phases within request-response round trip.
*
* All times are specified in milliseconds.
*
* http://www.softwareishard.com/blog/har-12-spec/#timings
*/
export interface Timings {
/**
* Time spent in a queue waiting for a network connection.
*
* Use `-1` if the timing does not apply to the current request.
*/
blocked?: number | undefined;
/**
* DNS resolution time. The time required to resolve a host name.
*
* Use `-1` if the timing does not apply to the current request.
*/
dns?: number | undefined;
/**
* Time required to create TCP connection.
*
* Use `-1` if the timing does not apply to the current request.
*/
connect?: number | undefined;
/**
* Time required to send HTTP request to the server.
*
* _Not optional and must have non-negative values._
*/
send?: number | undefined;
/**
* Waiting for a response from the server.
*
* _Not optional and must have non-negative values._
*/
wait: number;
/**
* Time required to read entire response from the server (or cache).
*
* _Not optional and must have non-negative values._
*/
receive: number;
/**
* Time required for SSL/TLS negotiation.
*
* If this field is defined then the time is also included in the connect
* field (to ensure backward compatibility with HAR 1.1).
*
* Use `-1` if the timing does not apply to the current request.
*/
ssl?: number | undefined;
/** A comment provided by the user or the application */
comment?: string | undefined;
}

View File

@@ -1,148 +0,0 @@
import * as harFormat from 'har-format';
const testCreator: harFormat.Creator = {
name: 'WebInspector',
version: '537.36',
};
const testPageTiming: harFormat.PageTiming = {
onContentLoad: 1995.6460000003062,
onLoad: 4262.566999999763,
};
const testPage: harFormat.Page = {
startedDateTime: '2017-02-11T09:36:22.868Z',
id: 'page_1',
title: 'https://github.com/',
pageTimings: testPageTiming,
};
const testHeader: harFormat.Header = {
name: 'Accept',
value: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
};
const testRequest: harFormat.Request = {
method: 'GET',
url: 'https://github.com/',
httpVersion: 'HTTP/1.1',
headers: [testHeader],
queryString: [],
cookies: [],
headersSize: 425,
bodySize: 0,
};
const testHeaders: harFormat.Header = {
name: 'Content-Encoding',
value: 'gzip',
};
const testCookie: harFormat.Cookie = {
name: 'logged_in',
value: 'no',
path: '/',
domain: '.github.com',
expires: '2037-02-11T09:36:23.000Z',
httpOnly: true,
secure: true,
};
const textPostData: harFormat.PostData = {
mimeType: 'text/plain',
text: 'some-text',
};
const paramsPostData: harFormat.PostData = {
mimeType: 'multipart/form-data',
params: [
{
name: 'some-param',
value: 'val',
},
],
};
// @ts-expect-error
const missingPostData: harFormat.PostData = {
mimeType: 'text/plain',
};
// @ts-expect-error
const tooMuchPostData: harFormat.PostData = {
mimeType: 'multipart/form-data',
params: [
{
name: 'some-param',
value: 'val',
},
],
text: 'asd',
};
const testContent: harFormat.Content = {
size: 26915,
mimeType: 'text/html',
compression: 18635,
};
const testResponse: harFormat.Response = {
status: 200,
statusText: 'OK',
httpVersion: 'HTTP/1.1',
headers: [testHeaders],
cookies: [testCookie],
content: testContent,
redirectURL: '',
headersSize: 2084,
bodySize: 8280,
_transferSize: 10364,
};
const testTimings: harFormat.Timings = {
blocked: 0.439999999798602,
dns: 39.6150000005946,
connect: 483.8799999997718,
send: 0.06899999971199122,
wait: 287.516999999753,
receive: 5.289000000629585,
ssl: 244.02999999983808,
};
const testEntry: harFormat.Entry = {
startedDateTime: '2017-02-11T09:36:22.868Z',
time: 816.8100000002596,
request: testRequest,
response: testResponse,
cache: {},
timings: testTimings,
serverIPAddress: '192.30.253.113',
connection: '26487',
pageref: 'page_1',
_gzip_total: null,
_server_rtt: null,
_chunks: [{ ts: 1, bytes: 4 }],
};
// Examples from http://www.softwareishard.com/blog/har-12-spec/#cache
const testCacheNoInformation: harFormat.Cache = {};
const testNoCacheAfter: harFormat.Cache = {
afterRequest: null,
};
const testCacheNotCached: harFormat.Cache = {
beforeRequest: null,
afterRequest: null,
};
const testLog: harFormat.Log = {
version: '1.2',
creator: testCreator,
pages: [testPage],
entries: [testEntry],
};
const harFile: harFormat.Har = {
log: testLog,
};

View File

@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"test/har-format-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }