Skip to content
This repository has been 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 opened this issue Apr 15, 2021 · 0 comments · May be fixed by #156
Open

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

hasparus opened this issue Apr 15, 2021 · 0 comments · May be fixed by #156

Comments

@hasparus
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant