#typescript compiller error
41 messages · Page 1 of 1 (latest)
Is it not just "exclude": ["dist/**/*", "maps/**/*", "i18n/**/*"]? Missing the * on each?
sorry
i do not understand
{
"compilerOptions": {
"strict": true,
"target": "ES2015",
"lib": ["DOM", "esnext"],
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": true,
"moduleResolution": "node",
"noUnusedLocals": true,
"sourceMap": true,
"declaration": true,
"declarationDir": "dist",
"outDir": "dist",
"experimentalDecorators": true,
"resolveJsonModule": true,
"rootDir": "src"
},
}
how would you change tsconfig
I'm confused by what you're trying to do
I want it to not put a "src" inside it in the "dist" folder and also not put "maps" and "i18n"
What's your package.json "scripts" look like?
How do you expect src/utils/vars.ts to know where i18n jsons are if you don't have it in dist?
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
The best you could do is a dynamic import for your messages, with a string variable instead of a string literal:
export async function getMessages() {
const enjson = "en.message.json";
const esjson = "es.message.json";
const ptjson = "pt.message.json";
return {
en: await import(enjson),
es: await import(esjson),
pt: await import(ptjson),
}
}
And in tsconfig.json:
"include": [
"src/index.ts"
],
But IMHO you should be using a build system like https://vitejs.dev/ or at least a bundling framework like https://rollupjs.org/. These tools have already solved your problem
I don't know why you would have a src folder in your dist, unless that is left over from an old config, and just needs deleting
tsc does not delete old files
Yea, basically tsc is not a bundler!
Well I'm not sure that that is relevant
Your exclude configs do nothing, because those folders are outside of src
My guess is that you need to delete dist, move i18n and maps inside src, and rebuild
Unless you have some other plan to access maps and i18. Obviously if you are not using them, then they can just be ignored
Whether he wants to bundle or not is sperate to just having the correct files in dist, right?
tsc outputs dist/i18n and dist/maps though
probably because "resolveJsonModule": true, so the json files are outputted
You think he is importing from outside of src, and so it is duplicating his project folder in dist?
I would have thouht that importing from outside of src would give a TS error
But I don't see why the solution is anything but putting the files needed in src and doing a normal build
Yea, not sure how dist/src ended up there, because that doesn't happen with the shared repo & tsconfig.
If you don't want your output to be dist/src you can configure rootDir: "src", and TS will error wherever you're violating that.
I think OP's concern is that the directories are essentially duped between src/ and dist
he has it
which I why i think his dist is an old build from an old config
rimraf dist && tsc
Not in the screenshot they shared.
here
you're correct about the screenshot
but he has it in his paste
Ah, yeah, I missed their follow-up comment. Yeah, would make sure to delete dist then and try again.