Skip to content

Throws TypeError: commitlint.config.ts: Emit skipped #1593

Closed

Description

@iamarpitpatidar

I am using commitlint which is using ts-node as a dep. Now somehow whenever I try to commit ts-node throws error TypeScriptCompileError Emit Skipped which is weird coz I compiled the project with tsc and it compiled succesfully.
I even tried it with just one file containing console.log please check the linked github repo

Search Terms

Emit Skipped
commitlint

Actual Behavior

Edit: just found that even after settings the rootdir in tsconfig ts-node still includes files outside from src directory, I think its a bug but I'm not sure.

Expected Behavior

should not throw compile error and emit skipped.
Must not include files outside of rootdir

Steps to reproduce the problem

yarn install
git add .
git commit -m "test: added a test"

Minimal reproduction

https://github.com/iamarpitpatidar/ts-node-bug

Specifications

  • ts-node version: v10.4.0
  • node version: v16.13.1
  • TypeScript version: v4.5.4
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "outDir": "./dist",
    "rootDir": "./src",
    "moduleResolution": "Node",
    "lib": ["ESNext", "ESNext.AsyncIterable"],
    "esModuleInterop": true,
    "allowJs": true,
    "strict": true,
    "experimentalDecorators": true,
    "noEmitOnError": true,
    "baseUrl": ".",
    "types": ["@types/node"],
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}
  • Operating system and version: Zorin OS 16

Activity

  1. changed the title [-]Throws Emit Skipped[/-] [+]Throws TypeError: commitlint.config.ts: Emit skipped[/+] on Jan 10, 2022
  2. cspotcode commented on Jan 11, 2022

    @cspotcode
    Collaborator

    I see you have a config file written in .ts, I assume something is trying to use ts-node to run it? And it's not included in your tsconfig?

  3. iamarpitpatidar commented on Jan 11, 2022

    @iamarpitpatidar
    Author

    yeah, that's the thing the github I linked has the exact same config with just one file that I am using.. but wierd that it throws error,.

    about something is trying to use ts-node to run it its commitlint as ofc the error only happens when husky run commitlint as pre-commit hook

    @cspotcode do you think there is a way to fix this ?

  4. cspotcode commented on Jan 11, 2022

    @cspotcode
    Collaborator

    ts-node uses typescript under the hood. We need to get output JS to give to node to execute it. TypeScript does not emit files that fall outside your rootDir. So when ts-node is asked for the JS code from a file, and typescript doesn't give it to us, you get the error.

    transpileOnly mode avoids this. Or you can use compilerOptions overrides.

    https://typestrong.org/ts-node/docs/configuration
    https://typestrong.org/ts-node/docs/options

  5. locked and limited conversation to collaborators on Jan 11, 2022
  6. converted this issue into a discussion #1595 on Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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