Skip to content

Commit a10bd17

Browse files
chore: resolve 'unknown' type from jsYaml.load with explicit cast
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 261a117 commit a10bd17

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as fs from 'fs-extra';
2424
import { DevfileContext } from './api/devfile-context';
2525
import { DevContainerComponentFinder } from './devfile/dev-container-component-finder';
2626

27-
type DevfileLike = V230Devfile & {
27+
export type DevfileLike = V230Devfile & {
2828
metadata: V230DevfileMetadata & {
2929
generateName?: string;
3030
};
@@ -72,13 +72,13 @@ export class Generate {
7272
injectDefaultComponent?: string,
7373
defaultComponentImage?: string,
7474
): Promise<DevfileContext> {
75-
const devfile = jsYaml.load(devfileContent);
75+
const devfile = jsYaml.load(devfileContent) as DevfileLike;
7676

7777
// sets the suffix to the devfile name
7878
const suffix = devfile.metadata.name || '';
7979

8080
// devfile of the editor
81-
const editorDevfile = jsYaml.load(editorContent);
81+
const editorDevfile = jsYaml.load(editorContent) as DevfileLike;
8282

8383
// transform it into a devWorkspace template
8484
const metadata = this.createDevWorkspaceMetadata(editorDevfile);

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import * as axios from 'axios';
1212
import * as fs from 'fs-extra';
13-
import { Generate, DEVWORKSPACE_METADATA_ANNOTATION } from './generate';
13+
import { Generate, DEVWORKSPACE_METADATA_ANNOTATION, DevfileLike } from './generate';
1414
import { DevfileSchemaValidator } from './devfile-schema/devfile-schema-validator';
1515
import * as jsYaml from 'js-yaml';
1616
import { InversifyBinding } from './inversify/inversify-binding';
@@ -71,7 +71,7 @@ export class Main {
7171
devfileContent = await container.get(UrlFetcher).fetchText(url.getContentUrl('devfile.yaml'));
7272

7373
// load content
74-
const devfileParsed = jsYaml.load(devfileContent);
74+
const devfileParsed = jsYaml.load(devfileContent) as DevfileLike;
7575

7676
if (!devfileParsed.attributes) {
7777
devfileParsed.attributes = {};
@@ -106,7 +106,7 @@ export class Main {
106106
devfileContent = params.devfileContent;
107107
}
108108

109-
const jsYamlDevfileContent = jsYaml.load(devfileContent);
109+
const jsYamlDevfileContent = jsYaml.load(devfileContent) as DevfileLike;
110110
const schemaVersion = jsYamlDevfileContent.schemaVersion;
111111
if (!schemaVersion) {
112112
throw new Error(`Devfile is not valid, schemaVersion is required`);

0 commit comments

Comments
 (0)