-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Search Terms
Suggestion
There should be a compiler option like strictJSDocTypes
or something to disable the object
to any
conversion present in TypeScript’s JSDoc parser.
Use Cases
I’m currently forced to use:
/** @typedef {NonNullable<Parameters<typeof Object.create>[0]>} obj */
to get a reference to TypeScript’s object
type.
Examples
Any code where I use the above.
The following code creates an object with writable, configurable and non‑enumerable properties:
var ES = require("es-abstract");
var define = require("define-properties");
var $ObjectCreate = GetIntrinsic("%Object.create%", true);
/**
* @template {object} M
* @param {object | null} proto
* @param {M & ThisType<any>} [props]
* @return {object}
*/
function createObj(proto, props) {
var result = ES.ObjectCreate(proto);
if (arguments.length > 1) {
define(result, props);
}
return result;
}
All instances of object
in the above code currently have to be replaced with the obj
type alias.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript