3
votes

hi I am using PrimeNg datatable and it seems to be failing the build on teamcity. below is the error

(CompileTypeScriptWithTSConfig target) -> node_modules\primeng\components\datatable\datatable.d.ts(180,14): error TS1005: Build: '=' expected. node_modules\primeng\components\datatable\datatable.d.ts(180,25): error TS1005: Build: ';' expected.

any idea why Visual Studio Compilation is failing. it seems there is some issue with Typings, do I need to manually fix this in this file?

some lines before these lines are

PreComputeCompileTypeScriptWithTSConfig:

[13:34:52][Step 1/1] C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "E:\buildagent\work\2be75659b1819119\src\MyProject.Client\e2e\tsconfig.json"

[13:34:52][Step 1/1] C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "E:\buildagent\work\2be75659b1819119\src\MyProject.Client\src\tsconfig.json"

[13:34:52][Step 1/1] CompileTypeScriptWithTSConfig: [13:34:52][Step 1/1] C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "E:\buildagent\work\2be75659b1819119\src\MyProject.Client\e2e\tsconfig.json"

[13:34:54][Step 1/1] C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "E:\buildagent\work\2be75659b1819119\src\MyProject.Client\src\tsconfig.json"

my tsconfig is below

{
  "compileOnSave": false,
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "mapRoot": "/",
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../dist/",
    "rootDir": ".",
    "sourceMap": true,
    "target": "es5",
    "inlineSources": true
  },

  "files": [
    "main.ts",
    "typings.d.ts"
  ],
  "exclude": [
    "../node_modules/*",
    "typings",
    "**/*-aot.ts"
  ]

}

why is it not ignoring node_modules compilation

2
First of all, which version of PrimeNg are you using? Secondly, show us yours tsconfig and compiling task to be sure which TypeScript files you are transpiling. - be4code
i am using "primeng": "^1.0.0" - Kamran Pervaiz
I think the issue is tsc is trying to compile node_modules files I cant seem to ignore this folder. - Kamran Pervaiz

2 Answers

2
votes

I have managed to fix it, it seems Tyescript 1.8 has bug excluding node_modules.

I upgraded Typescript to 2.1 and changed below from 1.8 to 2.1

<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>

It seemed to fix the problem and ignored node_modules typescript files. I am not sure how to tell VS not to compile Typescript files that would be another solution.

0
votes

If you want to ignore TypeScript automatic compilation by VS, rename the tsconfig.json to something like tsconfig.jsonx. Then in your gulp script (or preferred build env) use the renamed file.

When you have tsconfig.json in your VS csproj, please check out the properties. You will find that VS auto detects it under "TypeScript Build" section.

In my gulp script, I use the new ts configuration file as:

var tsProject = ts.createProject('tsconfig.jsonx');

// compile ts files and put it in dist
gulp.task('compile', ['clean'], function () {
    return tsProject.src()
        .pipe(tsProject())
        .js.pipe(gulp.dest("dist/app"));
});

Kinda hack, but one way to avoid MS Build, if you need so