0

This is my current tsconfig.json.

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "./dist"
  },
  "exclude": [
    "bower_components",
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

When I added typings entries under exclude, I get all kinds of build errors.

Error TS2304 Build: Cannot find name 'Zone'.

Error TS2305 Build: Module '".../wwwroot/node_modules/angular2/src/core/linker/interfaces"' has no exported member 'LIFECYCLE_HOOKS_VALUES'.

Error TS2339 Build: Property 'hostBoundary' does not exist on type 'Injector'.

Error TS2415 Build: Class 'MockDirectiveResolver' incorrectly extends base class 'DirectiveResolver'.

Error TS4058 Build: Return type of exported function has or is using name 'ComponentRef' from external module ".../wwwroot/node_modules/angular2/src/core/linker/dynamic_component_loader" but cannot be named.

What is the correct tsconfig setting for Angular2/Typescript?

Many of them are also coming from examples or testing folders. Can I just delete them?

UPDATE

This is what I have in my web project file.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
  <PropertyGroup Label="Globals">
    <ProjectGuid>3775534b-d08c-45f2-8d5a-4a4f6e91edb9</ProjectGuid>
    <RootNamespace>MyProject</RootNamespace>
    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
    <OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>
  <PropertyGroup>
    <SchemaVersion>2.0</SchemaVersion>
  </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
    <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
    <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
    <TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
    <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
    <TypeScriptOutFile />
    <TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
    <TypeScriptOutDir />
    <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
    <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
    <TypeScriptSourceMap>True</TypeScriptSourceMap>
    <TypeScriptMapRoot />
    <TypeScriptSourceRoot />
    <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
  </PropertyGroup>
  <Target Name="FixTsBuildConfiguration" BeforeTargets="CompileTypeScript" >
    <PropertyGroup>
      <TypeScriptBuildConfigurations>$(TypeScriptBuildConfigurations.Replace("--moduleResolution NodeJs", "--moduleResolution node"))</TypeScriptBuildConfigurations>
   </PropertyGroup>
  </Target>
  <ItemGroup>
    <DnxInvisibleContent Include="bower.json" />
    <DnxInvisibleContent Include=".bowerrc" />
    <DnxInvisibleContent Include="package.json" />
    <DnxInvisibleFolder Include="wwwroot\bower_components\" />
    <DnxInvisibleFolder Include="wwwroot\node_modules\" />
  </ItemGroup>
  <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

1 Answer 1

1

Adding this on the top of boot.ts will help to resolve some error:

/// <reference path="../node_modules/angular2/typings/browser.d.ts"/> 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. You're right, it resolved most of the errors. Now I'm left with duplicate identifier errors in a few locations: node_modules\angular2\typings, node_modules\angular2\typings\es6-collections and typings\browser\ambient\es6-shim. Should I add exclude entries for each one of these?
Just Can You share screen Shot of the errors so can get more in details what the exact error Is and in package.json please check angular version is updated "angular2": "2.0.0-beta.14",
I'd like to revisit this suggestion. Why is it necessary? It has not been included in the Angular2 quickstart. For many, it seems to work without having to add reference tag.
I think this provides an explanation regarding reference tags in Visual Studio 2015. blog.johnnyreilly.com/2015/02/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.