Skip to content
New issue

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

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

Already on GitHub? # to your account

$d accepts string as input #1113

Open
5 tasks done
Shinigami92 opened this issue Aug 8, 2022 · 3 comments
Open
5 tasks done

$d accepts string as input #1113

Shinigami92 opened this issue Aug 8, 2022 · 3 comments
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf Type: Bug Bug or Bug fixes typescript

Comments

@Shinigami92
Copy link

Reporting a bug?

Currently $d only allows number or Date as input via TypeScript
But we are using ISO 8601 strings and using these as input is totally fine and renders correctly
But vue-tsc throws ts compile time errors

Expected behavior

Allow string as input for $d so it doesn't throw a compile time error

Reproduction

{{ $d('2022-08-08T08:56:45.846Z') }}

System Info

System:
    OS: macOS 12.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 699.39 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node
    npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm
  Browsers:
    Chrome: 104.0.5112.79
    Safari: 15.6
  npmPackages:
    @vitejs/plugin-vue: ~3.0.1 => 3.0.1 
    @vue/apollo-composable: ~4.0.0-alpha.19 => 4.0.0-alpha.19 
    @vue/compiler-sfc: ~3.2.37 => 3.2.37 
    @vue/test-utils: ~2.0.2 => 2.0.2 
    vite: ~3.0.4 => 3.0.4 
    vite-plugin-git-revision: ~0.1.9 => 0.1.9 
    vitest: ~0.21.0 => 0.21.0 
    vue: ~3.2.37 => 3.2.37 
    vue-eslint-parser: ~9.0.3 => 9.0.3 
    vue-i18n: ~9.2.2 => 9.2.2 
    vue-router: ~4.1.3 => 4.1.3 
    vue-tsc: ~0.39.5 => 0.39.5

Screenshot

image

Additional context

No response

Validations

@Shinigami92 Shinigami92 added the Status: Review Needed Request for review comments label Aug 8, 2022
@Shinigami92
Copy link
Author

PS: interestingly it doesn't really throw a compile-time build error, but only shows in VS Code
So it doesn't hold us back from moving on developing 🙂

@kazupon
Copy link
Member

kazupon commented Aug 10, 2022

Thank you for your feedback.

The cause of this issue is due to the Legacy Style API (Options API) and Composition API support provided by vue-i18n.
When we first developed vue-i18n v9, we did not suppose that the $ prefixed global API types provided by these two styles would conflict.

Now, I think we can solve this issue by using conditional exports and specifying either style in the tsconfig.

related: #1025

@kazupon kazupon added Type: Bug Bug or Bug fixes Status: PR Welcome Welcome to Pull Request and removed Status: Review Needed Request for review comments labels Aug 10, 2022
@kazupon kazupon added ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf typescript and removed Status: PR Welcome Welcome to Pull Request labels Nov 15, 2022 — with Volta.net
@Sopamo
Copy link

Sopamo commented Dec 4, 2023

We're also running into this issue. The API is so much nicer if we can just pass in a string that we get from our API to $d(). It works, but we get a TS error every time. Is there an easy way to overload the method with string as an input type in TS?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf Type: Bug Bug or Bug fixes typescript
Projects
None yet
Development

No branches or pull requests

3 participants