bigtest icon indicating copy to clipboard operation
bigtest copied to clipboard

typescript errors about missing tsconfig.json are printed to the console in non-typescript projects

Open cowboyd opened this issue 4 years ago • 12 comments

When integrating the bigtest runner into the stripes-components project, the bundler threw this error out to the console:

rpt2: config error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.

The project is in vanilla javascript and not typescript, so that's probably related. However, even though it prints this error, the tests to run properly.

Here is the full project.https://github.com/cowboyd/stripes-components/tree/integrate-bigtest

cowboyd avatar Nov 17 '20 22:11 cowboyd

There is no error ;)

jnicklas avatar Nov 18 '20 14:11 jnicklas

@jnicklas 😹 ok, thanks for that.... comment updated.

cowboyd avatar Nov 18 '20 15:11 cowboyd

it is an error coming from the rollup-plugin-typescript2 which is why it is prefixed with rpt2.

It is because there is no tsconfig.json and nowhere in the rollup config do we specify include or exclude fields that tsc uses to know where to look for or avoid typescript files.

I think we need to update our defaults to:

export declare function defaultTSConfig(): {
compilerOptions: {
    skipLibCheck: boolean;
    target: string;
    lib: string[];
    include: [
        "nowhere/**/*.ts",
      ],
    };
};

dagda1 avatar Nov 18 '20 18:11 dagda1

@dagda1 That seems to change it to:

rpt2: config error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["nowhere/**/*.ts"]' and 'exclude' paths were '[]'.

cowboyd avatar Nov 18 '20 18:11 cowboyd

@cowboyd oh right so the error is that it cannot find any typescript files.

I wanted to avoid us deciding if it is a typescript or javascript project

dagda1 avatar Nov 18 '20 18:11 dagda1

stdout or stderr from here.

dagda1 avatar Nov 18 '20 19:11 dagda1

a couple of things we could do is:

const isTypescript = fs.existsSync(process.cwd(), 'tsconfig.json);

Not sure if we can guarantee that but might be fine

The error message is just a console.something and not an actual error so we could suppress it somehow.

dagda1 avatar Nov 18 '20 21:11 dagda1

if it is typescript, we either disable the plugin or do not add it to the plugins array

dagda1 avatar Nov 18 '20 21:11 dagda1

Whether or not tsconfig is present is a known propert of BigTest.json so theoretically this is possible

cowboyd avatar Nov 19 '20 00:11 cowboyd

@jnicklas @dagda1 I went down the same rabbit hole to try and get rid of the warning. I see that the orchestrator invokes createManifestBuilder:

yield fork(createManifestServer({
  atom: options.atom,
  dir: manifestDistDir,
  port: options.project.manifest.port,
  proxyPort: options.project.proxy.port,
}));

And the manifest-builder creates the Bundler:

export function* createManifestBuilder(options: ManifestBuilderOptions): Operation {
  let bundlerSlice = options.atom.slice('bundler');
  bundlerSlice.set({ type: 'UNBUNDLED' });
  
  let bundler: Bundler = yield Bundler.create({
    watch: options.watch,
    entry: options.srcPath,
    globalName: bigtestGlobals.manifestProperty,
    outFile: path.join(options.buildDir, "manifest.js"),
    tsconfig: options.tsconfig,
  });
  
  // ...
};

I don't understand at which point the options object is modified to include tsconfig.

Edit: Oh that's what #803 is for.

minkimcello avatar Feb 03 '21 16:02 minkimcello

@minkimcello this is different than #803. this is when there are no typescript files, i.e it is a javascript project but the rollup tyoescript2 plugin is still included in the rollout plugins array.

no inputs means no files to transpile, it comes from tsc.

ideally we would not include that plug-in if we are dealing with javascript only but it is not entirely clear cut when it is.

dagda1 avatar Feb 03 '21 21:02 dagda1

I actually just opened #959, but it seems related to this.

jbolda avatar Jul 30 '21 16:07 jbolda