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

类型声明文件 #2

Open
xiaochengzi6 opened this issue Oct 7, 2022 · 1 comment
Open

类型声明文件 #2

xiaochengzi6 opened this issue Oct 7, 2022 · 1 comment

Comments

@xiaochengzi6
Copy link
Owner

declare 声明一个全局变量 比如 window 那种

为了解决找不到全局变量名的问题 例如:$(jqure) 一般可以使用 xx.d.ts 类型声明文件 通过这个文件来声明一些全局变量

在 ts 文件导入 import style from 'xx.css' ts 编译器会抛错这个时候就要使用类型申明文件了

// index.ts
impport css from './style/file.css'

// xx.d.ts
declare module "*.css" {
  const css: string;
  export default css
}

详细的

@xiaochengzi6 xiaochengzi6 changed the title declate 类型声明文件 May 27, 2023
@xiaochengzi6
Copy link
Owner Author

关于这方面的具体介绍查看这个网址

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

No branches or pull requests

1 participant