#typescript compiller error

41 messages · Page 1 of 1 (latest)

wise shoal
#

Basically, I don't want to transcribe the src folder into dist, and I also don't want to put maps and i18n in there.

nocturne sand
#

Is it not just "exclude": ["dist/**/*", "maps/**/*", "i18n/**/*"]? Missing the * on each?

wise shoal
#

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

nocturne sand
#

I'm confused by what you're trying to do

wise shoal
#

I want it to not put a "src" inside it in the "dist" folder and also not put "maps" and "i18n"

nocturne sand
#

What's your package.json "scripts" look like?

wise shoal
nocturne sand
#

How do you expect src/utils/vars.ts to know where i18n jsons are if you don't have it in dist?

nocturne sand
#

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"
  ],
candid valve
#

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

nocturne sand
#

Yea, basically tsc is not a bundler!

candid valve
#

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?

nocturne sand
#

tsc outputs dist/i18n and dist/maps though

#

probably because "resolveJsonModule": true, so the json files are outputted

candid valve
#

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

nocturne sand
#

Yea, not sure how dist/src ended up there, because that doesn't happen with the shared repo & tsconfig.

crude hamlet
#

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.

nocturne sand
#

I think OP's concern is that the directories are essentially duped between src/ and dist

candid valve
#

which I why i think his dist is an old build from an old config

#

rimraf dist && tsc

crude hamlet
#

Not in the screenshot they shared.

candid valve
#

you're correct about the screenshot

#

but he has it in his paste

crude hamlet
#

Ah, yeah, I missed their follow-up comment. Yeah, would make sure to delete dist then and try again.