Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve compiler api types #2001

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading