TypeStrong / grunt-ts

A grunt task to manage your complete typescript development to production workflow
https://www.npmjs.com/package/grunt-ts
MIT License
330 stars 121 forks source link

baseUrl not passed to tsc correctly when using "." in tsconfig.json #426

Closed beyerleinf closed 6 years ago

beyerleinf commented 6 years ago

I've encountered the following issue today. When I have baseUrl set to "." in my tsconfig.json, grunt-ts doesn't pass it to tsc correctly resulting in tsc wanting to look for es2017.ts in my case.

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "rootDir": "backend",
    "outDir": "dist",
    "baseUrl": ".",
    "lib": [
      "es2017"
    ],
    "experimentalDecorators": true,
    "sourceMap": false,
    "paths": {
      ...
    }
  },
  "include": [
    "backend/**/*.ts"
  ],
  "exclude": [
    "backend/**/*.spec.ts",
    "node_modules",
    "dist"
  ]
}

grunt-ts config

ts: {
  backend: {tsconfig: './tsconfig.json', options: {fast: 'always', verbose: true}},
}

verbose output

Running "ts:backend" (ts) taskCompiling...
### Fast Compile >>backend/...
.....
Using tsc v2.9.2
<all TS files> --removeComments --experimentalDecorators --moduleResolution node --rootDir backend --baseUrl  --lib es2017,es2016 --target ES6 --module commonjs --outDir dist
error TS6053: File 'es2017.ts' not found.

>> 1 non-emit-preventing type warning
>> Error: tsc return code: 2
Warning: Task "ts:backend" failed. Use --force to continue.

Aborted due to warnings.

As you can see, instead of insertig the "." after --baseUrl it inserts a space. "./" has the same effect.

Stono commented 6 years ago

I think I'm getting burned by this too.... error TS6053: File 'es6.ts' not found. . Do you have any workaround @beyerleinf

lib/commands/deployments/create/index.ts lib/commands/deployments/index.ts lib/commands/deployments/list/index.ts lib/commands/index.ts lib/deploymentNotifier/index.ts lib/deploymentNotifier/targets/lighthouse.ts lib/dockerExecutor/helm/index.ts lib/dockerExecutor/helm/release.ts lib/dockerExecutor/index.ts lib/gcloudAuth.ts lib/helmfile.ts lib/index.ts lib/kms/index.ts lib/kms/providers/gcp.ts lib/systemExecutor/index.ts lib/systemExecutor/result.ts lib/util.ts lib/wiring.ts bin/shippr.ts --removeComments --rootDir ./ --allowJs --checkJs --alwaysStrict --noImplicitThis --strictFunctionTypes --strictPropertyInitialization --strictNullChecks --baseUrl  --lib es6 --target ES6 --module commonjs --outDir built
nycdotnet commented 6 years ago

I'm sorry I don't have any time to work on this, but if you want to look into it, I would recommend looking here https://github.com/TypeStrong/grunt-ts/blob/master/tasks/modules/compile.ts#L377 or at the utils.possiblyQuotedRelativePath function which is in the utils.ts file. PRs definitely accepted.

beyerleinf commented 6 years ago

@nycdotnet I'll see what I can do. I'm glad to help :)

nycdotnet commented 6 years ago

This should be fixed in v6.0.0-beta.21. Thank you so much for the report and PR @beyerleinf , and also @Stono .

Stono commented 6 years ago

Awesome, thanks @beyerleinf