Skip to content

Commit

Permalink
fix: improve compiler api types
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jul 21, 2023
1 parent be1cc1b commit 037a6ce
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/purple-steaks-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@marko/babel-utils": patch
"@marko/compiler": patch
---

Improve some typings for the compiler apis.
6 changes: 3 additions & 3 deletions packages/babel-utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export interface AttributeDefinition {
descriptionMoreURL?: string;
}>;
}
export type PluginDefinition<T = any> = {
export interface PluginDefinition<T = any> {
path?: string;
hook: Plugin<T>;
};
}
export interface TagDefinition {
dir: string;
filePath: string;
Expand Down Expand Up @@ -209,7 +209,7 @@ export function loadFileForImport(

export function normalizeTemplateString(
quasis: Array<string | t.TemplateElement>,
expressions: t.Expression[]
...expressions: t.Expression[]
): t.TemplateLiteral;

type Loc = { line: number; column: number; index?: number };
Expand Down
5 changes: 4 additions & 1 deletion packages/compiler/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ declare const Config: {
ignoreUnrecognizedTags?: boolean;
sourceMaps?: boolean | "inline" | "both";
translator?: any;
fileSystem?: typeof import("fs");
fileSystem?: Pick<
typeof import("fs"),
"statSync" | "readFileSync" | "readdirSync"
>;
modules?: "esm" | "cjs";
resolveVirtualDependency?:
| ((
Expand Down
11 changes: 6 additions & 5 deletions packages/compiler/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { TaglibLookup, Diagnostic } from "@marko/babel-utils";
import * as types from "./babel-types";
export { types };

export type Config = typeof import("./config");
type _Config = typeof import("./config");
export interface Config extends _Config {}

type Dep = {
type: string;
Expand All @@ -16,21 +17,21 @@ type Dep = {
[x: string]: unknown;
};

export type MarkoMeta = {
export interface MarkoMeta {
id: string;
component?: string;
watchFiles: string[];
tags?: string[];
deps: Array<string | Dep>;
diagnostics: Diagnostic[];
};
}

export type CompileResult = {
export interface CompileResult {
ast: types.File;
code: string;
map: SourceMap;
meta: MarkoMeta;
};
}

export function configure(config: Config): void;

Expand Down

0 comments on commit 037a6ce

Please sign in to comment.