[英]export and import a Typescript Type alias from .d.ts file
I would like to have a file such as vue-number.d.ts
with a declaration along the lines of: 我想要一个像
vue-number.d.ts
这样的文件,并带有以下声明:
export type vueNumber = number | '';
and then be able to use the type alias across multiple typescript modules. 然后能够在多个打字稿模块之间使用类型别名。
If I use the above code, the import statement has 'vue-number.d.ts' is not a module
如果我使用上面的代码,则导入语句具有
'vue-number.d.ts' is not a module
How can I export and import a typescript type, which I can then use as if it was declared in the same module - ie let age: vueNumber = '';
如何导出和导入打字稿类型,然后可以像在同一模块中声明的那样使用它-即,
let age: vueNumber = '';
? ?
If you want to use a declaration file, then remove export
from vue-number.d.ts
: 如果要使用声明文件,请从
vue-number.d.ts
删除export
:
type vueNumber = number | '';
... and include the declaration file as a reference: ...并包括声明文件作为参考:
///<reference path="vue-number.d.ts"/>
let age: vueNumber = '';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.