4

Currently i'm converting old Angular 1 project from ES5 to TS. We choose approach to rename all legacy files to typescript, fix compilation errors and write new Angular 1 components using typescript. We are using grunt-ts for compilation. After successful compilation we clean all generated JS files using grunt job.

The problem: grunt-ts task finishes and after it karma test task starts. But for some reasons js files occur in source directory after grunt-ts finishes and karma task starts. That's why karma task fails because it can't find js spec files. I can't understand why generated by grunt-ts js files occurs in source directory a bit later.

Here is tsconfig file

{   "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "amd",
    "target": "es5",
    "noImplicitAny": false,
    "checkJs": false,
    "allowJs": true,
    "inlineSourceMap": true,
    "inlineSources": true,
    "removeComments": false,
    "types" : ["jasmine"],
    "lib": ["es2017", "dom"]   },   "include": [
     "src/**/*.ts"   ],   "exclude": [
     "node_modules",
     "dist",
     ".npmcache",
     "coverage",
     "dist",
     "docs",
     "grunt-build",
     "lib",
     "./",
     "typings",
     "modules",
     "target",
     "test"   ]

}

Here is grunt-ts tasks

grunt.initConfig({
    ts: {
        default: {
             // specifying tsconfig as a boolean will use the 'tsconfig.json' in same folder as Gruntfile.js
             tsconfig: true
        },
        comileSources: {
            src: ["src/sources/**/*.ts"],
            reference: 'referencesSources.ts',
            tsconfig: true,
            out:'target/sources/sources.js',

        },
        spec: {
            reference: 'referencesSpecs.ts',
            src: ["referencesSpecs.ts", "test/spec/sources/**/*.ts"],
            tsconfig: true
        } }
James Z
  • 12,209
  • 10
  • 24
  • 44
VladosJS
  • 1,210
  • 8
  • 20

0 Answers0