typescript-formatter
typescript-formatter copied to clipboard
bug: tsfmt ignores extends in tsconfig
when running tsfmt --verify
within project it ignores extends
within tsconfig.json, so user has to specify all file paths manually within terminal which is very inconvenient
That was quick! Arigatou gozaimasu ! 🍻
can you release pls?
wait a moment. I'll ship it in 3 hours.
just released v4.2.0 and v5.0.0 😉
unfortunately it doesn't work. pls reopen
tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "typings"
}
}
Error:
tsfmt --verify
Error: [object Object]
at makeFormatCodeOptions (/Users/hotell/Devel/github/Hotell/typescript-lib-starter/node_modules/typescript-formatter/lib/provider/tsconfigjson.ts:38:15)
at next (/Users/hotell/Devel/github/Hotell/typescript-lib-starter/node_modules/typescript-formatter/lib/index.ts:52:23)
at /Users/hotell/Devel/github/Hotell/typescript-lib-starter/node_modules/typescript-formatter/lib/index.ts:53:64
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
I'm working on https://github.com/vvakame/typescript-formatter/tree/fix-extends-tsconfig branch. Since there is no working time, it may be a little late to fix it.
sure, no worries, thx!
just released v5.0.1. please check it! this issue is solved my local env.
still doesn't work. Although I managed to make it work with slightly different config.
This doesn't work:
tsconfig.base.json
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
"target": "es5",
"lib": [
"es2015",
"dom"
],
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"pretty": true,
"jsx": "react",
"sourceMap": true,
"outDir": "lib"
},
"files": [
"./src/index.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "typings"
}
}
This does:
tsconfig.base.json
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
"target": "es5",
"lib": [
"es2015",
"dom"
],
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"pretty": true,
"jsx": "react",
"sourceMap": true,
"outDir": "lib"
},
"include": [
"./src"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "typings"
}
}
Solution
I had to use include
instead of files
in tsconfig.base.json
-> TSFMT v 5.0.1
umm.. I tried with your settings. But it is works. Now, tsfmt is using to parse tsconfig.json by typescript package. What version of tsc do you use? https://github.com/vvakame/typescript-formatter/blob/d688317d828f1a6363cf28bf6ad628586ea254ea/lib/utils.ts#L41-L61
$ tsfmt -v
5.0.1
$ tsc -v
Version 2.2.1
$ tsfmt --verify --verbose
read: /private/tmp/tsfmt-issue77/tsconfig.json
replace: OFF
verify: ON
baseDir: /private/tmp/tsfmt-issue77
stdin: OFF
files from tsconfig: ON
tsconfig: ON
tslint: ON
editorconfig: ON
vscode: ON
tsfmt: ON
read /private/tmp/tsfmt-issue77/tsconfig.json for /private/tmp/tsfmt-issue77/./src/index.ts
/private/tmp/tsfmt-issue77/./src/index.ts is not formatted
$ cat src/index.ts 1 ↵
class Sample{}
$ cat tsconfig.base.json
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
"target": "es5",
"lib": [
"es2015",
"dom"
],
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"pretty": true,
"jsx": "react",
"sourceMap": true,
"outDir": "lib"
},
"files": [
"./src/index.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
$ cat tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "typings"
}
}
@vvakame I think I ran into the same issue that @Hotell reported. It's true that if a file is listed directly in files
, tsfmt
will check it. However, tsfmt
doesn't check the modules that those files import. So if I have this in my tsconfig.json
:
{
"files": [
"./ts/main.ts"
]
}
And main.ts
contains this:
import { foo } from './module.ts';
foo();
tsfmt
won't format module.ts
. Or at least, I can't get it to work.