Not possible to use full TypeScript syntax in the config file
See original GitHub issueWhen I have the following config:
config/app.ts
interface Config {
clientId: string
clientSecret: string
}
const config: Config = {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
}
export default config;
After tsc
transpiling, and running (npm run start:prod
) produces:
.../src/config/app.ts:1
(function (exports, require, module, __filename, __dirname) { interface Config {
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at configPaths.reduce (.../node_modules/nestjs-config/dist/module/config.service.js:211:28)
Which is interesting, as it appears that the code uses require
and maybe that causes issues?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
Top Results From Across the Web
TSConfig Reference - Docs on every TSConfig option
All relative paths found in the configuration file will be resolved relative ... is provably unreachable due to the use of JavaScript syntax,...
Read more >How to tell it not to accept TypeScript syntax in JavaScript files?
I have some files that are not TypeScript, but Prettier has no problem formatting them. When I install eslint-config-prettier, ...
Read more >How to create an application-specific config file for TypeScript?
You can do it the following way. First define structure of your config file, in lets say config.ts: export interface Config { uriPath:...
Read more >TypeScript Compiling with Visual Studio Code
A tsconfig.json file defines the TypeScript project settings, such as the compiler options and the files that should be included. To do this,...
Read more >TypeScript configuration - Angular
Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration. This page ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The glob pattern I posted above works. I tested it just now. You can add your other bits to it:
Ok, I narrowed it down to:
This should exclude the definitions. Can be made tighter, as it also excludes
foo.d.js
right now, which technically is a valid filename.