question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add default values to TypeScript declaration files

See original GitHub issue
Description of the problem

Having definitions helps a lot but they are lacking the proper setting of the default value. It is usually in the comment just above each property so is there any blocker to include them as well.

See for instance:

https://github.com/mrdoob/three.js/blob/4a8c4ae51943f04ba94d04339e671bfe075c41ca/src/renderers/WebGLRenderer.d.ts#L128-L141

could be:

export class WebGLRenderer implements Renderer {
// ...
 	autoClearColor: boolean = true; 
 	autoClearDepth: boolean = true; 
 	autoClearStencil: boolean = true; 
// ...
}

It shouldn’t be an issue since types are actually exporting classes and not just declareing them and could help parsing the codebase and monitor default allocations.

Three.js version

N/A

Browser

N/A

OS

N/A

Hardware Requirements (graphics card, VR Device, …)

N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dmnsgncommented, Aug 7, 2020

Alright @mrdoob, I have opened the PR here: https://github.com/mrdoob/three.js/pull/20036. For maintaining it, I guess you can tag me in the future if defaults changes and these needs to be updated?

1reaction
dmnsgncommented, Aug 3, 2020

I might be able to update the initial comment definitions and PR, then I assume if defaults are changed for some reason in the js source files, the ts declaration files should be checked in parallel with the PR or when merging.


@donmccurdy just tried in VSCode and it does: if I update WebGLRenderer.d.ts in node_modules/three with @default true:

        /**
	 * If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.
         * @default true
	 */
	autoClearColor: boolean;

it will appear:

Screenshot 2020-08-03 at 16 57 02
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set default class property value in TypeScript ...
You need a constructor in order to set default values to class property. Try this: declare class Foo extends Bar { foo: number; ......
Read more >
Documentation - Modules .d.ts - TypeScript
Default Exports. In CommonJS you can export any value as the default export, for example here is a regular expression module:.
Read more >
A quick introduction to “Type Declaration” files and adding ...
In this lesson, we are going to take a closer look at type declaration files which are one of the key ingredients of...
Read more >
Documenting default interface values in typescript, or trying to...
You have a function that takes options with default values. How can you document the default values?
Read more >
Declare Module Typescript With Default Parameter Functions
Data let x 3 variable initialization functionx3 default parameter value return 3. Type void is not ... Adding Type Declaration Files To A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found