如何编写实现此TypeScript接口的类(并保持TypeScript编译器满意):
interface MyInterface {
(): string;
text2(content: string);
}
Run Code Online (Sandbox Code Playgroud)
我看到了这个相关的答案: 如何让一个类在Typescript中实现一个调用签名?
但这仅在接口仅具有裸功能签名时才有效.如果要实现其他成员(例如函数text2),它将不起作用.
我可以在运行时获得所有已注册模块的列表吗?
例如:
// Some code somewhere in some .js file
var module1 = angular.module('module1', []);
// Some code in some other .js file
var module2 = angular.module('module2', []);
// Main .js file
var arrayWithNamesOfAllRegisteredModules = .....
// (result would be: ['module1', 'module2'])
Run Code Online (Sandbox Code Playgroud) 我是一个团队的一员,拥有大约6个UI开发人员,质量各异,而且没有Angular经验.许多人是承包商,对代码库的经验很少.该应用程序具有非常花哨(复杂)的UI.它支持IE8 +(很快就希望IE9 +).
我们引入了Angular作为应用程序的主要扩展,我被要求为团队编写Angular使用指南.
我们将使用指令来创建花哨的UI元素,所有元素都以"ipwr"为前缀,以避免名称冲突.我正在试图决定是否要求开发者给他们的指令限制"元素"或"属性".只限一个,以避免混乱和混乱.
我的问题是:对于指令,"元素"或"属性",哪些限制更好或更受欢迎?我主要担心的是对于具有少量Angular经验且对应用程序代码库不熟悉,减少错误,复制和粘贴行为等的人的易用性.
我在Bower注册我的bower.json文件时遇到了麻烦.任何帮助将不胜感激.
当我尝试在Bower注册我的项目时
bower register jsnlog git://github.com/mperdeck/jsnlog.js.git -V
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
bower jsnlog#* EMALFORMED Failed to read C:\Users\mperdeck\AppData\Local\Temp\mperdeck-PC-mperdeck\bower\js
nlog-6944-x00dtF\bower.json
Additional error details:
Unexpected token ?
Run Code Online (Sandbox Code Playgroud)
我的bower.json的内容很简单(为了解决问题,我摆脱了空格和换行符):
{"name":"jsnlog.js","main":"jsnlog.js","version":"2.4.3"}
Run Code Online (Sandbox Code Playgroud)
(请注意,该文件中没有?)
以下是我运行bower寄存器时屏幕上显示的详细信息:
PS D:\dev\jsnlog\jsnlog.js> bower register jsnlog git://github.com/mperdeck/jsnlog.js.git -V
bower jsnlog#* resolve git://github.com/mperdeck/jsnlog.js.git#*
bower jsnlog#* download https://github.com/mperdeck/jsnlog.js/archive/2.4.3.tar.gz
bower jsnlog#* extract archive.tar.gz
bower jsnlog#* EMALFORMED Failed to read C:\Users\mperdeck\AppData\Local\Temp\mperdeck-PC-mperdeck\bower\js
nlog-6944-x00dtF\bower.json
Additional error details:
Unexpected token ?
Stack trace:
SyntaxError: Unexpected token ?
at Object.parse (native)
at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\bower-json\lib\json.js:41:29
at fs.js:266:14
at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\graceful-fs\graceful-fs.js:105:5
at Object.oncomplete (fs.js:107:15)
Console trace:
Trace …Run Code Online (Sandbox Code Playgroud) 我的5个开发团队维护着一个由6个解决方案(又称部分)组成的中型应用程序.目前,我们使用TFVC进行源代码控制.每个解决方案都位于自己的主分支中.
我想迁移到Git.我的问题是,对于所有6个解决方案是否有1个Git仓库,或者为每个解决方案使用单独的Git仓库.
我被一个单一的Git仓库所吸引,因为:
另一方面,单个Git仓库意味着对任何解决方案的更改都会导致我们的TeamCity CI服务器上的所有解决方案的新的完全重建.
在此问题上寻找其他团队负责人的一些见解.
当我对我的测试项目运行dotnet测试时,我收到错误消息
No test is available in ......dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
我正在使用此命令行:
dotnet test platform\Decideware.Platform.Tests\Decideware.Platform.Tests.csproj --configuration Release --framework net47 --no-restore --no-build
我的项目以net47为目标.它使用NUnit 2.6.4(它是最近转换的遗留项目).
我正在导入我认为我需要的所有包:
<PackageReference Include="NUnit" Version="2.6.*" />
<PackageReference Include="NUnitTestAdapter" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.*" />
我怎样才能让我的测试运行?
我在 API 中使用 JWT 令牌。为了使这项工作成功,在我的ConfigureServices课堂上,我打电话services.AddAuthentication(...),然后AddJwtBearer(...)。
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
//...
})
.AddJwtBearer(o =>
{
...
o.Events = new JwtBearerEvents
{
OnAuthenticationFailed = context =>
{
//...
//Log error <<<< how do I use dependency injected logger here?
}
};
});
}
Run Code Online (Sandbox Code Playgroud)
我想在事件发生时写入日志条目OnAuthenticationFailed。但是,我必须从ServiceProvider. 而这在方法中尚不可用ConfigureServices。
另一方面,当OnAuthenticationFailed事件处理程序实际运行时(如果有的话),它将ServiceProvider可用。
如何访问处理程序ServiceProvider内部OnAuthenticationFailed?
我一直在使用Jasmine编写JavaScript单元测试.但是,这些测试在浏览器中运行,而不是作为MSTest的一部分.
我希望我的TFS持续集成版本在JavaScript单元测试失败时中断.我知道在Visual Studio 2012中有一个解决方案,但我在2010年(可能在未来很长一段时间).
有没有一种简单的方法可以将基于Jasmine的JavaScript单元测试与TFS Build集成?
我有一个生成 React 组件的简单模块:
// index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
....
ReactDOM.render(......);
Run Code Online (Sandbox Code Playgroud)
react 和 react-dom 位于 node_modules\@types 目录中。
我使用 TypeScript 编译器将其编译为 .js 文件。该 .js 文件包含一个模块(因为导入)。我将其加载到 .html 页面中:
<script type="module" src="./js/Views/Home/index.js"></script>
Run Code Online (Sandbox Code Playgroud)
这会编译,我得到智能感知和类型检查。但是 Chrome(版本 66)现在在控制台中抛出一个错误,说
(index):1 Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".
Run Code Online (Sandbox Code Playgroud)
我尝试了这些选项:
1) 环境变量
// this works for both compiler and browser, but doesn't give me type checking or intellisense
declare var …Run Code Online (Sandbox Code Playgroud) 我对 Azure、Pipelines 等完全陌生。
我正在尝试创建一个由网站和 WebJob(定期运行的后台作业)组成的应用服务。我想使用用 Yaml 文件编码的管道来构建和部署它。
我使用一个非常简单的 ASP.Net Core 网站(项目“pipelines-dotnet-core”)和一个简单的 .Net Core 控制台程序(项目“WebJobsSDKSample”)创建了一个 Visual Studio 解决方案。
我创建了 Yaml 文件来构建、发布网站并将其部署到我的应用服务。这工作正常,我可以在浏览器中打开该站点。
然后我扩展 Yaml 文件以将控制台程序项目的输出文件夹复制到网站的发布文件夹,将结果压缩为 zip 文件并部署该 zip 文件。我知道我必须将控制台程序项目输出文件夹复制到网站发布文件夹下的/App_Data/jobs/triggered/app。
这个新管道运行良好,并且网站仍然可以正确部署。但是,当我打开应用服务的 WebJobs 页面时,它显示“您尚未添加任何 WebJobs”。
我的 Yaml 文件的内容如下。我需要更改什么才能正确部署 WebJob?
此外,如果您能向我指出如何在 Yaml 管道文件中编写 WebJob 的清晰示例,那将非常有帮助。
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration)'
zipAfterPublish: false
- task: CopyFiles@2
displayName: 'Copy Console App …Run Code Online (Sandbox Code Playgroud)