英文:
converting TS syntax to JSDOC
问题
import { SvelteKitAuth } from '@auth/sveltekit';
/**
* @type {import('@auth/sveltekit').SvelteKitAuthConfig}
*/
export let svelteKitAuthConfig;
/**
* @type {import('@auth/core/providers').Provider}
*/
export let provider;
config: svelteKitAuthConfig = {
providers: [
Auth0Provider({
id: 'auth0',
name: 'Auth0',
clientId: '-client-id-',
clientSecret: '-client-secret-',
issuer: 'https://dev-****.auth0.com/', // <- remember to add trailing `/`
wellKnown: 'https://dev-****.auth0.com/.well-known/openid-configuration',
}) as provider, // <-- Error here
],
secret: '-any-random-string-',
debug: true,
session: {
maxAge: 1800, // 30 mins
},
};
英文:
I am trying to convert a code snippet from TS to plain javascript jsdoc. Is there a good wiki that explains this ?
before
import { SvelteKitAuth, type SvelteKitAuthConfig } from '@auth/sveltekit';
import type { Provider } from '@auth/core/providers';
after:
import { SvelteKitAuth } from '@auth/sveltekit';
/** @type {import('@auth/sveltekit').SvelteKitAuthConfig} */
export let svelteKitAuthConfig
/** @type {import('@auth/core/providers').Provider}; */
export let provider
I have error "unexpected token" when I try to reference provider
config: svelteKitAuthConfig = {
providers: [
Auth0Provider({
id: 'auth0',
name: 'Auth0',
clientId: '-client-id-',
clientSecret: '-client-secret-',
issuer: 'https://dev-****.auth0.com/', // <- remember to add trailing `/`
wellKnown: 'https://dev-****.auth0.com/.well-known/openid-configuration'
}) as provider <-- Error here
],
secret: '-any-random-string-',
debug: true,
session: {
maxAge: 1800 // 30 mins
}
};
答案1
得分: 0
as
是TypeScript语法,它在JS中不存在。(同时,provider
是一个值,而不是一个类型。)
你可以尝试在你要类型化的值之前使用另一个/** @type {...} */
注释。可能首先将其提取到一个单独的const
中。
英文:
as
is TypeScript syntax, it does not exist in JS. (Also provider
is a value, not a type.)
You can try to use another /** @type {...} */
annotation before the value you are trying to type. Possibly extract it to a separate const
first.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论