add more types
This commit is contained in:
parent
5e313d933d
commit
bd858f0d30
|
@ -122,8 +122,9 @@ exports.create = (Dep, range, param, expr, options, contextOptions, parser) => {
|
|||
value = value + "`";
|
||||
} else if (
|
||||
part.expression &&
|
||||
part.expression.type === "TemplateElement" &&
|
||||
part.expression.value.raw === value
|
||||
part.expression.type === "TemplateLiteral" &&
|
||||
part.expression.quasis.length === 1 &&
|
||||
part.expression.quasis[0].value.raw === value
|
||||
) {
|
||||
// Shortcut when it's a single quasi and doesn't need to be replaced
|
||||
return;
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("estree").Expression} ExpressionNode */
|
||||
/** @typedef {import("./JavascriptParser").VariableInfoInterface} VariableInfoInterface */
|
||||
|
||||
const TypeUnknown = 0;
|
||||
const TypeUndefined = 1;
|
||||
const TypeNull = 2;
|
||||
|
@ -23,6 +26,7 @@ const TypeBigInt = 13;
|
|||
class BasicEvaluatedExpression {
|
||||
constructor() {
|
||||
this.type = TypeUnknown;
|
||||
/** @type {[number, number]} */
|
||||
this.range = undefined;
|
||||
/** @type {boolean} */
|
||||
this.falsy = false;
|
||||
|
@ -59,8 +63,11 @@ class BasicEvaluatedExpression {
|
|||
this.wrappedInnerExpressions = undefined;
|
||||
/** @type {string | undefined} */
|
||||
this.identifier = undefined;
|
||||
/** @type {VariableInfoInterface} */
|
||||
this.rootInfo = undefined;
|
||||
/** @type {() => string[]} */
|
||||
this.getMembers = undefined;
|
||||
/** @type {ExpressionNode} */
|
||||
this.expression = undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|||
/** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
||||
/** @typedef {{declaredScope: ScopeInfo, freeName: string | true, tagInfo: TagInfo | undefined}} VariableInfoInterface */
|
||||
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[] }} GetInfoResult */
|
||||
|
||||
const EMPTY_ARRAY = [];
|
||||
|
|
|
@ -314,7 +314,7 @@ declare interface BannerPluginOptions {
|
|||
}
|
||||
declare abstract class BasicEvaluatedExpression {
|
||||
type: number;
|
||||
range: any;
|
||||
range: [number, number];
|
||||
falsy: boolean;
|
||||
truthy: boolean;
|
||||
nullish: boolean;
|
||||
|
@ -333,9 +333,13 @@ declare abstract class BasicEvaluatedExpression {
|
|||
postfix: BasicEvaluatedExpression;
|
||||
wrappedInnerExpressions: any;
|
||||
identifier: string;
|
||||
rootInfo: any;
|
||||
getMembers: any;
|
||||
expression: any;
|
||||
rootInfo: {
|
||||
declaredScope: ScopeInfo;
|
||||
freeName: string | true;
|
||||
tagInfo: TagInfo;
|
||||
};
|
||||
getMembers: () => string[];
|
||||
expression: Expression;
|
||||
isUnknown(): boolean;
|
||||
isNull(): boolean;
|
||||
isUndefined(): boolean;
|
||||
|
|
Loading…
Reference in New Issue