Open marcelo-agil opened 2 years ago
try changing
"paths": {
"@sharedDomain/*": ["src/modules/shared/domain/*"],
}
to
"paths": {
"@shared/*": ["src/modules/shared/*"],
}
@erki
try changing
"paths": { "@sharedDomain/*": ["src/modules/shared/domain/*"], }
to
"paths": { "@shared/*": ["src/modules/shared/*"], }
My mistake on the example. The code is right, but won't work.
In the interface file:
import * as IUtil from '@shared/util/util.interface';
In tsconfig-paths: "@shared/": ["src/modules/shared/"],
It doesn't recognize. But on runtime code works, file gets imported. If I use full path on import, than typescript-json-schema works.
He is not translating @shared. How can I achieve that?
could you specify which command are you running and would you consider pasting your tsconfig?
could you specify which command are you running and would you consider pasting your tsconfig?
Sure.
Here's my tsconfig.ts:
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"lib": ["es6"],
"allowJs": true,
"outDir": "./dist",
"rootDir": "./src",
"removeComments": true,
"typeRoots": ["./node_modules/@types", "./src/@types"],
"esModuleInterop": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@sharedDomain/*": ["src/modules/shared/domain/*"],
"@negotiation/*": ["src/modules/user/*"],
"@notification/*": ["src/modules/notification/*"],
"@customer/*": ["src/modules/customer/*"],
"@person/*": ["src/shared/person/*"],
"@personDomain/*": ["src/modules/shared/person/domain/*"],
"@personController/*": [
"src/modules/shared/person/app/http/controller/*"
],
"@personHelper/*": ["src/modules/user/app/http/helper/*"],
"@security/*": ["src/modules/shared/security/*"],
"@userDomain/*": ["src/modules/shared/security/domain/user/*"],
"@product/*": ["src/modules/product/*"],
"@scheduler/*": ["src/modules/scheduler/*"],
"@shared/*": ["src/modules/shared/*"],
"@config/*": ["src/config/*"]
}
},
"include": ["src/**/*", "server.ts"]
}
The command is run through script:
const program = TJS.getProgramFromFiles(
[
resolve(
`./src/modules/shared/security/domain/user/user-agenda.interface.ts`
),
],
compilerOptions
);
const schema = TJS.generateSchema(program, '*', compilerOptions);
The "Agenda" interface is just a test file:
import * as IUtil from '@shared/util/util.interface';
export interface IUserAgenda extends IUtil.IDateFields {
/**
* Inform if this user has agenda app configured
*@default false
*/
isAgendaAppIntegrated?: boolean;
/**
* App key
*
*/
agendaAppKey?: string;
/**
* App secret
*
*/
agendaAppSecret?: string;
/**
* App endpoint
*
*/
agendaAppEndpoint?: string;
}
Once again, if I replace the @shared by the path, it works. If I keep @shared on imports, this is the error displayed: " Cannot find module '@shared/util/util.interface' or its corresponding type declarations."
@erkin98 any thoughts?
I suggest you use the typescript-json-schema "tsconfig.json" "*" -o all.json
command and add "types": ["folder-inside-src/@types"],
to your tsconfig.json
Any news on this issue? Because I use v0.62.0 but I get same error with similar context.
Hi guys,
I'm using tsconfig-paths to avoid path hell. Instead of importing files using import * from '../../../', it uses an array of path aliases and they current values. Works pretty well.
Example of tsconfig-path:
The problem is when I try to programmatic use typescript-json-schema, it throws this error:
"Cannot find module '@shared/util/util.interface' or its corresponding type declarations.".
The file above constains this code:
My question is: How to make typescript-json-schema understand the tsconfig-paths?