Tag: typescript1.7

TypeScript并没有在VS 2015中将JavaScript与Node.js TS应用程序结合到单个文件中

如果我做错了,请纠正我,或者误解这里的任何概念。 据我所知,通过这个连接错误报告的固定状态( https://connect.microsoft.com/VisualStudio/feedback/details/1581065/typescript-compile-output-into-single-file-not-保存工作 ),您应该能够通过使用TypeScript项目的项目属性中的“将JavaScript输出合并到文件”选项将TypeScript输出编译为单个文件。 通过文件 – >新build项目 – > TypeScript – >“空Node.js Web应用程序”,Visual Studio 2015更新1社区版中一个全新的项目可以重现此问题,我运行TypeScript 1.7.6这是最新的写作,而不是这样做。 它仍然将.js文件并行输出到.ts文件。 我也尝试在该字段中input整个文件path,也尝试了一个完整的文件path到“redirectJavaScript输出到目录”选项也无济于事。 我希望能够做到这一点的原因,是因为我通过Grunt任务亚军开始我的Visual Studio外的TypeScript编译器。

在TypeScript中使用外部模块声明全局variables

我在TypeScript https://www.npmjs.com/package/html2commonmark中创build了一个npm模块。 该模块可用于nodejs(通过使用require )和浏览器(通过在浏览器中加载node_modules/html2commonmark/dist/client/bundle.js )。 我最近添加了* .d.ts文件,以便在使用"moduleResolution": "node"时input信息"moduleResolution": "node" 。 这很好,当安装我的模块,它已准备好在打字稿中使用。 因此:下面的一段打字稿代码正在编译没有错误: // After installing using npm install html2commonmark // using "moduleResolution": "node" import * as html2commonmark from 'html2commonmark'; let converter = new html2commonmark.JSDomConverter(); 美丽! 现在我想在浏览器中运行我的模块。 如前所述,我需要添加一个脚本标记到node_modules/html2commonmark/dist/client/bundle.js到我的index.html页面。 之后,html2commonmark全局variables应该可用。 问题是:我如何让打字稿编译知道全局variables在那里? 以下的TS代码将不会编译: let converter = new html2commonmark.BrowserConverter(); // error TS2304: Cannot find name 'html2commonmark'. 即使我添加一个global.d.ts文件,我似乎无法同时导入我的外部模块,并声明我的全局variables: // Something […]

打字稿:“无法find模块”有效打字

我刚刚开始使用打字机新的nodejs项目。 我安装了Typings( https://github.com/typings/typings ),并使用它来为节点v4.x安装参考文件,并且表示v4.x. 我的节点版本是v4.2.6我的打字版本是v1.7.5 我的项目目录是这样布置的: package.json tsconfig.json typings.json src/ app.ts typings/ main.d.ts main/ambient/node/node.d.ts main/ambient/express/express.d.ts typings / main.d.ts的内容如下: /// <reference path="main/ambient/express/express.d.ts" /> /// <reference path="main/ambient/node/node.d.ts" /> tsconfig.json的内容如下: { "compilerOptions": { "target": "es6", "module": "commonjs" } } typings.json的内容如下: { "dependencies": {}, "devDependencies": {}, "ambientDependencies": { "express": "github:DefinitelyTyped/DefinitelyTyped/express/express.d.ts#dd4626a4e23ce8d6d175e0fe8244a99771c8c3f2", "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#1c56e368e17bb28ca57577250624ca5bd561aa81" } } src / app.ts的内容如下: 'use strict'; […]