Skip to content

Commit 947fe92

Browse files
committed
Update use of js-yaml for compatibility with newer type defintions
A [recent change][0] changed the return type of `safeLoad` from `any` to `object`. Accessing any property on a value of type `object` generates a compiler error. ``` src/config.ts(168,17): error TS2339: Property 'apiVersion' does not exist on type 'object'. ``` [0]: DefinitelyTyped/DefinitelyTyped@ae9aff4
1 parent fd3c72b commit 947fe92

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

node-client/src/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ export class KubeConfig {
165165

166166
public loadFromString(config: string) {
167167
var obj = yaml.safeLoad(config);
168-
if (obj.apiVersion != 'v1') {
169-
throw new TypeError('unknown version: ' + obj.apiVersion);
168+
if (obj['apiVersion'] != 'v1') {
169+
throw new TypeError('unknown version: ' + obj['apiVersion']);
170170
}
171-
this.clusters = newClusters(obj.clusters);
172-
this.contexts = newContexts(obj.contexts);
173-
this.users = newUsers(obj.users);
171+
this.clusters = newClusters(obj['clusters']);
172+
this.contexts = newContexts(obj['contexts']);
173+
this.users = newUsers(obj['users']);
174174
this.currentContext = obj['current-context'];
175175
}
176176
}

0 commit comments

Comments
 (0)