/** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ import ts from 'typescript'; import { ProgramMessage, Placeholder } from './messages.js'; type ResultOrError = { result: R; error?: undefined; } | { result?: undefined; error: E; }; /** * Extract translation messages from all files in a TypeScript program. */ export declare function extractMessagesFromProgram(program: ts.Program): { messages: ProgramMessage[]; errors: ts.Diagnostic[]; }; /** * Analyze the options argument to a msg call. */ export declare function extractOptions(node: ts.Node | undefined, file: ts.SourceFile): ResultOrError<{ id?: string; desc?: string; }, ts.Diagnostic>; interface ExtractedTemplate { contents: Array; params?: string[]; tag: 'html' | 'str' | undefined; template: ts.TemplateLiteral | ts.StringLiteral; } /** * Analyze the template argument to a msg call. */ export declare function extractTemplate(templateArg: ts.Node, file: ts.SourceFile, typeChecker: ts.TypeChecker): ResultOrError; export declare function generateMsgIdFromAstNode(template: ts.TemplateLiteral | ts.StringLiteral, isHtmlTagged: boolean): string; /** * E.g. "foo", 'foo', or `foo`, but not `foo${bar}`. */ export declare function isStaticString(node: ts.Node): node is ts.StringLiteral | ts.NoSubstitutionTemplateLiteral; /** * E.g. html`foo` or html`foo${bar}` */ export declare function isLitTemplate(node: ts.Node): node is ts.TaggedTemplateExpression; /** * E.g. str`foo${bar}` */ export declare function isStrTemplate(node: ts.Node): node is ts.TaggedTemplateExpression; /** * Return whether this is a call to the lit-localize `msg` function. */ export declare function isMsgCall(node: ts.Node, typeChecker: ts.TypeChecker): node is ts.CallExpression; /** * Return whether a node is a string tagged with our special `str` tag. */ export declare function isStrTaggedTemplate(node: ts.Node, typeChecker: ts.TypeChecker): node is ts.TaggedTemplateExpression; export {};