tsc does not generate .js files - TypeScript
Asked Answered
I

1

7

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
Inscrutable answered 10/11, 2021 at 13:41 Comment(3)
You have emitDeclarationOnly set to trueWalhalla
DOH! I swear on my little toe nail I had removed this! I am living in a dream world!Inscrutable
Another one to look out for is "noEmit": trueHae
Y
2

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,
  }
}
Yokefellow answered 8/3 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.