Skip to content
4 changes: 4 additions & 0 deletions types/babel__traverse/babel__traverse-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MyVisitor2: Visitor = {
},
ArrayExpression(path) {
path.get("elements"); // $ExpectType NodePath<SpreadElement | Expression | null>[]
path.get("elements.0"); // $ExpectType NodePath<SpreadElement | Expression | null>
},
Program(path) {
path.parentPath; // $ExpectType null
Expand Down Expand Up @@ -374,6 +375,7 @@ const objectTypeAnnotation: NodePath<t.ObjectTypeAnnotation> = new NodePath<t.Ob
);

objectTypeAnnotation.get("indexers"); // $ExpectType NodePathResult<ObjectTypeIndexer[] | undefined>
objectTypeAnnotation.get("indexers.0"); // $ExpectType NodePath<ObjectTypeIndexer>

// Test that NodePath can be narrowed from union to single type
const path: NodePath<t.ExportDefaultDeclaration | t.ExportNamedDeclaration> = new NodePath<t.ExportNamedDeclaration>(
Expand Down Expand Up @@ -427,7 +429,9 @@ binding.deopValue();
binding.clearValue();

binding.reassign(newPath.get("body")[0]);
binding.reassign(newPath.get("body.0"));
binding.reference(newPath.get("body")[0]);
binding.reference(newPath.get("body.0"));
binding.dereference();

newPath.scope.checkBlockScopedCollisions(binding, "local", "name", {});
Expand Down
22 changes: 22 additions & 0 deletions types/babel__traverse/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ export class NodePath<T = Node> {
getAllNextSiblings(): NodePath[];

get<K extends keyof T>(key: K, context?: boolean | TraversalContext): NodePathResult<T[K]>;
get<P extends string>(path: P, context?: boolean | TraversalContext): NodePathResult<ImplGetRecursive<T, P>>;
get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];

getBindingIdentifiers(duplicates: true): Record<string, t.Identifier[]>;
Expand Down Expand Up @@ -1448,6 +1449,27 @@ export interface TraversalContext<S = unknown> {
opts: TraverseOptions;
}

// Based on `GetFieldType`s from `@types/lodash/common/object.d.ts`:
// dprint-ignore
type ImplGetOfArray<T extends readonly unknown[], K extends string> =
K extends `${infer N extends number}` ? T[N]
: K extends keyof T ? T[K]
: never;

// dprint-ignore
type ImplGetByKey<T, K extends string>
= T extends readonly unknown[] ? ImplGetOfArray<T, K>
: K extends keyof T ? T[K]
: K extends `${infer N extends number}`
? N extends keyof T ? T[N] : never
: never;

// dprint-ignore
type ImplGetRecursive<T, K extends string>
= K extends `${infer L}.${infer R}`
? ImplGetRecursive<ImplGetByKey<T, L>, R>
: ImplGetByKey<T, K>;

export type NodePathResult<T> =
| (Extract<T, Node | null | undefined> extends never ? never : NodePath<Extract<T, Node | null | undefined>>)
| (T extends Array<Node | null | undefined> ? Array<NodePath<T[number]>> : never);
Expand Down
5 changes: 5 additions & 0 deletions types/dom-speech-recognition/dom-speech-recognition-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const speechRecognition2: SpeechRecognition = {
};
const speechRecognition3 = new webkitSpeechRecognition();

const speechRecognition4: SpeechRecognition = {
...speechRecognition2,
start: (audioTrack: MediaStreamTrack) => undefined,
};

const speechRecognitionResultList = new SpeechRecognitionResultList();

const speechRecognitionEventInit: SpeechRecognitionEventInit = {
Expand Down
2 changes: 1 addition & 1 deletion types/dom-speech-recognition/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface SpeechRecognition extends EventTarget {
onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null;
onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
abort(): void;
start(): void;
start(audioTrack?: MediaStreamTrack): void;
stop(): void;
addEventListener<K extends keyof SpeechRecognitionEventMap>(
type: K,
Expand Down
2 changes: 2 additions & 0 deletions types/gorilla-engine/components/MappingEditor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare namespace GorillaEngine.UI {
interface MappingEditorProps extends Common, Bounds, Background {
zones?: Zone[];
refreshView(index?: number): void;
selectAllZones(): void;
deselectAllZones(): void;
addZone(zone: Partial<Zone>): Zone;
removeZone(zone: Partial<Zone>): void;
}
Expand Down
2 changes: 1 addition & 1 deletion types/gorilla-engine/gorilla-engine-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ const label = new GorillaEngine.UI.Label({ margin: 5 });

const slider = new GorillaEngine.UI.Slider({ id: "slider", x: 0 });

const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: "myMappingEditor" });
const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: "MappingEditor" });
4 changes: 0 additions & 4 deletions types/k6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
"name": "Théo Crevon",
"githubUsername": "oleiade"
},
{
"name": "Oleg Bespalov",
"githubUsername": "olegbespalov"
},
{
"name": "Ankur Agarwal",
"githubUsername": "ankur22"
Expand Down
2 changes: 1 addition & 1 deletion types/mailchimp__mailchimp_transactional/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"https://github.com/mailchimp/mailchimp-transactional-node"
],
"dependencies": {
"axios": "^1.6.7"
"axios": "^1.8.2"
},
"devDependencies": {
"@types/mailchimp__mailchimp_transactional": "workspace:."
Expand Down
2 changes: 1 addition & 1 deletion types/mysql/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export type TypeCast =
buffer(): null | Buffer;
geometry(): null | GeometryType;
},
next: () => void,
next: () => any,
) => any);

export type queryCallback = (err: MysqlError | null, results?: any, fields?: FieldInfo[]) => void;
Expand Down
4 changes: 2 additions & 2 deletions types/mysql/mysql-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ connection.query({
if (field.type === "TINY" && field.length === 1) {
return (field.string() === "1"); // 1 = true, 0 = false
}
next();
return next();
},
});

Expand All @@ -456,7 +456,7 @@ connection.query({
}
return (JSON.parse(string));
}
next();
return next();
},
});

Expand Down
2 changes: 1 addition & 1 deletion types/semver/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const SEMVER_SPEC_VERSION: "2.0.0";

export const RELEASE_TYPES: ReleaseType[];

export type ReleaseType = "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease";
export type ReleaseType = "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease" | "release";

export interface Options {
loose?: boolean | undefined;
Expand Down
2 changes: 1 addition & 1 deletion types/semver/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/semver",
"version": "7.5.9999",
"version": "7.7.9999",
"projects": [
"https://github.com/npm/node-semver"
],
Expand Down
1 change: 1 addition & 0 deletions types/semver/semver-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ strn = semver.inc(str, "prerelease", "beta");
strn = semver.inc("1.2.3", "prerelease", "alpha", "0");
strn = semver.inc("1.2.3", "prerelease", "alpha", "1");
strn = semver.inc("1.2.3", "prerelease", "beta", false);
let res: string | null = semver.inc("1.2.3", "release"); // $ExpectType string | null
num = semver.major(str, loose);
num = semver.major(str, { loose: false });
// @ts-expect-error
Expand Down