fix(cli): enum TypeScript type should be const enum
This commit is contained in:
parent
0723e158e5
commit
f4b0a2e322
2 changed files with 5 additions and 4 deletions
|
@ -394,7 +394,8 @@ export class ExternalObject<T> {
|
||||||
idents.push(def.name)
|
idents.push(def.name)
|
||||||
}
|
}
|
||||||
dts +=
|
dts +=
|
||||||
indentLines(`${def.js_doc}export enum ${def.name} {`, nest) + '\n'
|
indentLines(`${def.js_doc}export const enum ${def.name} {`, nest) +
|
||||||
|
'\n'
|
||||||
dts += indentLines(def.def, nest + 2) + '\n'
|
dts += indentLines(def.def, nest + 2) + '\n'
|
||||||
dts += indentLines(`}`, nest) + '\n'
|
dts += indentLines(`}`, nest) + '\n'
|
||||||
break
|
break
|
||||||
|
|
6
examples/napi/index.d.ts
vendored
6
examples/napi/index.d.ts
vendored
|
@ -28,7 +28,7 @@ export interface Obj {
|
||||||
}
|
}
|
||||||
export function either4(input: string | number | boolean | Obj): number
|
export function either4(input: string | number | boolean | Obj): number
|
||||||
/** default enum values are continuos i32s start from 0 */
|
/** default enum values are continuos i32s start from 0 */
|
||||||
export enum Kind {
|
export const enum Kind {
|
||||||
/** Barks */
|
/** Barks */
|
||||||
Dog = 0,
|
Dog = 0,
|
||||||
/** Kills birds */
|
/** Kills birds */
|
||||||
|
@ -37,7 +37,7 @@ export enum Kind {
|
||||||
Duck = 2
|
Duck = 2
|
||||||
}
|
}
|
||||||
/** You could break the step and for an new continuous value. */
|
/** You could break the step and for an new continuous value. */
|
||||||
export enum CustomNumEnum {
|
export const enum CustomNumEnum {
|
||||||
One = 1,
|
One = 1,
|
||||||
Two = 2,
|
Two = 2,
|
||||||
Three = 3,
|
Three = 3,
|
||||||
|
@ -68,7 +68,7 @@ export interface AllOptionalObject {
|
||||||
age?: number | undefined | null
|
age?: number | undefined | null
|
||||||
}
|
}
|
||||||
export function receiveAllOptionalObject(obj?: AllOptionalObject | undefined | null): void
|
export function receiveAllOptionalObject(obj?: AllOptionalObject | undefined | null): void
|
||||||
export enum ALIAS {
|
export const enum ALIAS {
|
||||||
A = 0,
|
A = 0,
|
||||||
B = 1
|
B = 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue