-
-
Notifications
You must be signed in to change notification settings - Fork 552
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
Typescript 声明类型时似乎未能得到完整支持? #40
Comments
如果是在 nodejs 环境下倒是可以用
这种方式声明,不过这样它就附带了个 globalThis 的前缀,会降低代码的移植性。请问是否有更合适的使用方式? |
@fjqingyou 我测试下来没有问题呢。 没有默认到出方法,需要下面方式导入包? import data from 'province-city-china'
import dataCity from 'province-city-china/dist/city.json' |
通过调用推导类型是正常的可以得到目标类型的。 不过如果不是赋值形式,而是声明某个变量是什么类型的变量时。 例如: 只声明一个变量以及它的类型,但是具体的值还未确定,需要后续逻辑进一步计算才能得到真正的值。 那么它就不属于推导性质可知的类型,而 ProvinceCityChina.Province 这个类型是未导出的! |
@fjqingyou Upgrade import { City } from 'province-city-china'
import type ProvinceCityChina from '@province-city-china/types'
const data: Partial<City> = { code: '12', name: 'dsfsdf'}
const dt: Partial<ProvinceCityChina.Area> = {} |
@fjqingyou Upgrade v8.5.4, 找到原因了,修复了。 |
已经按预期工作,感谢! |
@jaywcjlove 似乎 Country 类型的并未被导出? |
@fjqingyou Upgrade |
@jaywcjlove 它正常工作了!感谢! |
请问是否我的用法有误?
The text was updated successfully, but these errors were encountered: