Closed rojiwon0325 closed 1 year ago
Can you uploas an example project file?
How about using CommonJS target? If not working, I will try at tomorrow.
i use tsconfig { "module":"commonjs" }
Oh my god, you are configuring NodeJS global type directly.
In that case, you have to reference the declaration file like below:
/// <reference path="../../../../infrastructure/config/env.d.ts" />
import { PROFILEKEY } from '@COMMON/constant';
import { HttpExceptionMessage } from '@COMMON/exception';
import { Google, StrategyException } from '@devts/nestjs-auth';
import { IProfile } from '@INTERFACE/common';
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import typia from 'typia';
@Injectable()
export class GoogleStrategy extends Google.AbstractStrategy<
PROFILEKEY,
'email' | 'profile',
IProfile
> {
constructor(config: ConfigService<IEnv, true>) {
super({
key: 'profile',
client_id: config.get('GOOGLE_CLIENT_ID'),
client_secret: config.get('GOOGLE_CLIENT_SECRET'),
redirect_uri: config.get('GOOGLE_OAUTH_CALLBACK'),
access_type: 'offline',
prompt: 'select_account',
scope: ['email', 'profile'],
});
}
protected throw({ statusCode, message }: StrategyException): never {
throw new HttpException(
message ?? HttpExceptionMessage.UAE,
statusCode ?? HttpStatus.UNAUTHORIZED,
);
}
validate(identity: Google.IdToken<'email' | 'profile'>): boolean {
typia.assert(identity);
return true;
}
transform(identity: Google.IdToken<'email' | 'profile'>): IProfile {
const { name: username, email, sub } = identity;
return { username, email, sub, oauth_type: 'google' };
}
}
thank you..
/// <reference path="../../../../infrastructure/config/env.d.ts" />
why do we need this? I think I'm facing a similar issue
I have some utility types in a @types/utils.d.ts
files that looks like this
type RemoveIndex<T> = {
[K in keyof T as string extends K
? never
: number extends K
? never
: K]: T[K];
};
declare type KnownKeys<T> = keyof RemoveIndex<T>;
then using in my code without any import, just adding this file to the includes
of tsconfig
and this is working fine, but with nestia swagger I'm gettings this error error TS2304: Cannot find name 'KnownKeys'.
is this the same? why is this happenning?
thanks
EDIT: could be related with this? can that files option be used?
I managed to solved this issue, using this TS_NODE_FILES=1
env var from ts-node doc to include files and includes from tsconfig
If a controller class depend on .d.ts file(or something that depend on .d.ts file), I can't command "nestia sdk" or "nestia swagger".
If i command that, throw Error.
example. IEnv is defined in env.d.ts file. so i don't have line "import ~~".