Closed
Description
Describe the Bug
The TS interfaces are pretty great.
I found a bug where the TS unknown
type is used for some of the properties in src/event/interfaces.ts
.
This is a problem because this TS type causes some issues:
Type 'unknown' is not assignable to type '{}'.ts(2322)
We should simply remove the unknown
type as a possibility for these interfaces.
Test code:
const TEST_CLOUD_EVENT: CloudEventV1 = {
specversion: '1.0',
type: 'com.google.cloud.storage',
source: 'https://github.com/GoogleCloudPlatform/functions-framework-nodejs',
subject: 'test-subject',
id: 'test-1234-1234',
time: '2020-05-13T01:23:45Z',
datacontenttype: 'application/json',
data: {
some: 'payload',
},
};
describe('CloudEvents request to event function', () => {
interface TestData {
name: string;
headers: { [key: string]: string | Date | undefined };
body: {};
}
const testData: TestData[] = [
{
name: 'CloudEvents v1.0 structured content mode',
headers: { 'Content-Type': 'application/cloudevents+json' },
body: TEST_CLOUD_EVENT,
},
{
name: 'CloudEvents v1.0 binary content mode',
headers: {
'Content-Type': 'application/cloudevents+json',
'ce-specversion': TEST_CLOUD_EVENT.specversion,
'ce-type': TEST_CLOUD_EVENT.type,
'ce-source': TEST_CLOUD_EVENT.source,
'ce-subject': TEST_CLOUD_EVENT.subject,
'ce-id': TEST_CLOUD_EVENT.id,
'ce-time': TEST_CLOUD_EVENT.time,
'ce-datacontenttype': TEST_CLOUD_EVENT.datacontenttype,
},
body: TEST_CLOUD_EVENT.data,
},
];