type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
FunctionDeclaration |
function stopPollingRuntime() {
if (botStatusInterval) {
clearInterval(botStatusInterval);
botStatusInterval = undefined;
}
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
async function handlePublish(config: IPublishConfig) {
setBotStatus(BotStatus.publishing);
dismissDialog();
const { luis, qna } = config;
const endpointKey = settings.qna?.endpointKey;
await setSettings(projectId, {
...settings,
luis: luis,
qna: Object.assign({}, settings.qna, qna, { endpointKey }),
});
await build(luis, qna, projectId);
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
async function handleLoadBot() {
setBotStatus(BotStatus.reloading);
if (settings.qna && settings.qna.subscriptionKey) {
await setQnASettings(projectId, settings.qna.subscriptionKey);
}
const sensitiveSettings = settingsStorage.get(projectId);
await publishToTarget(projectId, defaultPublishConfig, { comment: '' }, sensitiveSettings);
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
function isConfigComplete(config) {
let complete = true;
if (getReferredLuFiles(luFiles, dialogs).length > 0) {
if (Object.values(LuisConfig).some((luisConfigKey) => config.luis[luisConfigKey] === '')) {
complete = false;
}
}
if (getReferredQnaFiles(qnaFiles, dialogs).length > 0) {
if (Object.values(QnaConfig).some((qnaConfigKey) => config.qna[qnaConfigKey] === '')) {
complete = false;
}
}
return complete;
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration | // return true if dialogs have one with default recognizer.
function needsPublish(dialogs) {
let isDefaultRecognizer = false;
if (dialogs.some((dialog) => typeof dialog.content.recognizer === 'string')) {
isDefaultRecognizer = true;
}
return isDefaultRecognizer;
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
async function handleStart() {
dismissCallout();
const config = Object.assign(
{},
{
luis: settings.luis,
qna: {
subscriptionKey: settings.qna?.subscriptionKey,
qnaRegion: settings.qna?.qnaRegion,
endpointKey: settings.qna?.endpointKey,
},
}
);
if (!isAbsHosted() && needsPublish(dialogs)) {
if (botStatus === BotStatus.failed || botStatus === BotStatus.pending || !isConfigComplete(config)) {
openDialog();
} else {
await handlePublish(config);
}
} else {
await handleLoadBot();
}
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
function handleErrorButtonClick() {
navigateTo(`/bot/${projectId}/notifications`);
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
FunctionDeclaration |
async function handleOpenEmulator() {
return Promise.resolve(
openInEmulator(
botEndpoints[projectId] || 'http://localhost:3979/api/messages',
settings.MicrosoftAppId && settings.MicrosoftAppPassword
? { MicrosoftAppId: settings.MicrosoftAppId, MicrosoftAppPassword: settings.MicrosoftAppPassword }
: { MicrosoftAppPassword: '', MicrosoftAppId: '' }
)
);
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
() => {
const [modalOpen, setModalOpen] = useState(false);
const [calloutVisible, setCalloutVisible] = useState(false);
const botActionRef = useRef(null);
const notifications = useNotifications();
const botName = useRecoilValue(botNameState);
const botStatus = useRecoilValue(botStatusState);
const dialogs = useRecoilValue(validatedDialogsSelector);
const luFiles = useRecoilValue(luFilesState);
const qnaFiles = useRecoilValue(qnaFilesState);
const settings = useRecoilValue(settingsState);
const projectId = useRecoilValue(projectIdState);
const botLoadErrorMsg = useRecoilValue(botLoadErrorState);
const botEndpoints = useRecoilValue(botEndpointsState);
const {
publishToTarget,
onboardingAddCoachMarkRef,
build,
getPublishStatus,
setBotStatus,
setSettings,
setQnASettings,
} = useRecoilValue(dispatcherState);
const connected = botStatus === BotStatus.connected;
const publishing = botStatus === BotStatus.publishing;
const reloading = botStatus === BotStatus.reloading;
const addRef = useCallback((startBot) => onboardingAddCoachMarkRef({ startBot }), []);
const errorLength = notifications.filter((n) => n.severity === 'Error').length;
const showError = errorLength > 0;
const publishDialogConfig = { subscriptionKey: settings.qna?.subscriptionKey, ...settings.luis } as IConfig;
const warningLength = notifications.filter((n) => n.severity === 'Warning').length;
const showWarning = !showError && warningLength > 0;
useEffect(() => {
if (projectId) {
getPublishStatus(projectId, defaultPublishConfig);
}
}, [projectId]);
useEffect(() => {
switch (botStatus) {
case BotStatus.failed:
openCallout();
stopPollingRuntime();
setBotStatus(BotStatus.pending);
break;
case BotStatus.published:
stopPollingRuntime();
handleLoadBot();
break;
case BotStatus.reloading:
startPollingRuntime();
break;
default:
case BotStatus.connected:
stopPollingRuntime();
break;
}
return () => {
stopPollingRuntime();
return;
};
}, [botStatus]);
function dismissDialog() {
setModalOpen(false);
}
function openDialog() {
setModalOpen(true);
}
function dismissCallout() {
if (calloutVisible) setCalloutVisible(false);
}
function openCallout() {
setCalloutVisible(true);
}
function startPollingRuntime() {
if (!botStatusInterval) {
const cancelInterval = setInterval(() => {
// get publish status
getPublishStatus(projectId, defaultPublishConfig);
}, POLLING_INTERVAL);
botStatusInterval = cancelInterval;
}
}
function stopPollingRuntime() {
if (botStatusInterval) {
clearInterval(botStatusInterval);
botStatusInterval = undefined;
}
}
async function handlePublish(config: IPublishConfig) {
setBotStatus(BotStatus.publishing);
dismissDialog();
const { luis, qna } = config;
const endpointKey = settings.qna?.endpointKey;
await setSettings(projectId, {
...settings,
luis: luis,
qna: Object.assign({}, settings.qna, qna, { endpointKey }),
});
await build(luis, qna, projectId);
}
async function handleLoadBot() {
setBotStatus(BotStatus.reloading);
if (settings.qna && settings.qna.subscriptionKey) {
await setQnASettings(projectId, settings.qna.subscriptionKey);
}
const sensitiveSettings = settingsStorage.get(projectId);
await publishToTarget(projectId, defaultPublishConfig, { comment: '' }, sensitiveSettings);
}
function isConfigComplete(config) {
let complete = true;
if (getReferredLuFiles(luFiles, dialogs).length > 0) {
if (Object.values(LuisConfig).some((luisConfigKey) => config.luis[luisConfigKey] === '')) {
complete = false;
}
}
if (getReferredQnaFiles(qnaFiles, dialogs).length > 0) {
if (Object.values(QnaConfig).some((qnaConfigKey) => config.qna[qnaConfigKey] === '')) {
complete = false;
}
}
return complete;
}
// return true if dialogs have one with default recognizer.
function needsPublish(dialogs) {
let isDefaultRecognizer = false;
if (dialogs.some((dialog) => typeof dialog.content.recognizer === 'string')) {
isDefaultRecognizer = true;
}
return isDefaultRecognizer;
}
async function handleStart() {
dismissCallout();
const config = Object.assign(
{},
{
luis: settings.luis,
qna: {
subscriptionKey: settings.qna?.subscriptionKey,
qnaRegion: settings.qna?.qnaRegion,
endpointKey: settings.qna?.endpointKey,
},
}
);
if (!isAbsHosted() && needsPublish(dialogs)) {
if (botStatus === BotStatus.failed || botStatus === BotStatus.pending || !isConfigComplete(config)) {
openDialog();
} else {
await handlePublish(config);
}
} else {
await handleLoadBot();
}
}
function handleErrorButtonClick() {
navigateTo(`/bot/${projectId}/notifications`);
}
async function handleOpenEmulator() {
return Promise.resolve(
openInEmulator(
botEndpoints[projectId] || 'http://localhost:3979/api/messages',
settings.MicrosoftAppId && settings.MicrosoftAppPassword
? { MicrosoftAppId: settings.MicrosoftAppId, MicrosoftAppPassword: settings.MicrosoftAppPassword }
: { MicrosoftAppPassword: '', MicrosoftAppId: '' }
)
);
}
return (
<Fragment>
<div ref={botActionRef} css={bot}>
<EmulatorOpenButton
botEndpoint={botEndpoints[projectId] || 'http://localhost:3979/api/messages'}
botStatus={botStatus}
hidden={showError}
onClick={handleOpenEmulator}
/>
<div
aria-label={publishing ? formatMessage('Publishing') : reloading ? formatMessage('Reloading') : ''}
aria-live={'assertive'}
/>
<Loading botStatus={botStatus} />
<div ref={addRef}>
<ErrorInfo count={errorLength} hidden={!showError} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(startBot) => onboardingAddCoachMarkRef({ startBot }) | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(n) => n.severity === 'Error' | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(n) => n.severity === 'Warning' | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
() => {
if (projectId) {
getPublishStatus(projectId, defaultPublishConfig);
}
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
() => {
switch (botStatus) {
case BotStatus.failed:
openCallout();
stopPollingRuntime();
setBotStatus(BotStatus.pending);
break;
case BotStatus.published:
stopPollingRuntime();
handleLoadBot();
break;
case BotStatus.reloading:
startPollingRuntime();
break;
default:
case BotStatus.connected:
stopPollingRuntime();
break;
}
return () => {
stopPollingRuntime();
return;
};
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
() => {
stopPollingRuntime();
return;
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
() => {
// get publish status
getPublishStatus(projectId, defaultPublishConfig);
} | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(luisConfigKey) => config.luis[luisConfigKey] === '' | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(qnaConfigKey) => config.qna[qnaConfigKey] === '' | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ArrowFunction |
(dialog) => typeof dialog.content.recognizer === 'string' | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
MethodDeclaration |
formatMessage('Restart Bot') : formatMessage | 14squared/BotFramework-Composer | Composer/packages/client/src/components/TestController/TestController.tsx | TypeScript |
ClassDeclaration |
@Component({
selector: 'exception-404',
template: ` <exception type="404" style="min-height: 500px; height: 80%; user-select: none;" desc="抱歉,您访问的页面不存在!"></exception> `
})
export class Exception404Component {} | jhkmnm/alainDemo5 | angular/src/app/routes/exception/404.component.ts | TypeScript |
ClassDeclaration |
@Module({
imports: [
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
],
controllers: [UserController],
providers: [UserService],
})
export class UserModule {} | ate-na/authnestjs | src/user/user.module.ts | TypeScript |
ArrowFunction |
() => {
const users = createStore<User[]>([
{
username: 'alice',
email: 'alice@example.com',
bio: '. . .',
},
{
username: 'bob',
email: 'bob@example.com',
bio: '~/ - /~',
},
{
username: 'carol',
email: 'carol@example.com',
bio: '- - -',
},
])
describe('infer type with `as const`', () => {
it('should pass typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as const,
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})
it('should fail typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id] as const,
//@ts-expect-error
fn: (users, [id, field]) => null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Tuple type 'readonly [number]' of length '1' has no element at index '1'.
"
`)
})
})
describe('infer type with `as [explicit, tuple]`', () => {
it('should pass typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})
it('should fail typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
//@ts-expect-error
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]: [number, number]) => null,
})
//@ts-expect-error
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Type '[number, keyof User]' is not assignable to type '[number, number]'.
Type 'string' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
Type 'unknown' is not assignable to type 'ReactNode'.
Type 'unknown' is not assignable to type 'ReactPortal'.
"
`)
})
})
it('can infer tuple type without `as`', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
it('should pass typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as const,
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})
it('should fail typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id] as const,
//@ts-expect-error
fn: (users, [id, field]) => null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Tuple type 'readonly [number]' of length '1' has no element at index '1'.
"
`)
})
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as const,
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as const,
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
(users, [id, field]) => users[id][field] || null | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id] as const,
//@ts-expect-error
fn: (users, [id, field]) => null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Tuple type 'readonly [number]' of length '1' has no element at index '1'.
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id] as const,
//@ts-expect-error
fn: (users, [id, field]) => null,
})
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
(users, [id, field]) => null | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
it('should pass typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})
it('should fail typecheck', () => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
//@ts-expect-error
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]: [number, number]) => null,
})
//@ts-expect-error
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Type '[number, keyof User]' is not assignable to type '[number, number]'.
Type 'string' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
Type 'unknown' is not assignable to type 'ReactNode'.
Type 'unknown' is not assignable to type 'ReactPortal'.
"
`)
})
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
//@ts-expect-error
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]: [number, number]) => null,
})
//@ts-expect-error
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
Type '[number, keyof User]' is not assignable to type '[number, number]'.
Type 'string' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
Type 'unknown' is not assignable to type 'ReactNode'.
Type 'unknown' is not assignable to type 'ReactPortal'.
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({id, field}: Props) => {
const value = useStoreMap({
store: users,
//@ts-expect-error
keys: [id, field] as [number, keyof User],
fn: (users, [id, field]: [number, number]) => null,
})
//@ts-expect-error
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
(users, [id, field]: [number, number]) => null | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const UserProperty = ({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({id, field}: Props) => {
const value = useStoreMap({
store: users,
keys: [id, field],
fn: (users, [id, field]) => users[id][field] || null,
})
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const store = createStore({foo: 0, bar: 'ok'})
const Foo = () => {
const value = useStoreMap(store, ({foo}) => foo)
return <div>{value}</div>
}
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
() => {
const value = useStoreMap(store, ({foo}) => foo)
return <div>{value}</div>
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ArrowFunction |
({foo}) => foo | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
TypeAliasDeclaration |
type User = {
username: string
email: string
bio: string
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
TypeAliasDeclaration |
type Props = {
id: number
field: keyof User
} | 5angel/effector | src/types/__tests__/effector-react/useStoreMap.test.tsx | TypeScript |
ClassDeclaration |
@NgModule({
declarations: [EditComponent],
imports: [
CommonModule,
EditRoutingModule,
ComponentWrapperModule,
ReactiveFormsModule,
MatSelectModule,
MatAutocompleteModule,
MatButtonModule,
RestrictionFormModule,
CoreModule
]
})
export class EditModule {} | bcgov/embc-ess-mod | registrants/src/UI/embc-registrant/src/app/feature-components/edit/edit.module.ts | TypeScript |
ClassDeclaration |
export class PaymentSplitterFactory__factory extends ContractFactory {
constructor(signer?: Signer) {
super(_abi, _bytecode, signer);
}
deploy(
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PaymentSplitterFactory> {
return super.deploy(overrides || {}) as Promise<PaymentSplitterFactory>;
}
getDeployTransaction(
overrides?: Overrides & { from?: string | Promise<string> }
): TransactionRequest {
return super.getDeployTransaction(overrides || {});
}
attach(address: string): PaymentSplitterFactory {
return super.attach(address) as PaymentSplitterFactory;
}
connect(signer: Signer): PaymentSplitterFactory__factory {
return super.connect(signer) as PaymentSplitterFactory__factory;
}
static readonly bytecode = _bytecode;
static readonly abi = _abi;
static createInterface(): PaymentSplitterFactoryInterface {
return new utils.Interface(_abi) as PaymentSplitterFactoryInterface;
}
static connect(
address: string,
signerOrProvider: Signer | Provider
): PaymentSplitterFactory {
return new Contract(
address,
_abi,
signerOrProvider
) as PaymentSplitterFactory;
}
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
deploy(
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PaymentSplitterFactory> {
return super.deploy(overrides || {}) as Promise<PaymentSplitterFactory>;
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
getDeployTransaction(
overrides?: Overrides & { from?: string | Promise<string> }
): TransactionRequest {
return super.getDeployTransaction(overrides || {});
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
attach(address: string): PaymentSplitterFactory {
return super.attach(address) as PaymentSplitterFactory;
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
connect(signer: Signer): PaymentSplitterFactory__factory {
return super.connect(signer) as PaymentSplitterFactory__factory;
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
static createInterface(): PaymentSplitterFactoryInterface {
return new utils.Interface(_abi) as PaymentSplitterFactoryInterface;
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
MethodDeclaration |
static connect(
address: string,
signerOrProvider: Signer | Provider
): PaymentSplitterFactory {
return new Contract(
address,
_abi,
signerOrProvider
) as PaymentSplitterFactory;
} | levx-io/shoyu | test/typechain/factories/PaymentSplitterFactory__factory.ts | TypeScript |
ArrowFunction |
(state, action: PayloadAction<number>): void => {
const value = action.payload;
state.cash += value;
state.list.push({
id: state.list.length + 1,
value,
totalAfter: state.cash,
});
} | Saniol/CashflowGameAssistant | src/transactions/transactionsSlice.ts | TypeScript |
ArrowFunction |
(state, action: PayloadAction<ProffessionInitData>): void => {
const proffesionData = action.payload;
state.cash = proffesionData.income + proffesionData.savings;
state.list.length = 0;
} | Saniol/CashflowGameAssistant | src/transactions/transactionsSlice.ts | TypeScript |
InterfaceDeclaration |
interface TransactionI {
id: number;
value: number;
totalAfter: number;
} | Saniol/CashflowGameAssistant | src/transactions/transactionsSlice.ts | TypeScript |
InterfaceDeclaration |
interface TransactionsStateI {
cash: number;
list: TransactionI[];
} | Saniol/CashflowGameAssistant | src/transactions/transactionsSlice.ts | TypeScript |
FunctionDeclaration | // Vite doesnot export preview handler
export default function runExecutor(
schema: VitePreviewSchema,
context: ExecutorContext
) {
preflightCheck(context, schema.configFile);
schema.root =
schema.root ?? context.workspace.projects[context.projectName].root;
return eachValueFrom(startVitePreview(schema).pipe(map((res) => res)));
} | LinbuduLab/nx-plugins | packages/nx-plugin-vite/src/executors/preview/preview.impl.ts | TypeScript |
ArrowFunction |
(res) => res | LinbuduLab/nx-plugins | packages/nx-plugin-vite/src/executors/preview/preview.impl.ts | TypeScript |
ClassDeclaration |
@SocketMiddleware()
export class UserConverterSocketMiddleware {
async use(@Args() args: any[]) {
let [user] = args;
// update Arguments
user = deserialize(user, {type: User, useAlias: true});
return [user];
}
} | AlexDede/tsed | docs/tutorials/snippets/socketio/socket-use-middleware.ts | TypeScript |
MethodDeclaration |
async use(@Args() args: any[]) {
let [user] = args;
// update Arguments
user = deserialize(user, {type: User, useAlias: true});
return [user];
} | AlexDede/tsed | docs/tutorials/snippets/socketio/socket-use-middleware.ts | TypeScript |
ClassDeclaration |
export default class App extends React.PureComponent<RouteComponentProps> {
public readonly state: IState = {
userInfo: utils.getUserInfo(),
};
public render() {
// due to hosting on gh pages there are some weird routing steps
const authCallbackRequest = this.props.location.pathname.startsWith(
"/access_token",
);
const isLoggedIn = Boolean(this.state.userInfo.username);
return (
<div>
{authCallbackRequest ? (
<Redirect
to={{
pathname: "/authCallback",
state: this.props.location.pathname,
}} | fbjorn/spotify-dumper | src/components/App.tsx | TypeScript |
InterfaceDeclaration |
interface IState {
userInfo: IUserInfo;
} | fbjorn/spotify-dumper | src/components/App.tsx | TypeScript |
MethodDeclaration |
public render() {
// due to hosting on gh pages there are some weird routing steps
const authCallbackRequest = this.props.location.pathname.startsWith(
"/access_token",
);
const isLoggedIn = Boolean(this.state.userInfo.username);
return (
<div>
{authCallbackRequest ? (
<Redirect
to={{
pathname: "/authCallback",
state: this.props.location.pathname,
}} | fbjorn/spotify-dumper | src/components/App.tsx | TypeScript |
MethodDeclaration |
authCallbackRequest ? (
<Redirect
to={{
pathname: "/authCallback",
state: this | fbjorn/spotify-dumper | src/components/App.tsx | TypeScript |
ArrowFunction |
(params) => {
if (params.has('id')) {
this.title = 'Edit Attribute Group';
}
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
ArrowFunction |
attributeGroup => {
console.log('updateAttributeGroup response.body: ' + attributeGroup);
if (attributeGroup) {
this.attributeGroup = {};
}
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
ArrowFunction |
newAttributeGroup => {
console.log('addAttributeGroup response.body: ' + newAttributeGroup);
// this.addProduct.emit(newObjectType);
this.attributeGroup = {};
this.router.navigate(['/application/design/model']);
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'add-attribute-groups',
templateUrl: './add-attribute-groups.component.html',
styleUrls: ['./add-attribute-groups.component.scss']
})
export class AddAttributeGroupsComponent implements OnInit {
private attributeGroup: AttributeGroup;
private submitted = false;
private title = 'Add New Attribute Group';
constructor(private route: ActivatedRoute,
private applicationSchemaService: ApplicationSchemaService,
private router: Router) { }
ngOnInit() {
this.attributeGroup = {};
this.route.paramMap.subscribe((params) => {
if (params.has('id')) {
this.title = 'Edit Attribute Group';
}
});
}
public onSubmit() {
if (this.attributeGroup.id) {
this.applicationSchemaService.updateAttributeGroup(this.attributeGroup)
.subscribe(attributeGroup => {
console.log('updateAttributeGroup response.body: ' + attributeGroup);
if (attributeGroup) {
this.attributeGroup = {};
}
},
);
} else {
this.applicationSchemaService.addAttributeGroup(this.attributeGroup)
.subscribe(newAttributeGroup => {
console.log('addAttributeGroup response.body: ' + newAttributeGroup);
// this.addProduct.emit(newObjectType);
this.attributeGroup = {};
this.router.navigate(['/application/design/model']);
});
}
this.submitted = true;
}
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
MethodDeclaration |
ngOnInit() {
this.attributeGroup = {};
this.route.paramMap.subscribe((params) => {
if (params.has('id')) {
this.title = 'Edit Attribute Group';
}
});
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
MethodDeclaration |
public onSubmit() {
if (this.attributeGroup.id) {
this.applicationSchemaService.updateAttributeGroup(this.attributeGroup)
.subscribe(attributeGroup => {
console.log('updateAttributeGroup response.body: ' + attributeGroup);
if (attributeGroup) {
this.attributeGroup = {};
}
},
);
} else {
this.applicationSchemaService.addAttributeGroup(this.attributeGroup)
.subscribe(newAttributeGroup => {
console.log('addAttributeGroup response.body: ' + newAttributeGroup);
// this.addProduct.emit(newObjectType);
this.attributeGroup = {};
this.router.navigate(['/application/design/model']);
});
}
this.submitted = true;
} | akshay-misra-fullstack-solutions/seller-ecommerce-solution | ecom-bss-admin-web/src/main/web/angular-src/src/app/core/framework/design/model-schema/add-attribute-groups/add-attribute-groups.component.ts | TypeScript |
ClassDeclaration |
export default class ResourceLoader {
static loadResource(filePath: string) {
try {
const clazz = Require.default(filePath);
if (ResourceClazzMap.has(clazz)) {
const clazzInstance = Reflect.construct(clazz, ResourceClazzMap.get(clazz));
ResourceClassMap.set(clazz, clazzInstance);
}
} catch (err) {
if (process.env.NODE_ENV === 'debugger') console.log(err);
}
}
static loadResourceDir(dirPath: string, ignoreDirs: string[] = []) {
if (!fs.existsSync(dirPath)) {
return;
}
loadDir(dirPath, ResourceLoader.loadResource, ignoreDirs);
}
} | wuba/Umajs | packages/core/src/loader/ResourceLoader.ts | TypeScript |
MethodDeclaration |
static loadResource(filePath: string) {
try {
const clazz = Require.default(filePath);
if (ResourceClazzMap.has(clazz)) {
const clazzInstance = Reflect.construct(clazz, ResourceClazzMap.get(clazz));
ResourceClassMap.set(clazz, clazzInstance);
}
} catch (err) {
if (process.env.NODE_ENV === 'debugger') console.log(err);
}
} | wuba/Umajs | packages/core/src/loader/ResourceLoader.ts | TypeScript |
MethodDeclaration |
static loadResourceDir(dirPath: string, ignoreDirs: string[] = []) {
if (!fs.existsSync(dirPath)) {
return;
}
loadDir(dirPath, ResourceLoader.loadResource, ignoreDirs);
} | wuba/Umajs | packages/core/src/loader/ResourceLoader.ts | TypeScript |
FunctionDeclaration | /**
* 根据每行最大字节数切分字符串
* @param text
* @param maxBytePreRow
*/
function splitByMaxBytePreRow(text: string, maxBytePreRow: number): string[] {
let rt = [];
let countPerCount = 0;
let strPreRow = "";
for (let i=0; i<text.length; i++) {
let len = (text.charCodeAt(i) > 127 || text.charCodeAt(i)===94) ? 2 : 1;
if(countPerCount + len > maxBytePreRow) {
rt.push(strPreRow);
strPreRow = "";
countPerCount = 0;
}
strPreRow += text[i];
countPerCount += len;
}
if(strPreRow) {
rt.push(strPreRow);
}
return rt;
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
FunctionDeclaration | /**
* 创建规则编辑器节点使用的label内容,标题固定占2行,操作符1行,值和单位1行
* @param title
* @param operation
* @param value
* @param unit
*/
export function getLabelTextForNode(title: string, operation?: string, value?: any, unit?: string) {
let titleWithRow = splitByMaxBytePreRow(title, 22);
// 指标标题占2行
let rt = [];
if(titleWithRow.length >= 2) {
rt = titleWithRow.slice(0, 2);
} else {
rt = [titleWithRow[0], ''];
}
return rt.concat([operation || "运算符", value === undefined || value === null ? "值" : value + (unit || '')]);
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
FunctionDeclaration | /**
* 填充一个对象,保持对象本身的引用
* @param fillObj
* @param data
*/
export function fillObject(fillObj: any, data: any) {
for(let key in data) {
fillObj[key] = data[key];
}
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
FunctionDeclaration |
export function quotaCheck(variables: QuotaVariableStruct[], templateCode: number) {
// 自定义函数模板,直接忽略
if(templateCode === 13) {return true}
// 名单模板,特殊处理
if(templateCode === 7) {
if(variables.length !== 1) {
return "名单模板变量数量错误";
}
let variable = variables[0];
if(!variable.objectId) {
return "变量1中的对象不可为空";
}
if(variable.funcName !== "current") {
return "变量1中的函数必须为【当前】";
}
if(!variable.operator) {
return "变量1中的操作符不可为空";
}
if(!variable.value) {
return "变量1中的名单不可为空";
}
return true
}
// 其他模板校验
for(let index = 0; index < variables.length; index++) {
let variable = variables[index];
let varName = `变量${index + 1}`;
if(!variable.objectId) {
return `${varName}中的对象不可为空`;
}
if(!variable.funcName) {
return `${varName}中的函数不可为空`;
}
// 校验第二个变量必须有连接运算符
if(index > 0 && !variable.connector) {
return `${varName}前的操作符不可为空`;
}
// 窗口函数不是current或history时,要求必须填写窗口宽度和单位
if(!(variable.funcName === "current" || variable.funcName === "history")) {
if(!variable.windowWidth || variable.windowWidth < 0) {
return `${varName}必须填写时间,并且时间大于0`;
}
if(!variable.windowWidthUnit) {
return `${varName}必须选择一个时间单位`;
}
}
if(variable.filters && variable.filters.list.length) {
for(let j = 0; j < variable.filters.list.length; j++) {
let filter = variable.filters.list[j];
let index = j + 1;
// 全空通过
if(!filter.objectId && !filter.operation && !filter.value) {
continue;
}
if(!filter.objectId) {
return `${varName}中第${index}个过滤条件必须选择一个对象`;
}
if(!filter.operation) {
return `${varName}中第${index}个过滤条件必须选择一个运算符`;
}
if(!filter.value && (filter.value !== 0)) {
return `${varName}中第${index}个过滤条件必须填写值`;
}
}
}
}
return true;
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
TypeAliasDeclaration |
type QuotaFilterStruct = {
objectId?: string,
valueType?: string,
operation?: string,
value?: string|number,
unit?: string,
connector: boolean, // true: and false: or
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
TypeAliasDeclaration |
type QuotaVariableStruct = {
subjectIds: string[],
windowWidth?: number,
windowWidthUnit?: string,
objectId?: string,
funcName?: string,
funcParam?: string,
operator?: string, // 名单专用
value?: any,
filters?: {
desc: string,
exp: string,
list: QuotaFilterStruct[]
},
connector?: string,
} | crazyworkDing/control-demo | src/utils/RuleUtils.ts | TypeScript |
ClassDeclaration |
export class Welcome {
@bindable value;
valueChanged(newValue, oldValue) {
//
}
} | TIHBS/blockchain-modelling-tool | src/resources/elements/welcome.ts | TypeScript |
MethodDeclaration |
valueChanged(newValue, oldValue) {
//
} | TIHBS/blockchain-modelling-tool | src/resources/elements/welcome.ts | TypeScript |
ClassDeclaration |
export class UpdateDormitoryDto extends PartialType(CreateDormitoryDto) {} | ASUDR/backend | src/dormitories/dto/update-dormitory.dto.ts | TypeScript |
ArrowFunction |
(
options: IImportNamedOptions,
): IImportNamed => ({
...create_element(ElementKind.ImportNamed),
...options,
}) | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
ArrowFunction |
(value: any): value is IImportNamed =>
is_element(value) && value.kind === ElementKind.ImportNamed | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
ArrowFunction |
(
element: IImportNamed,
path: IElement<any>[],
) =>
ts.createImportDeclaration(
/* decorators */ undefined,
/* modifiers */ undefined,
/* importClause */ element.members === undefined &&
element.default === undefined
? undefined
: ts.createImportClause(
/* name */ element.default === undefined
? undefined
: ts.createIdentifier(element.default),
/* namedBindings */ element.members === undefined
? undefined
: ts.createNamedImports(
element.members.map(
member => transform(member, path) as ts.ImportSpecifier,
),
),
),
/* moduleSpecifier */ ts.createLiteral(element.from),
) | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
ArrowFunction |
member => transform(member, path) as ts.ImportSpecifier | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
InterfaceDeclaration |
export interface IImportNamedOptions extends IElementOptions {
from: string;
default?: string;
members?: IImportMember[];
} | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
InterfaceDeclaration |
export interface IImportNamed
extends IElement<ElementKind.ImportNamed>,
IImportNamedOptions {} | ikatyang/dts-element | src/import-exports/import-named.ts | TypeScript |
FunctionDeclaration | /**
Framework objects in an Ember application (components, services, routes, etc.)
are created via a factory and dependency injection system. Each of these
objects is the responsibility of an "owner", which handled its
instantiation and manages its lifetime.
`getOwner` fetches the owner object responsible for an instance. This can
be used to lookup or resolve other class instances, or register new factories
into the owner.
For example, this component dynamically looks up a service based on the
`audioType` passed as an argument:
```app/components/play-audio.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { getOwner } from '@ember/application';
// Usage:
//
// <PlayAudio @audioType={{@model.audioType}} @audioFile={{@model.file}}/>
//
export default class extends Component {
get audioService() {
let owner = getOwner(this);
return owner.lookup(`service:${this.args.audioType}`);
}
@action
onPlay() {
let player = this.audioService;
player.play(this.args.audioFile);
}
}
```
@method getOwner
@static
@for @ember/application
@param {Object} object An object with an owner.
@return {Object} An owner object.
@since 2.3.0
@public
*/
export function getOwner(object: any): Owner {
let owner = glimmerGetOwner(object) as Owner;
if (owner === undefined) {
owner = object[LEGACY_OWNER];
deprecate(
`You accessed the owner using \`getOwner\` on an object, but it was not set on that object with \`setOwner\`. You must use \`setOwner\` to set the owner on all objects. You cannot use Object.assign().`,
owner === undefined,
{
id: 'owner.legacy-owner-injection',
until: '3.25.0',
for: 'ember-source',
since: {
enabled: '3.22.0',
},
}
);
}
return owner;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
FunctionDeclaration | /**
`setOwner` forces a new owner on a given object instance. This is primarily
useful in some testing cases.
@method setOwner
@static
@for @ember/application
@param {Object} object An object instance.
@param {Object} object The new owner object of the object instance.
@since 2.3.0
@public
*/
export function setOwner(object: any, owner: Owner): void {
glimmerSetOwner(object, owner);
object[LEGACY_OWNER] = owner;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
InterfaceDeclaration | /**
@module @ember/application
*/
export interface LookupOptions {
singleton?: boolean;
instantiate?: boolean;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
InterfaceDeclaration |
export interface FactoryClass {
positionalParams?: string | string[] | undefined | null;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
InterfaceDeclaration |
export interface Factory<T, C extends FactoryClass | object = FactoryClass> {
class?: C;
name?: string;
fullName?: string;
normalizedName?: string;
create(props?: { [prop: string]: any }): T;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
InterfaceDeclaration |
export interface EngineInstanceOptions {
mountPoint: string;
routable: boolean;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
InterfaceDeclaration |
export interface Owner {
lookup<T>(fullName: string, options?: LookupOptions): T | undefined;
factoryFor<T, C>(fullName: string, options?: LookupOptions): Factory<T, C> | undefined;
factoryFor(fullName: string, options?: LookupOptions): Factory<any, any> | undefined;
buildChildEngineInstance(name: string, options?: EngineInstanceOptions): EngineInstance;
register<T, C>(fullName: string, factory: Factory<T, C>, options?: object): void;
hasRegistration(name: string, options?: LookupOptions): boolean;
mountPoint?: string;
routable?: boolean;
} | Angel-gc/ember.js | packages/@ember/-internals/owner/index.ts | TypeScript |
FunctionDeclaration | /**
* 10000 => "10,000"
* @param {number} num
*/
export function toThousandFilter(num: number): string {
return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
} | wusshuang/vue-ts | src/filters/index.ts | TypeScript |
ArrowFunction |
m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ',') | wusshuang/vue-ts | src/filters/index.ts | TypeScript |
FunctionDeclaration |
function lagConfig(
enhet: string | undefined | null,
history: History,
settEnhet: (enhet: string) => void
): DecoratorProps {
const { sokFnr, pathFnr } = getFnrFraUrl();
const onsketFnr = sokFnr || pathFnr;
const fnrValue = onsketFnr === '0' ? RESET_VALUE : onsketFnr;
return {
appname: 'Modia personoversikt',
fnr: {
value: fnrValue,
display: FnrDisplay.SOKEFELT,
onChange(fnr: string | null): void {
if (fnr === getFnrFraUrl().pathFnr) {
return;
}
if (fnr && fnr.length > 0) {
setNyBrukerIPath(history, fnr);
} else {
fjernBrukerFraPath(history);
}
}
},
enhet: {
initialValue: enhet || null,
display: EnhetDisplay.ENHET_VALG,
onChange(enhet: string | null): void {
if (enhet) {
settEnhet(enhet);
}
}
},
toggles: {
visVeileder: true
},
markup: {
etterSokefelt: etterSokefelt
},
// modiacontextholder kjører på samme domene som modiapersonoversikt.
// Som default brukes app.adeo.no, så her tvinger vi dekoratøren over på nytt domene
useProxy: `https://${window.location.host}`
};
} | navikt/modiapersonoversikt | src/app/internarbeidsflatedecorator/Decorator.tsx | TypeScript |
FunctionDeclaration | // TODO Jupp, dette er en superhack pga fnr i redux-state ikke blir satt tidlig nok.
// gjeldendeBruker.fnr burde fjernes fra state og hentes fra url slik at man har en single-point-of truth.
function useVenterPaRedux() {
const [klar, setKlar] = useState(false);
useOnMount(() => {
setKlar(true);
});
return klar;
} | navikt/modiapersonoversikt | src/app/internarbeidsflatedecorator/Decorator.tsx | TypeScript |
FunctionDeclaration |
function getPathnameFromUrl(): string {
const { pathname, hash } = window.location;
return removePrefix(pathname + hash, process.env.PUBLIC_URL, '/#', '#');
} | navikt/modiapersonoversikt | src/app/internarbeidsflatedecorator/Decorator.tsx | TypeScript |
FunctionDeclaration |
function getFnrFraUrl(): { sokFnr: string | null; pathFnr: string | null } {
const location = window.location;
const pathname = getPathnameFromUrl();
const queryParams = parseQueryString<{ sokFnr?: string }>(location.search);
const sakerUriMatch = matchPath<{ fnr: string }>(pathname, `${paths.sakerFullscreen}/:fnr`);
const saksdokumentUriMatch = matchPath<{ fnr: string }>(pathname, `${paths.saksdokumentEgetVindu}/:fnr`);
const personUriMatch = matchPath<{ fnr: string }>(pathname, `${paths.personUri}/:fnr`);
return {
sokFnr: queryParams.sokFnr ?? null,
pathFnr: sakerUriMatch?.params.fnr ?? saksdokumentUriMatch?.params.fnr ?? personUriMatch?.params.fnr ?? null
};
} | navikt/modiapersonoversikt | src/app/internarbeidsflatedecorator/Decorator.tsx | TypeScript |