Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare date types with strongly typed names #2408

Merged
merged 1 commit into from
Oct 3, 2021

Conversation

faatihi
Copy link
Contributor

@faatihi faatihi commented Oct 3, 2021

Many JavaScript frameworks and bundlers minify code when building for production.
Minification includes renaming identifiers, including class names.

Comparing types using literal string names doesn't work well with these frameworks and bundlers.
For example, SvelteKit renames DateTime to something like Ve.
With this, the if test fails because 'Ve' is not the same as 'DateTime'.

This results in exceptions such as the following:

  • Error: TD: Could not correctly parse "Sun Oct 03 2021 11:15:46 GMT+0000 (Coordinated Universal Time)" to a date for defaultDate
  • Error: TD: Could not correctly parse "Sun Oct 03 2021 11:15:46 GMT+0000 (Coordinated Universal Time)" to a date for viewDate

With this change, in the minified file, the line now tests for Ve.name instead of 'DateTime'

Many JavaScript frameworks and bundlers minify code when building for production.
Minification includes renaming identifiers, including class names.

Comparing types using literal string names doesn't work well with these frameworks and bundlers.
@Eonasdan Eonasdan merged commit 9e29391 into Eonasdan:master Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants