我如何使用TypeScript编译包含不同库(例如jquery,jquery-ui,其他第三方库)的文件 [英] How can i compile a file containing different libraries (e.g. jquery, jquery-ui, other 3rd party libs) with typescript

查看:256
本文介绍了我如何使用TypeScript编译包含不同库(例如jquery,jquery-ui,其他第三方库)的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个包含多个库(Jquery,jq-ui,fileupload插件和一些其他第三方插件)的项目中,我正在将项目转换为打字稿,但是为了使用这些库,我需要一个.d. ts文件包含在我的项目中,但是当我编译我的plugins.ts(只是从.js重命名为.ts)时,它给了我很多错误,并生成了一个.js文件,但没有.d.ts文件,因此我无法编译我的其他文件,因为我需要包含我的插件文件的引用

I am working on a project that contains multiple libraries (Jquery, jq-ui, fileupload plugins and some other 3rd party plugins) i am converting my project to typescript but in order to work with those libraries I need a .d.ts file to include in my project but when i compile my plugins.ts (just rename from .js to .ts) it give me a bunch of errors and generate a .js file but no .d.ts file and i cannot compile my other files as i need to include a reference of my plugin file

在tsc中是否有任何-force类型标志,或者它们是编译我的文件的一种方式.

is there any kind of -force type flag in tsc or is their a way to compile my file.

我使用此命令来编译我的ts文件 tsc --declaration bmkjqplugins.ts

I use this command to compile my ts file tsc --declaration bmkjqplugins.ts

推荐答案

在tsc中是否有任何-force类型标志,或者它们是编译我的文件的一种方式.

is there any kind of -force type flag in tsc or is their a way to compile my file.

不.您需要引用这些文件以确保完整的类型安全.也就是说:在出现TYPEONLY错误的情况下,打字稿 会生成有效的JavaScript.

No. You need to reference those files for complete type safety. That said : typescript will generate valid JavaScript in the presence of TYPEONLY errors.

注意:grunt-TS确实不支持类型错误: https ://github.com/TypeStrong/grunt-ts#grunt-ts-gruntfilejs-options

Note: grunt-TS does support not failing on type errors : https://github.com/TypeStrong/grunt-ts#grunt-ts-gruntfilejs-options

这篇关于我如何使用TypeScript编译包含不同库(例如jquery,jquery-ui,其他第三方库)的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆