在本文中,您将会了解到关于angular–如何在VisualStudio2015中为Typescript添加打字输入到typings.json?的新资讯,同时我们还将为您解释vs2019angular
在本文中,您将会了解到关于angular – 如何在Visual Studio 2015中为Typescript添加打字输入到typings.json?的新资讯,同时我们还将为您解释vs2019 angular的相关在本文中,我们将带你探索angular – 如何在Visual Studio 2015中为Typescript添加打字输入到typings.json?的奥秘,分析vs2019 angular的特点,并给出一些关于angular – 如何在Visual Studio 2015中从非相对路径导入模块、angular – 将Ionic 2迁移到Typescript 2.0 RC、angular – 由typescript导入的代码的Typescript类型?、angularjs – Visual Studio 2015显示’调试正在启动’的实用技巧。
本文目录一览:- angular – 如何在Visual Studio 2015中为Typescript添加打字输入到typings.json?(vs2019 angular)
- angular – 如何在Visual Studio 2015中从非相对路径导入模块
- angular – 将Ionic 2迁移到Typescript 2.0 RC
- angular – 由typescript导入的代码的Typescript类型?
- angularjs – Visual Studio 2015显示’调试正在启动’
angular – 如何在Visual Studio 2015中为Typescript添加打字输入到typings.json?(vs2019 angular)
这是我的package.json文件中的脚本:
"scripts": { "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ","tsc": "tsc","tsc:w": "tsc -w","lite": "lite-server","typings": "typings","postinstall": "typings install" }
这是我试过的typings.json文件。 es6-shim和jasmine已下载。
{ "ambientDependencies": { "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd","jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd","jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd" }}
这可能是一些简单的事情,比如没有标签之后的校验和。我在哪里可以找到正确的校验和,或者我需要在package.json中添加什么命令来检索编译时的输入,或者我做错了什么?
Here’s another example在typings.json文件中添加一行,然后为你安装d.ts文件。向下滚动,直到看到手动打字
>打开您选择的控制台(例如命令提示符或powershell)
>导航到项目文件夹
仅使用npm(TypeScript 2及更高版本):
> npm install –save @ types / jquery
完成:有关详细信息,请参阅this。
使用typings(v.2之前的Typescript):
>确保安装了typings,如果没有安装npm install typings –global
>写入类型安装dt~jquery –save –global
这应该更新您的typings.json文件并下载定义文件。
在上面的类型示例中,’dt~’表示它应该在DefinitelyTyped存储库中查找jquery,默认为’npm’。语法从版本0.x略微改变为1.0,标志–global以前是 – 框架。
angular – 如何在Visual Studio 2015中从非相对路径导入模块
我从 here获得了Visual Studio 2015 QuickStart.
> tsc版本:2.5.2
我的项目结构:
src └──angular └──common └──models └──items.ts └──ui └──components └──items.component.ts
items.ts
export module items { export const listofItems = [1,2,3]; }
我想在导入我的src文件夹中的所有内容时使用非相对路径,即:
items.component.ts
import { items } from 'items';
这是我的tsconfig.json文件(与src处于同一级别):
{ "compileOnSave": false,"compilerOptions": { "target": "es5","module": "commonjs","moduleResolution": "node","sourceMap": true,"emitDecoratorMetadata": true,"experimentalDecorators": true,"lib": [ "es2015","dom" ],"noImplicitAny": true,"suppressImplicitAnyIndexErrors": true,"typeRoots": [ "node_modules/@types/" ] } }
在这里,我尝试将其添加到compilerOptions中:
"baseUrl": "." //it doesn't help.
之后:
"baseUrl": ".","paths": { "*": [ "*","src/agnular/*" // still nothing. ] }
我还添加了rootDirs,但我仍然收到此错误:
Cannot find module 'items'
tsconfig.json:
{ "compileOnSave": false,"compilerOptions": { "baseUrl": "./src","paths": { "@models/*": [ "angular/common/models/*" ] } //.. } }
用法:
import { items } from '@models/items';
那么,这里发生了什么:
*指向我们文件的实际名称,因此在我们的情况下,在@models之后有*指向项目,而项目在angular / common / models / *内.
另外,我们应该将它添加到systemjs.config.js中,以便可以解析路径:
System.config({ paths: { // paths serve as alias 'npm:': 'node_modules/',"@models/*": ["rootdist/angular/common/models/*"] ^ where you keep your files,for example dist/ } // other things.. });
另一个重要的事情是重新启动视觉工作室
我也试过卸载/重新加载项目,但这没有用.
angular – 将Ionic 2迁移到Typescript 2.0 RC
这是我得到的错误:
TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(150,30): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(167,24): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(173,55): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-axis/index.d.ts(191,24): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-brush/index.d.ts(30,37): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(38,56): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(39,25): Error TS1110: Type expected. TypeScript error: /Users/arash1/Projects/brite-front-end/node_modules/@types/d3-chord/index.d.ts(41,59): Error TS1110: Type expected.
我查看了我的主IONIC目录中的package.json文件,并没有看到一个打字稿作为依赖项,所以我认为它正在使用其他东西来定义版本.我知道了:
>“ionic-gulp-browserify-typescript”:“2.0.0”
>“tslint-ionic-rules”:“^ 0.0.3”
>“tsify”:“0.16.0”
所以我进入了tslint-ionic-rules并看到:
"devDependencies": { "typescript": "^1.8.10" }
只是为了尝试我运行npm install typescript @ rc在tslint-ionic-rules node_modules中安装新版本,看看我是否得到了同样的错误.错误仍然存在.
有人可以就如何这样做提供指导吗? RC最近于MFST Blog宣布.
解决方法
确切地说,我没有在我的gulp.file中使用lint,但我注意到ionic2使用了browserify,当你查看ionic-gulp-browserify-typescript模块时,你可以看到:
tsifyOptions:{}
您可以使用它来设置您要使用的TS版本.
例:
>在本地安装typescript 2.x.
>在构建任务中添加tsifyOptions:{}
它应该看起来像这样:
gulp.task('build',['clean'],function(done){ runSequence( ['sass','html','fonts','scripts'],function(){ buildbrowserify({ minify: isRelease,browserifyOptions: { debug: !isRelease },uglifyOptions: { mangle: false },tsifyOptions: { typescript: require('your typescript') } }).on('end',done); } ); });
angular – 由typescript导入的代码的Typescript类型?
我正在开发一个Angular 7应用程序,我正在使用一些库,这些库是通过前端的脚本标签从其他来源(Stripe,recaptcha,googletags等)导入的.我将在这里使用Stripe作为示例,因为Stripe绝对要求客户端从Stripe.js导入前端库以实现PCI兼容性,因此从源服务器端不是一个选项.
我已经从DefinitelyTyped安装了Stripe的类型.如果我添加声明让Stripe:any;并且在组件中使用Stripe,它可以工作,但当然它不是类型安全的.如果我省略声明,VSCode发现类型很好,编辑器捕获类型错误,但它不会编译,(错误TS2304:找不到名称’Stripe’.)可能因为我没有Stripe的import语句.
有没有办法提示TypeScript它应该使用DefinitelyTyped中的类型来捕获类型错误,而不导入Stripe库本身?
编辑:我收回我所说的关于不认为这是Angular特定的内容.我现在认为这可能与角度编译过程有关.
解决方法
所以,我所做的是,我将Type DeFinition文件(通常是index.d.ts)复制到我的代码库中.
之后,您可以执行以下操作:
import {SomeType} from "sometype.d.ts" declare let ObjectImportedFromHTMLScriptTag: SomeType;
然后,您可以使用导入的对象而不会破坏类型安全性.
angularjs – Visual Studio 2015显示’调试正在启动’
解决方法
>您可以尝试运行您的项目而无需调试,但您可以
将调试器附加到您的应用程序
我们今天的关于angular – 如何在Visual Studio 2015中为Typescript添加打字输入到typings.json?和vs2019 angular的分享已经告一段落,感谢您的关注,如果您想了解更多关于angular – 如何在Visual Studio 2015中从非相对路径导入模块、angular – 将Ionic 2迁移到Typescript 2.0 RC、angular – 由typescript导入的代码的Typescript类型?、angularjs – Visual Studio 2015显示’调试正在启动’的相关信息,请在本站查询。
本文标签: