-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Labels
Description
The package published on npm looks like it still has the "unknonw" typo in the compile declaration.
However obviously we can do better than "unknown", I already created a typing of the parser result while developing the vscode riot extension:
type Expression = {
text: string,
start: number,
end: number
};
type Attribute = {
name: string,
value: string,
start: number,
end: number,
unescape?: string,
expressions?: Array<Expression>,
valueStart?: number,
parts?: Array<string>
};
type BaseParserNode = {
type: number,
name: string,
start: number,
end: number,
attributes?: Array<Attribute>,
isVoid?: true,
isSelfClosing?: true
};
type ParserNode = BaseParserNode & {
nodes?: Array<ParserNode>,
isCustom?: true,
text?: string,
expressions?: Array<Expression>,
parts?: Array<string>
};
type ParserCodeNode = BaseParserNode & {
text?: {
type: 3,
text: string,
start: number,
end: number
}
};
type ParserResult = {
data: string,
output: {
template: ParserNode,
css: ParserCodeNode | null,
javascript: ParserCodeNode | null,
}
};
This is not by any means complete, but I hope it can help to provide better typings.
Also I'm posting this here but the typings should be actually added in the parser and the compiler should reference them.