Skip to content
This repository was archived by the owner on Oct 2, 2022. It is now read-only.
This repository was archived by the owner on Oct 2, 2022. It is now read-only.

Misleading TypeScriptCompileError when user's tsconfig.json "module" is set to "es2015" #155

Open
@hasparus

Description

@hasparus

Description

I'm using auto (pretty cool tool) with .config.ts and I get a crash with following error.

$ /home/hasparus/workspace/theme-ui/node_modules/.bin/auto info
TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
    at Function.TypeScriptCompileError.fromError (/home/hasparus/workspace/theme-ui/node_modules/@endemolshinegroup/cosmiconfig-typescript-loader/src/Errors/TypeScriptCompileError.ts:20:12)
    at /home/hasparus/workspace/theme-ui/node_modules/@endemolshinegroup/cosmiconfig-typescript-loader/dist/index.js:21:48
    at Generator.next (<anonymous>)

What went wrong?

  1. ts-node/register finds my tsconfig which isn't configured for Node
  2. cosmiconfig-typescript-loader requires the config
  3. ts-node compiles the config successfuly
  4. Node crashes on export — the error is a bit misleading

What did you expect should have happened?

What was the config you used?

This one, but I'm not sure if it matters
import { AutoRc } from '@auto-it/core'

import { INpmConfig } from '@auto-it/npm'
import { IAllContributorsPluginOptions } from '@auto-it/all-contributors'

const npmOptions: INpmConfig = {
  exact: true,
}

const allContributorsOptions: IAllContributorsPluginOptions = {
  exclude: ['dependabot', 'dependabot-preview'],
  types: {
    infra: ['./github/**/*'],
    example: ['examples/**/*'],
    doc: ['**/*.mdx', '**/*.md', 'packages/docs/**/*'],
    test: ['**/*.test.*', '**/*.spec.*'],
    code: [
      'packages/**/*.js',
      'packages/**/*.ts',
      'packages/**/*.jsx',
      'packages/**/*.tsx',
      '**/package.json',
      '**/tsconfig.json',
    ],
  },
}

export default function config(): AutoRc {
  return {
    baseBranch: 'stable',
    prereleaseBranches: ['develop'],
    plugins: [
      ['npm', npmOptions],
      'conventional-commits',
      'first-time-contributor',
      'released',
      ['all-contributors', allContributorsOptions],
    ],
  }
}

What stacktrace or error messages did you see?

Stack Trace:
$ /home/hasparus/workspace/theme-ui/node_modules/.bin/auto info
TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
    at Function.TypeScriptCompileError.fromError (/home/hasparus/workspace/theme-ui/node_modules/@endemolshinegroup/cosmiconfig-typescript-loader/src/Errors/TypeScriptCompileError.ts:20:12)
    at /home/hasparus/workspace/theme-ui/node_modules/@endemolshinegroup/cosmiconfig-typescript-loader/dist/index.js:21:48
    at Generator.next (<anonymous>)

Similar or dependent issues:

Additional Data

Version of cosmiconfig-typescript-loader you're using: 3.0.2

Node Version: 14.15.3

Operating System: Pop!_OS 20.04 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions