Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upThe [[ExportName]] field of ExportEntry Record can also be null #1290
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Aug 18, 2018
Collaborator
It appears that when an ExportEntry Record has [[ImportName]] = "*", its [[ExportName]] and [[LocalName]] are completely ignored. (ParseModule puts the record in _starExportEntries_, which goes to [[StarExportEntries]], which is then processed in GetExportedNames and ResolveExport.)
So on the one hand, it doesn't matter what [[ExportName]] is set to there. But on the other hand, I agree that the use of the field should conform to its 'type declaration'. The easiest thing would be to change the latter to "String | null". (Personally, I think replacing null with (say) "*ignored*" would be somewhat more informative. Another alternative would be to have 3 'sub-types' of ExportEntry Record, none of which have any null fields.)
|
It appears that when an ExportEntry Record has So on the one hand, it doesn't matter what |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seminaoki
Aug 18, 2018
I agree that
The easiest thing would be to change the latter to "String | null"
Since other fields of ExportEntry also use "String | null" value type.
seminaoki
commented
Aug 18, 2018
|
I agree that
Since other fields of ExportEntry also use "String | null" value type. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
wouldn't we say not present or unset here? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Aug 18, 2018
Collaborator
wouldn't we say not present or unset here?
The spec doesn't use the word "unset" at all, so that seems unlikely. As for "not present", did you mean like this?
ExportEntry Record { ..., [[ExportName]]: not present, ... }
That would amount to treating not present as a (spec) value, which we don't really do.
The spec doesn't use the word "unset" at all, so that seems unlikely. As for "not present", did you mean like this?
That would amount to treating |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
It could be |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Aug 18, 2018
Collaborator
It could, but:
nullis clearly the convention for ExportEntry records, and- you'd still have to change [[ExportEntry]]'s field type.
|
It could, but:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ljharb
Aug 18, 2018
Member
Would you? Empty means there’s nothing there, so the type is still string, it’s just optional.
|
Would you? Empty means there’s nothing there, so the type is still string, it’s just optional. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Aug 18, 2018
Collaborator
I don't think there's a precedent in the spec where something with a declared type of T actually allows T or ~empty~. E.g., the [[Target]] field of completion records is explicitly declared as any ECMAScript string or ~empty~.
(In several programming languages, "optional string" is quite distinct from "string". E.g. Rust, Swift, Kotlin, Scala, C#, F#.)
|
I don't think there's a precedent in the spec where something with a declared type of T actually allows T or (In several programming languages, "optional string" is quite distinct from "string". E.g. Rust, Swift, Kotlin, Scala, C#, F#.) |
seminaoki commentedAug 18, 2018
In Table 42: ExportEntry Record Fields, it states that [[ExportName]] filed's value type is String.
But look at the example, [[ExportName]] can also be null, when Export Statement Form is the following:
The [[ExportName]] field of ExportEntry Record should be "String | null",
or the [[ExportName]] of
export * from "mod";should not be null.