Browse Source

quote interface keys if not valid a property name

pull/8015/head
Arman Ozak 5 years ago
parent
commit
d46397630d
  1. 4
      npm/ng-packs/packages/schematics/src/utils/model.ts

4
npm/ng-packs/packages/schematics/src/utils/model.ts

@ -8,6 +8,7 @@ import {
} from './generics';
import { parseNamespace } from './namespace';
import { relativePathToModel } from './path';
import { isValidProp } from './prop';
import { camel } from './text';
import { parseGenerics } from './tree';
import {
@ -134,7 +135,8 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP
genericsCollector.reset();
typeDef.properties?.forEach(prop => {
const name = prop.jsonName || camel(prop.name);
let name = prop.jsonName || camel(prop.name);
name = isValidProp(name) ? name : `'${name}'`;
const type = simplifyType(prop.typeSimple);
const refs = parseType(prop.type).reduce(
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()),

Loading…
Cancel
Save