Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tsc does not generate .js files - TypeScript

Tags:

typescript

tsc

I am creating a component-library and using tsc to output a 1:1 of my tsx files to .js files. However I cannot get this to working:

comand

...
"ts": "rm -rf dist && yarn tsc --build tsconfig.json",
...

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "rootDirs": [
      "src",
      "stories",
      "config"
    ],
    "rootDir": "src",
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "jsx": "react-jsx",
    "declaration": true,
    "emitDeclarationOnly": true,
    "isolatedModules": true,
    "outDir": "dist",
  },
  "include": [
    "src"
  ],
  "exclude": [
    "**/*.spec.ts",
    "**/*.test.tsx",
    "**/*.stories.js",
    "node_modules",
    "src/test-utils",
    "dist",
    "docs",
    "src/setupTests.js"
  ]
}

output

dist
dist/components
dist/components/Link
dist/components/Link/index.d.ts
dist/components/Link/Link.d.ts
dist/components/Text
dist/components/Text/index.d.ts
dist/components/Text/Text.d.ts
dist/components/index.d.ts
like image 846
Jamie Hutber Avatar asked Apr 30 '26 14:04

Jamie Hutber


1 Answers

Check your tsconfig.json and make sure that have not disabled the emission of the javascript files by typescript during the compilation process.

{
  "compilerOptions": {
    "emitDeclarationOnly": false,
    "noEmit": false,
  }
}
like image 69
Sylhare Avatar answered May 02 '26 07:05

Sylhare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!