-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
TaggedTemplateExpression.ts
62 lines (55 loc) · 1.53 KB
/
TaggedTemplateExpression.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import CallOptions from '../CallOptions';
import { ExecutionPathOptions } from '../ExecutionPathOptions';
import { EMPTY_PATH } from '../values';
import Identifier from './Identifier';
import * as NodeType from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import TemplateLiteral from './TemplateLiteral';
export default class TaggedTemplateExpression extends NodeBase {
type: NodeType.tTaggedTemplateExpression;
tag: ExpressionNode;
quasi: TemplateLiteral;
private callOptions: CallOptions;
bind() {
super.bind();
if (this.tag.type === NodeType.Identifier) {
const variable = this.scope.findVariable((<Identifier>this.tag).name);
if (variable.isNamespace) {
this.context.error(
{
code: 'CANNOT_CALL_NAMESPACE',
message: `Cannot call a namespace ('${(<Identifier>this.tag).name}')`
},
this.start
);
}
if ((<Identifier>this.tag).name === 'eval') {
this.context.warn(
{
code: 'EVAL',
message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
url: 'https://rollupjs.org/guide/en#avoiding-eval'
},
this.start
);
}
}
}
hasEffects(options: ExecutionPathOptions) {
return (
super.hasEffects(options) ||
this.tag.hasEffectsWhenCalledAtPath(
EMPTY_PATH,
this.callOptions,
options.getHasEffectsWhenCalledOptions()
)
);
}
initialise() {
this.included = false;
this.callOptions = CallOptions.create({
withNew: false,
callIdentifier: this
});
}
}