Skip to content

Commit 044d917

Browse files
authored
Merge pull request #641 from saschanaz/refactor2
refactor: remove convertDomTypeToNullableTsType()
2 parents 6ec9795 + 110d5ae commit 044d917

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

.paket/paket.bootstrapper.exe

-30 KB
Binary file not shown.

src/emitter.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,6 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
350350
}
351351
}
352352

353-
function convertDomTypeToNullableTsType(obj: Browser.Typed) {
354-
const resolvedType = convertDomTypeToTsType(obj);
355-
return obj.nullable ? makeNullable(resolvedType) : resolvedType;
356-
}
357-
358353
function nameWithForwardedTypes(i: Browser.Interface) {
359354
const typeParameters = i["type-parameters"];
360355

@@ -383,7 +378,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
383378

384379
return expectedMName === m.name &&
385380
m.signature && m.signature.length === 1 &&
386-
convertDomTypeToNullableTsType(m.signature[0]) === expectedMType &&
381+
convertDomTypeToTsType(m.signature[0]) === expectedMType &&
387382
m.signature[0].param && m.signature[0].param!.length === expectedParamType.length &&
388383
expectedParamType.every((pt, idx) => convertDomTypeToTsType(m.signature[0].param![idx]) === pt);
389384
}
@@ -501,7 +496,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
501496
p = { name: p.name, type: [p.subtype!, p] }
502497
}
503498
const isOptional = !p.variadic && p.optional;
504-
const pType = isOptional ? convertDomTypeToTsType(p) : convertDomTypeToNullableTsType(p);
499+
const pType = convertDomTypeToTsType(p);
505500
const variadicParams = p.variadic && pType.indexOf('|') !== -1;
506501
return (p.variadic ? "..." : "") +
507502
adjustParamName(p.name) +
@@ -534,7 +529,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
534529
function emitCallBackFunction(cb: Browser.CallbackFunction) {
535530
printer.printLine(`interface ${processInterfaceType(cb, cb.name)} {`);
536531
printer.increaseIndent();
537-
emitSignatures(cb, "", "", s => printer.printLine(s));
532+
emitSignatures(cb, "", "", printer.printLine);
538533
printer.decreaseIndent();
539534
printer.printLine("}");
540535
printer.printLine("");
@@ -761,8 +756,8 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
761756

762757
// Emit constructor signature
763758
if (constructor) {
764-
emitComments(constructor, s => printer.print(s));
765-
emitSignatures(constructor, "", "new", s => printer.printLine(s));
759+
emitComments(constructor, printer.print);
760+
emitSignatures(constructor, "", "new", printer.printLine);
766761
}
767762
else {
768763
printer.printLine(`new(): ${i.name};`);

0 commit comments

Comments
 (0)