Skip to content

Commit 034aab9

Browse files
committed
add some object globals, Function.prototype.name
1 parent f155d65 commit 034aab9

File tree

1 file changed

+5
-1
lines changed
  • packages/svelte/src/compiler/phases

1 file changed

+5
-1
lines changed

packages/svelte/src/compiler/phases/scope.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const UNKNOWN = Symbol('unknown');
2222
export const NUMBER = Symbol('number');
2323
export const STRING = Symbol('string');
2424
/** @typedef {NUMBER | STRING | UNKNOWN | undefined | boolean} TYPE */
25-
2625
/** @type {Record<string, [type: TYPE | TYPE[], fn?: Function]>} */
2726
const globals = {
2827
BigInt: [NUMBER, BigInt],
@@ -70,6 +69,8 @@ const globals = {
7069
'Number.isSafeInteger': [NUMBER, Number.isSafeInteger],
7170
'Number.parseFloat': [NUMBER, Number.parseFloat],
7271
'Number.parseInt': [NUMBER, Number.parseInt],
72+
'Object.is': [[true, false], Object.is],
73+
'Object.hasOwn': [[true, false], Object.hasOwn],
7374
String: [STRING, String],
7475
'String.fromCharCode': [STRING, String.fromCharCode],
7576
'String.fromCodePoint': [STRING, String.fromCodePoint]
@@ -606,6 +607,9 @@ class Evaluation {
606607
if (keypath && Object.hasOwn(global_constants, keypath)) {
607608
this.values.add(global_constants[keypath]);
608609
break;
610+
} else if (keypath?.match(/\.name$/) && Object.hasOwn(globals, keypath.slice(0, -5))) {
611+
this.values.add(globals[keypath.slice(0, -5)]?.[1]?.name ?? STRING);
612+
break;
609613
}
610614

611615
this.values.add(UNKNOWN);

0 commit comments

Comments
 (0)